Image data types are not valid for local variables (using openrowset cannot make it work)

Using Sql server 2005

You must call the stored procedure with many parameters and one that is the image column that is used for the word document. I cannot change the database, since it is not under my control. I can not show the result of openrowset for the variable as I get

"Text, ntext, and image data types are not valid for local variables."

What is workround.

Below is the code that cannot make it work.

DECLARE BinaryContent image SET @BinaryContent=(SELECT BulkColumn FROM OPENROWSET(BULK N'C:\mydoc.docx', SINGLE_BLOB) blob EXEC [dbo].[InsertWordDocument] @Id = NEWID, @Name = N'DocName', @Description = N'DescriptionToChange', @BinaryColumn =@BinaryContent 

How can I do the above work?

Thank you very much

+6
source share
1 answer

Use varbinary (max) instead of image. Varbinary (max) can be passed as the value of the image parameter.

The ntext, text, and image data types are deprecated and will be removed in a future version of SQL Server.

+13
source

All Articles