SQL storage image

Source: Internet
Author: User

1. creation process
Create procedure sp_textcopy (
@ Srvname varchar (30 ),
@ Login varchar (30 ),
@ Password varchar (30 ),
@ Dbname varchar (30 ),
@ Tbname varchar (30 ),
@ Colname varchar (30 ),
@ Filename varchar (30 ),
@ Whereclause varchar (40 ),
@ Direction char (1 ))
As
Declare @ exec_str varchar (255)
Select @ exec_str =
'Textcopy/s' + @ srvname +
'/U' + @ login +
'/P' + @ password +
'/D' + @ dbname +
'/T' + @ tbname +
'/C' + @ colname +
'/W "' + @ whereclause +
'"/F' + @ filename +
'/' + @ Direction
Exec master .. xp_mongoshell @ exec_str

2. Create a table and initialize data
Create Table Name (No. Int, image column name image)
Go
Insert table name values (1, 0x) -- required, and not null
Insert table name values (2, 0x) -- required and not null
Go

3. Read
Sp_textcopy 'your server name', 'sa ', 'Your password', 'database name', 'table name', 'image column name', 'c:/image .bmp ', 'Where id = 1', 'I' -- note that the condition is number = 1

Sp_textcopy 'your server name', 'sa ', 'Your password', 'database name', 'table name', 'image column name', 'c:/bb.doc ', 'Where id = 2', 'I' -- note that the condition is number = 2

Go

4. Read data into files
Sp_textcopy 'your server name', 'sa ', 'Your password', 'database name', 'table name', 'image column name', 'c:/image .bmp ', 'Where id = 1', 'O' -- note that the condition is number = 1

Sp_textcopy 'your server name', 'sa ', 'Your password', 'database name', 'table name', 'image column name', 'c:/bb.doc ', 'Where id = 2', 'O' -- note that the condition is number = 2
Go

If textcopy is not an executable file
C:/program files/Microsoft SQL Server/MSSQL/binn
Copy textcopy.exe to the following directory:
C:/Windows/system32

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.