0

谁能帮我纠正以下陈述:

SET @cmd='BULK INSERT ' + @Database + '.dbo.' + @tmp + ' from ' + @Out + @tmp + '.csv 
WITH (FIELDTERMINATOR = , , ROWTERMINATOR = \n)' 

上述查询的输出是:

从 C:\SABA\GLCODE.csv 批量插入 MP2.dbo.GLCODE WITH (FIELDTERMINATOR = , , ROWTERMINATOR = \n)

我想以以下方式打印它:

从 C:\SABA\GLCODE.csv 批量插入 MP2.dbo.GLCODE WITH (FIELDTERMINATOR =',', ROWTERMINATOR = '\n')

4

2 回答 2

0

尝试这个

SET @cmd='BULK INSERT ' + @Database + '.dbo.' + @tmp + ' from ' + @Out + @tmp + 
            '.csv WITH (FIELDTERMINATOR = '','' , ROWTERMINATOR = ''\n'')'

只需使用''which 用作转义序列字符即可获得额外的'

于 2012-11-04T11:59:48.250 回答
0
SET @cmd='BULK INSERT ' + @Database + '.dbo.' + @tmp + ' from ''' + @Out + @tmp + '.csv'' WITH (FIELDTERMINATOR = '','', ROWTERMINATOR = ''\n'')' 

Yogi 建议的方法应该可行,但您还需要在文件名周围加上撇号。

于 2012-11-04T19:36:55.810 回答