SQL Server 2008 inserting modified picture information

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.