Implicit conversion from data type varchar to varbinary(max) is not allowed
CREATE PROCEDURE uspInsertImage
@PCImage varbinary(max)
As
Begin
INSERT INTO dbo.PCInfo PCImage)
VALUES (@PCImage)
End
When I Write
EXEC uspInsertPC 'D:\Desktop.jpg'
Showin开发者_StackOverflowg Error
Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.
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:
http://www.databasejournal.com/features/mssql/article.php/3724556/Storing-Images-and-BLOB-files-in-SQL-Server-Part-2.htm
精彩评论