Reputation: 3482
CREATE PROCEDURE uspInsertImage
@PCImage varbinary(max)
As
Begin
INSERT INTO dbo.PCInfo PCImage)
VALUES (@PCImage)
End
When I Write
EXEC uspInsertPC 'D:\Desktop.jpg'
Showing Error
Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.
Upvotes: 0
Views: 9389
Reputation: 26737
You are tried to save a string into a binary column that’s why you are getting this error
You should tell SQL server to use a different source provider by using OPENROWSET
you should do something the below:
INSERT INTO BLOBTest
(BLOBName, BLOBData)
SELECT 'First test file',
BulkColumn FROM OPENROWSET(
Bulk 'C:\temp\nextup.jpg', SINGLE_BLOB) AS BLOB
For more info have a look at the below:
Upvotes: 2