How to get over "Can't get text, text and graphic variables". on SQL Server?

I am getting the error: Msg 16927, Level 16, State 1, Procedure GetWfGenProcessParameters, Line 21 Unable to get into text, text and graphic variables.

I really need to make this cursor work with text data. Is there a way to overcome this error?

0


source to share


2 answers


If you are using SQL Server 2005

, you can use NVARCHAR(MAX)

:



CREATE TABLE text_test (test NTEXT NOT NULL)

INSERT
INTO    text_test
VALUES  ('test')

DECLARE @t NVARCHAR(MAX);

DECLARE txt_cur CURSOR FOR
        SELECT test
        FROM   text_test

OPEN    txt_cur

FETCH   NEXT
FROM    txt_cur
INTO    @t

CLOSE txt_cur

DEALLOCATE txt_cur
GO

DROP TABLE text_test
GO

      

+2


source


FIrst why you are using cusrsor cursors should be avoided at all costs. If you use a set-based solution, your problem may go away. However, without any idea as to what you are trying to do with an inteh cursor, it is difficult to give advice. Of course, I cannot change the fact that SQL Server does not allow you to put text data in a variable. When you run into a system limitation, you need to rethink what you do and how you do it.



+1


source







All Articles