将表数据写入文本文件时收到错误

时间:2016-08-11 13:54:39

标签: sql tsql

我尝试过以下希望从表格到文本文件中写入记录并收到以下错误:

exec sp_configure 'show advanced option',1
reconfigure

exec sp_configure  xp_cmdshell,1
reconfigure


DECLARE @OutputFile NVARCHAR(100) ,    @FilePath NVARCHAR(100) ,    @bcpCommand NVARCHAR(1000)

SET @bcpCommand = 'bcp "SELECT Name FROM Customer " queryout '
SET @FilePath = 'C:\'
SET @OutputFile = 'testFile.txt'
SET @bcpCommand = @bcpCommand + @FilePath + @OutputFile + ' -c -t, -T -S'+ @@servername
exec master..xp_cmdshell @bcpCommand

错误:

SQLState = S0002, NativeError = 208
Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid object name 'Customer'.
SQLState = 37000, NativeError = 8180
Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement(s) could not be prepared.
NULL

0 个答案:

没有答案