我希望我不是在问..但是..。
下面是我的SQL的相关部分。有问题的视图(vw_TempALlItems)是在前面的步骤中创建的,是的,它使用列名创建,并注意类型等。视图可以100%正常工作。但是BCP,就没那么多了..
---------------------------------------------------------------
DECLARE @bcpCommand varchar(2000)
SET @bcpCommand = 'bcp vw_TempAllItems out
"c:\FEPData.csv" -c -t -U USER -P PWD'
EXEC master..xp_cmdshell @bcpCommand
GO
Drop View vw_TempAllItems
GO
----------------------------------------------------------------我得到的唯一结果窗格显示的是BCP命令参数
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-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]
[-h "load hints"] [-x generate xml format file]
[-d database name]
NULL并且未创建CSV文件。
有没有人?
发布于 2013-05-09 04:04:11
对于任何关心这个问题的人来说,最终的结果都很好
DECLARE @bcpCommand varchar(2000)
SET @bcpCommand = 'bcp ' + DB_NAME() + '..vw_TempAllItems out c:\FEPData.csv -c -t, -U User -P Pwd -S' + @@SERVERNAME
EXEC master..xp_cmdshell @bcpCommand
GO发布于 2013-05-08 23:09:24
比如,试着把它变成一个查询:
SET @bcpCommand = 'bcp "SELECT * FROM vw_TempAllItems" out
"c:\FEPData.csv" -c -t -U USER -P PWD'另外,要回答您的问题,请查看: stackoverlow上的How to pass parameter to a bcp command in sql server。
https://stackoverflow.com/questions/16444082
复制相似问题