每天读取昨天的txt 怎么就不行了呢?
霉天会产生一个output.txt日期.txt的文件
比如今天就是 output.txt2007-03-22.txt
然后第二天读进数据表,可是报错,大人看看.
declare @yesterday char(10)
select @yesterday=convert(varchar(10),getdate()-1,120)
exec(
'BULK INSERT test
FROM d:\\output.txt '+@yesterday+ ' WITH ( FIELDTERMINATOR = ' '| ' ', ROWTERMINATOR = ' '\n ' ' ) '
)
------解决方案--------------------多了個\,另外,路徑前後要加上 " ' "
declare @yesterday varchar(10)
select @yesterday=convert(varchar(10),getdate()-1,120)
exec(
'BULK INSERT test
FROM ' 'd:\output.txt '+@yesterday+ '.txt ' ' WITH ( FIELDTERMINATOR = ' '| ' ', ROWTERMINATOR = ' '\n ' ' ) '
)