这是我的 BCPCommand,查询的其余部分已经过测试并且工作正常,我还测试了 BCP 查询中的结果并且也是有序的
DECLARE @OutputFile VARCHAR(100) ,
@FilePath VARCHAR(100) ,
@bcpCommand VARCHAR(1000)
SET @bcpCommand = 'bcp "exec [dbo].[spRMAReturnBatchRecords] @strBatchNo = ' + @strBatchNo +
' , @dtBatchDate = ''' + CONVERT(VARchar(10),@dtBatchDate,120) +
''' , @intBatchNo = ' + CONVERT(varchar(5),@intNextBatchNo) + '" queryout '
SET @FilePath = 'E:\RMA\Test\'
SET @OutputFile = 'RMA-' + @strBatchNo +'.txt'
--SET @bcpCommand = @bcpCommand + @FilePath + @OutputFile + ' -S'+ @@servername + ' -T -c'
SET @bcpCommand = @bcpCommand + @FilePath + @OutputFile + ' -c -T -S ' + @@SERVERNAME
exec master..xp_cmdshell @bcpCommand
--TEST COMMAND
--print @bcpCommand
--TEST OUTPUT
--exec spRMAReturnBatchRecords @strBatchNo, @dtBatchDate, @intNextBatchNo
我目前收到的错误如下:
Starting copy...
SQLState = 37000, NativeError = 2812
Error = [Microsoft][SQL Server Native Client 11.0][SQL Server]Could not find stored procedure 'spRMAReturnBatchRecords'.
SQLState = S1000, NativeError = 0
Error = [Microsoft][SQL Server Native Client 11.0]Unable to resolve column level collations
BCP copy out failed
当我打印我的 Cmd 时,它的内容如下
bcp "exec [dbo].[spRMAReturnBatchRecords] @strBatchNo = SN001 , @dtBatchDate = '2014-04-02' , @intBatchNo = 1" queryout E:\RMA\Test\RMA-SN001.txt -c -T -S [omitted but correct]
然后,我将“双引号”之间的所有内容粘贴到具有当前连接的新查询中,它可以毫无问题地执行。
exec [spRMAReturnBatchRecords] @strBatchNo = SN006 , @dtBatchDate = '2014-04-02' , @intBatchNo = 6
请协助。