Skip to Content

Solved: How do I move the image field into nvarchar(max) field in SQL/VB.Net syntax?


I need to take an Image datatype from one SQL database and insert it into a second database that is using nvarchar(max) for images.

Is nvarchar(max) what they should be using? When I do an insert, the image appears as System.byte[] in the table. Should there be a cast or convert done to the image datatype to get it to work?

The query as below:

Select [mypicture] from [dbo].[oldtable] into a datareader (drPic.Item("mypicture")) (image datatype)

Update [dbo].[newtable] Set [mypicture] = drPic.Item("mypicture") (nvarchar(max) datatype)


varchar is for characters, you should use varbinary instead. If you really want to use a varchar field, you need to encode your image.


Microsoft SQL Docs > SQL > Reference > Transact-SQL (T-SQL) Reference > String & binary > binary and varbinary (Transact-SQL)

How to Convert Image to Base64 in VB.Net

    Ads Blocker Image Powered by Code Help Pro

    Ads Blocker Detected!!!

    This site depends on revenue from ad impressions to survive. If you find this site valuable, please consider disabling your ad blocker.