您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

如何把图片、声音等存储到sql中_MySQL

2025/12/7 20:57:28发布24次查看
如何不通过其他工具,把图片、声音等存储到sql中
用image类型
方法:
1、建立过程
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_cmdshell @exec_str
2、建表和初始化数据
create table 表名 (编号 int,image列名 image)
go
insert 表名 values(1,0x) -- 必须的,且不是null
insert 表名 values(2,0x) -- 必须的,且不是null
go
3、读入
sp_textcopy '你的服务器名','sa','你的密码','库名','表名','image列名','c:\图片.bmp','where 编号=1','i' --注意条件是 编号=1
sp_textcopy '你的服务器名','sa','你的密码','库名','表名','image列名','c:\bb.doc','where 编号=2','i' --注意条件是 编号=2
go
4、读出成文件
sp_textcopy '你的服务器名','sa','你的密码','库名','表名','image列名','c:\图片.bmp','where 编号=1','o' --注意条件是 编号=1
sp_textcopy '你的服务器名','sa','你的密码','库名','表名','image列名','c:\bb.doc','where 编号=2','o' --注意条件是 编号=2
go
如果报textcopy不是可执行文件的话,你就到
c:\program files\microsoft sql server\mssql\binn
目录下拷备 textcopy.exe到:
c:\program files\microsoft sql server\80\tools\binn
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product