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

    Your Support Matters...

    We run an independent site that\'s committed to delivering valuable content, but it comes with its challenges. Many of our readers use ad blockers, causing our advertising revenue to decline. Unlike some websites, we haven\'t implemented paywalls to restrict access. Your support can make a significant difference. If you find this website useful and choose to support us, it would greatly secure our future. We appreciate your help. If you\'re currently using an ad blocker, please consider disabling it for our site. Thank you for your understanding and support.