How to store images and sounds in SQL without using other tools: 1. CREATEPROCEDUREsp_textcopy (@ srvnamevarchar (30), @ loginvarchar (30 ), @ passwordvarchar (30), @ dbnamevarchar (30), @ tbnamevarchar (30), @ colnamevarchar (30), @ filen, store images and sounds in SQL
Image type
Method:
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
'/' @ Ction
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: \ Program Files \ Microsoft SQL Server \ 80 \ Tools \ Binn