--導出數據到tset1.txt,並指定本地數據庫的用戶名和密碼 --這裏須要指定數據庫徹底限定名。 --username 數據登陸名 --password 數據庫密碼 EXEC master..xp_cmdshell 'BCP "SELECT * FROM Testdb.dbo.TestVoucher" queryout d:\tset1.txt -c -U"username" -P"password"'
注:SQL Server阻止了對組件xp_cmdshell過程的解決方案shell
sp_configure 'show advanced options',1 reconfigure go sp_configure 'xp_cmdshell',1 reconfigure go
BCP "SELECT * FROM Testdb.dbo.TestVoucher" queryout d:\tset1.txt -c -S"服務器地址" -U"username" -P"password"
如圖:數據庫
EXEC master..xp_cmdshell 'bcp Testdb.dbo.TestVoucher in d:\tset1.txt -c -T'
bcp Testdb.dbo.TestVoucher in d:\tset1.txt -c -T
圖:服務器