In SQL Server 2008 we can use the varbinary (max) data type to save a picture, but its seeding and modification are a little bit different from other data.
Let's look at the example below:
1. Definition table: Create TABLE t_image (ID int NOT NULL, bmpimage varbinary (max) is not null)
2. Insert the data into the table:
Insert into T_image (id,bmpimage)
Select 1,bulkcolumn --bulkcolumn this keyword to write down big data columns
From OpenRowset (BULK ' e:\0. png ', Single_blob) as a;--Be sure to have an as x otherwise it will go wrong.
3. Modify the data in the table
Update T_image
Set bmpimage= (select Bulkcolumn from OPENROWSET (BULK ' e:/a.jpg ', Single_blob) as B)
where t_image.id=1;
Second, summarize the last write method used only varchar (max) .... These classes are only. and varbinary (max) has no way to modify the data.
This article is from the "Shang" blog, make sure to keep this source http://6772017.blog.51cto.com/6762017/1432383