Hi all,
I am trying to create a small cursor to move an image data field from one table to another. I have to change an index key so I think this is the best way to do it.
However, I am getting the following error:
Server: Msg 2739, Level 16, State 1, Line 3
The text, ntext, and image data types are invalid for local variables.
I dont know much about the IMAGE DATA type. I have found some info using WRITETEXT to write an image file but need a little help incorporating it into my small cursor..
Here is the example:
----------------------
DECLARE MOVEREPORTS SCROLL CURSOR FOR select repsId,Definition from DDI_OLD..rblb
SET NOCOUNT ON
DECLARE
@P1 int,@P2 int ,@P3 IMAGE
-- Looping through all the records in the selected set
OPEN MOVEREPORTS
FETCH NEXT FROM MOVEREPORTS INTO @P1,@P3
WHILE (@@FETCH_STATUS <> -1)
BEGIN
IF (@@FETCH_STATUS <> -2)
BEGIN
Select @P2=(select repsid from DDI_NEW..reps where DDI_NEW..reps.repscode=(select repscode from DDI_OLD..reps where DDI_OLD..reps.repsid=@P1))
INSERT INTO DDI_NEW..reps (repsId, defintion) VALUES(@P2,@P3)
END
FETCH NEXT FROM MOVEREPORTS INTO @P1,@P3
END
-- Closing the Cursor and the loop
CLOSE MOVEREPORTS
DEALLOCATE MOVEREPORTS
SET QUOTED_IDENTIFIER OFF
SET ANSI_NULLS ON
__________________________________________________
Any ideas are greatly appreciated!
Regards,
MDA
I am trying to create a small cursor to move an image data field from one table to another. I have to change an index key so I think this is the best way to do it.
However, I am getting the following error:
Server: Msg 2739, Level 16, State 1, Line 3
The text, ntext, and image data types are invalid for local variables.
I dont know much about the IMAGE DATA type. I have found some info using WRITETEXT to write an image file but need a little help incorporating it into my small cursor..
Here is the example:
----------------------
DECLARE MOVEREPORTS SCROLL CURSOR FOR select repsId,Definition from DDI_OLD..rblb
SET NOCOUNT ON
DECLARE
@P1 int,@P2 int ,@P3 IMAGE
-- Looping through all the records in the selected set
OPEN MOVEREPORTS
FETCH NEXT FROM MOVEREPORTS INTO @P1,@P3
WHILE (@@FETCH_STATUS <> -1)
BEGIN
IF (@@FETCH_STATUS <> -2)
BEGIN
Select @P2=(select repsid from DDI_NEW..reps where DDI_NEW..reps.repscode=(select repscode from DDI_OLD..reps where DDI_OLD..reps.repsid=@P1))
INSERT INTO DDI_NEW..reps (repsId, defintion) VALUES(@P2,@P3)
END
FETCH NEXT FROM MOVEREPORTS INTO @P1,@P3
END
-- Closing the Cursor and the loop
CLOSE MOVEREPORTS
DEALLOCATE MOVEREPORTS
SET QUOTED_IDENTIFIER OFF
SET ANSI_NULLS ON
__________________________________________________
Any ideas are greatly appreciated!
Regards,
MDA