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