Thursday, October 9, 2008

Insert Picture into Image Field using T-SQL

Here's an example of how to quickly load a picture into an image field using T-SQL.

INSERT INTO [hr].[NTUsers] (
[userid],
[username],
[title],
[reportsto],
[pic]
)
SELECT
'00001',
'Chip Porter',
'Technology Services',
'00000',
BulkColumn FROM OPENROWSET(BULK 'c:\noimage.bmp', SINGLE_BLOB) AS ImageLoad
GO

1 comment:

Unknown said...

Worked perfectly, thanks!