For data in specific tables I will need to generate images, those images will have to be printed or displayed by various different applications.
First of all I need to store the image.
To store an image in a tablecolumn on SQL Server 2008, the manual advises to use the varbinary(MAX) type and not the image data type.
Store the image with a SQL server statement
OPENROWSET is a T-SQL function that allows for reading data from many sources including using the SQL Server’s BULK import capability.
The bulk provider keyword needs to be SINGLE_BLOB, which reads a file as varbinary(max).
The path to the image file is a path that the SQL Server needs to be able to read, do not confuse it with the path that an app can read, i.e. if you execute the statement from SSMS on your PC then the path E: will be a drive on the server not on your PC.
The SQL server statement to insert an image is
INSERT INTO dbo.MyTable (Id,Name,LocationPicture,)
FROM Openrowset( Bulk 'E:\ImportBarcode\000014.jpg', SINGLE_BLOB) as A
This will result in one new row being added to the table dbo.MyTable.