日期:2014-05-18 浏览次数:20603 次
create PROCEDURE sp_textcopy ( @srvname varchar (30), @login varchar (30), @password varchar (30), @dbname varchar (30), @tbname varchar (30), @photoname 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 ' + @photoname + ' /W "' + @whereclause + '" /F ' + @filename + ' /' + @direction EXEC master..xp_cmdshell @exec_str ,no_output create table photo(id int identity(1,1),photo image,memo nvarchar(50) default 'my photo') go insert photo(photo) values(0x) -- 必须的,且不是null select * from photo --truncate table photo sp_textcopy 'roy','sa','wuxi','test','photo','photo','E:\photo\myphoto\roy3.jpg','where id=5','I' --注意条件是 id=1 3、读入 sp_textcopy 'roy','sa','wuxi','test','photo','photo','E:\photo\photo\21.jpg','where id=1','I' --注意条件是 id=1 sp_textcopy 'roy','sa','wuxi','test','photo','photo','E:\photo\photo\33.jpg','where id=2','I' --注意条件是 id=2 go 4、读出成文件 sp_textcopy 'roy','sa','wuxi','test','photo','photo','E:\photo\roy.jpg','where id=1','O' --注意条件是 id=1 sp_textcopy 'roy','sa','wuxi','test','photo','photo','E:\photo\roy1.jpg','where id=2','O' sp_textcopy 'roy','sa','wuxi','test','photo','photo','E:\photo\roy2.jpg','where id=3','O' sp_textcopy 'roy','sa','wuxi','test','photo','photo','E:\photo\roy3.jpg','where id=4','O' sp_textcopy 'roy','sa','wuxi','test','photo','photo','c:\bb.doc','where id=5','O' --注意条件是 id=2