0
即時通訊使用Sql2008試圖運行此BCP命令,但它永遠不會創建該文件。問題與BCP寫入.txt文件從SQL
-- Export query
DECLARE @qry2 VARCHAR(1000)
SET @qry2 = 'SELECT * FROM @SkippedProductsTable'
-- Folder we will be putting the file in
DECLARE @incomingfolder VARCHAR(1000)
SET @incomingfolder = 'c:\Logs'
DECLARE @bcpCommand VARCHAR(2000)
SET @bcpCommand = 'bcp "'[email protected]+'" queryout "'[email protected]+'\SkippedProducts-'+CAST(@StoreMatchCode AS VARCHAR)+'-'+'.txt" -c -T'
PRINT @bcpCommand
EXEC MASTER..xp_cmdshell @bcpCommand, no_output
所創建的命令看起來像:
bcp "SELECT * FROM @SkippedProductsTable" queryout "c:\Logs\SkippedProducts-1330-.txt" -c -T
任何人都可以提出什麼可以去錯了嗎?我從來沒有使用過BCP,也不確定從哪裏開始尋找。
作爲一個開始,我知道該文件夾deffinately在該位置存在
你真的把第一行分配給了@ @ Bcpcommand變量嗎? – JNK
並且不要忘記這是服務器上的路徑 –
是的,第一行實際上是來自@bcpCommand的變量的變量變量也將服務器上存在的文件夾的路徑存在於服務器上 – Purplegoldfish