SQL Server 2008 R2中的BCP导出问题

时间:2013-06-25 11:15:15

标签: sql-server-2008-r2

INSERT INTO DVR_DOCUMENTS(path, Document)
Select 
       'C:\2.csv', 1.csv  
    FROM OPENROWSET 
       (BULK 'C:\2.csv', SINGLE_BLOB) Document

Declare @sql varchar(500)

set @sql = 'BCP "select DOCUMENT from [dbname].dbo.DVR_DOCUMENTS Where ID=1" QUERYOUT C:\7.CSV -T -f C:\DVR_DOCUMENTS.fmt -S ' + @@SERVERNAME

print @SQL
EXEC master.dbo.xp_CmdShell @sql

bcp "select DOCUMENT from [Dbname].dbo.DVR_DOCUMENTS Where ID=9" queryout C:\7.pdf -T -c

输出

NULL
Starting copy...
NULL
1 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total     : 1      Average : (1000.00 rows per sec.)
NULL

我无法下载我上传的文件。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

声明@SQLcommand nvarchar(4000) set @SQLcommand ='bcp“SELECT [DOCUMENT] FROM ngap_poc.dbo.DVR_DOCUMENTS其中Id = 11”queryout“C:\ test03.pdf”-T -n'

exec xp_cmdshell @SQLcommand