data script error??

  • I am writing a script to retrieve data records of MarinLif table. The problem is that i have a column MarinLif_Picture of type image so the insert is wrong in this way. How do i correct it?

    /*****MarinLIf TAble ********************/

    DECLARE @ID INT

    DECLARE @typeID INT

    DECLARE @NAME NVARCHAR(50)

    Declare @scName nvarchar(50)

    Declare @distribution nvarchar(600)

    Declare @maxSize nvarchar(200)

    Declare @env nvarchar(200)

    Declare @climate nvarchar(200)

    Declare @country nvarchar(2000)

    Declare @desc nvarchar(4000)

    Declare @pic image

    DECLARE CURS CURSOR STATIC FOR

      SELECT MarinLIf_ID, MarinLIfTyp_ID,MarinLif_name, MarinLIf_ScName,MarinLIf_Distribution,

     MarinLIf_MaxSize,MarinLIf_Env,MarinLIf_climate,MarinLIf_Country,MarinLIf_Desc,MarinLIf_Pic

     FROM MarinLif

    OPEN CURS

    FETCH NEXT FROM CURS INTO @ID,@typeID,@NAME, @scName, @distribution, @maxSize, @env, @climate,

       @country, @desc, @pic

    PRINT 'SET IDENTITY_INSERT MarinLif ON'

    WHILE @@FETCH_STATUS = 0

    BEGIN

     PRINT 'INSERT INTO MarinLif (MarinLIf_ID, MarinLIfTyp_ID,MarinLif_name, MarinLIf_ScName,MarinLIf_Distribution,

     MarinLIf_MaxSize,MarinLIf_Env,MarinLIf_climate,MarinLIf_Country,MarinLIf_Desc,MarinLIf_Pic)

      VALUES (' +  convert(varchar,@ID) + ','

         +  convert(varchar,@typeID) + ','

         +  '''' + @NAME + '''' +

          +  '''' + @scName + '''' + ','

          +  '''' + @distribution + '''' + ','

         +  '''' + @maxSize + '''' + ','

         +  '''' + @env + '''' + ','

         +  '''' + @climate + '''' + ',' 

         +  '''' + @country + '''' + ','

         +  '''' + @desc + '''' + ','

         +  '''' + @climate + '''' + ','

         +  '''' + @pic + '''' + ')'

    FETCH NEXT FROM CURS INTO @ID,@typeID,@NAME, @scName, @distribution, @maxSize, @env, @climate,

       @country, @desc, @pic

    END

    PRINT 'SET IDENTITY_INSERT MarinLif OFF'

    CLOSE CURS

    DEALLOCATE CURS

  • use textptr and writetext functions to deal with image field.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply