I've a table in MS Sql serve开发者_如何学Pythonr with an image field and a file. What is the easiest way to create a T-Sql script that updates the field with the content of the file?
UPDATE YourTable
SET BlobColumn =
(SELECT BulkColumn FROM OPENROWSET(BULK N'C:\YourFile.png', SINGLE_BLOB) AS x)
WHERE ...
Drop table employees:
CREATE TABLE Employees
(
myid int,
myname varchar(50) not null,
mypic varbinary(max) not null
)
INSERT INTO Employees (myid, myname, mypic)
SELECT 10, 'John', BulkColumn
FROM Openrowset( Bulk 'C:\delete\a.bmp', Single_Blob) as EmployeePicture
UPDATE Employees SET [mypic] =
(
SELECT MyImage.*
from Openrowset(Bulk 'C:\Delete\B.bmp', Single_Blob) MyImage)
where myid = 10
After column i.e. MayImage
there should be .*
otherwise, it will not work.
精彩评论