我想從表寫入輸出文本文件。我沒有收到任何錯誤,但文件沒有創建。使用tsql從表中寫入文本
EXEC master..xp_cmdshell 'bcp "SELECT * FROM DB.dbo.table1" queryout "C:\employee.txt" -T -Sservername -U user111 -P pwd -c -t,'
沒有文件創建,我不知道爲什麼。任何人都可以幫忙嗎?
,我沒有得到的錯誤,而不是我得到以下信息:
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-V file format version] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
NULL
我運行它在服務器A,但在數據庫服務器B等服務器AI使用SQL Server Management Studio中,給服務器B詳細信息登錄。之後,我寫了上面提到的查詢。所以文件將在哪個服務器上形成?
這實際上對我來說工作,儘管最後明顯的逗號和你指定'T'並傳入用戶名和密碼的事實。你在什麼版本上? –
我已經刪除了逗號,最後還刪除了用戶名和密碼。但仍然沒有運氣 – CPDS