1、创建存储过程
CREATEPROCEDUREsp_textcopy(@srvnamevarchar(30),@loginvarchar(30),@passwordvarchar(30),@dbnamevarchar(30),@tbnamevarchar(30),@colnamevarchar(30),@filenamevarchar(30),@whereclausevarchar(40),@directionchar(1))ASDECLARE@exec_strvarchar(255)SELECT@exec_str='textcopy/S'+@srvname+'/U'+@login+'/P'+@password+'/D'+@dbname+'/T'+@tbname+'/C'+@colname+'/W"'+@whereclause+'"/F'+@filename+'/'+@directionEXECmaster..xp_cmdshell@exec_str
2、创建表和初始化数据
createtable表名(编号int,image列名image)goinsert表名values(1,0x)--必须的,且不是nullinsert表名values(2,0x)--必须的,且不是nullgo
SQLServer数据库中插入图像怎么实现
3、读入图像
sp_textcopy'你的服务器名','sa','你的密码','库名','表名','image列名','c:\图片.bmp','where编号=1','I'--注意条件是编号=1sp_textcopy'你的服务器名','sa','你的密码','库名','表名','image列名','c:\bb.doc','where编号=2','I'--注意条件是编号=2go
4、读出成文件
sp_textcopy'你的服务器名','sa','你的密码','库名','表名','image列名','c:\图片.bmp','where编号=1','O'--注意条件是编号=1sp_textcopy'你的服务器名','sa','你的密码','库名','表名','image列名','c:\bb.doc','where编号=2','O'--注意条件是编号=2go假如报textcopy不是可执行文件的话,你就到C:\ProgramFiles\MicrosoftSQLServer\MSSQL\Binn目录下拷备textcopy.exe到:C:\ProgramFiles\MicrosoftSQLServer\80\Tools\Binn。