下面的 bcp commnad 没有错误
exec master..xp_cmdshell 'bcp "select RecordType + PaymentYear from CentersApp.dbo.IRS_TRecord"
queryout "\\w2k3solomon\c$\IRS1099B\IRS_VENDORS.TXT" -T -c -S SOLOMON'
但是,当我使用变量做同样的事情时(见下文),我得到了错误'bcp' is not recognized as an internal or external command
declare @t nvarchar(200)
declare @s nvarchar(1000)
set @t = '"select RecordType + PaymentYear from CentersApp.dbo.IRS_TRecord"'
set @s = '''bcp ' + '"' + @t + '"' + ' queryout "\\w2k3solomon\c$\IRS1099B\IRS_VENDORS.TXT" -T -c -S SOLOMON '''
exec master..xp_cmdshell @s