Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.
How to insert/update image column om SQL?
When you try to do this on sql server 2008 you got an error
update [tbl_items] set [ImagePlayer]='C:\Projects\Images\item.jpg' where [ID]=1
The error message was:
Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.
Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query
All you need is to do BulkColumn
Code for update
update [tbl_items] set [ImagePlayer]=BulkColumn FROM OPENROWSET(Bulk 'C:\Projects\Images\item.jpg', SINGLE_BLOB) AS BLOB where [ID]=1
(1 row(s) affected)
Code for Insert
INSERT INTO [ScoutMe].[dbo].[tbl_Players]
([ID],
[ImagePlayer])
SELECT 1,
BulkColumn FROM OPENROWSET(
Bulk 'C:\Projects\Images\item.jpg', SINGLE_BLOB) AS BLOB
Yours,
Roi Kolbinger :)
Comments
Post a Comment