2

我收到错误:

SQLState = S1000,NativeError = 0 错误 = [Microsoft][SQL Server Native Client 10.0]无法打开 BCP 主机数据文件

运行以下命令时:

set nocount on;
Declare @sql varchar(1000);
declare @noteid int;
declare xx1 cursor for select nic.NotebookItemId from NotebookItemContent nic
inner join NotebookLinks nl on nl.NotebookItemId = nic.NotebookItemId
inner join NotebookItems ni on ni.NotebookItemId = nic.NotebookItemId
where nl.clientid = 1235074
AND ni.NotebookTypeId = 56;
open xx1;
fetch xx1 into @noteid;
while (@@fetch_status = 0)
begin
set @sql = 'BCP "SELECT memo FROM Monarch_Pronet_ITOIL.dbo.notebookitemcontent where notebookitemid=' + cast(@noteid as varchar) + 
'" QUERYOUT C:\TEMP\' + cast(@noteid as varchar) + '.doc -T -f C:\temp\bcp.fmt -S ' + @@SERVERNAME
EXEC master.dbo.xp_CmdShell @sql
fetch xx1 into @noteid;
end;
close xx1;
deallocate xx1;

任何帮助,将不胜感激!

打印@SQL 返回:

BCP "SELECT memo FROM Monarch_Pronet_ITOIL.dbo.notebookitemcontent where notebookitemid=17695498" QUERYOUT C:\TEMP\17695498.doc -T -f C:\temp\bcp.fmt -S BHAMSQL-SRV03

还意识到我的原始查询不正确(选择所有备忘录而不是使用光标......!所以现在正确的查询是上面的查询 - 为我作为布偶道歉:D

4

1 回答 1

2

你能做一个

PRINT @sql 

并查看@sql 字符串值是什么。我猜,它是一个错误的引用或反斜杠

于 2012-04-12T15:10:08.340 回答