2

これが私の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

手伝ってください。

4

2 に答える 2

1

データベースの名前をクエリに追加してみてください: [MyDatabase].[dbo].[spRMAReturnBatchRecords]

期待する出力の種類によっては、コンマで区切られている場合は区切り記号を指定する必要がある場合があります (-t ^または任意の区切り記号を使用します)。

于 2014-04-26T12:03:41.980 に答える