How to store images and sounds in SQL _ MySQL

Source: Internet
Author: User
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

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.