尝试通过引入全局常量来改进一些 tsql 批量插入代码:
declare @folder varchar(max)
declare @fileLocation varchar(max)
set @folder = 'C:\SomeFolder\'
set @fileLocation = @folder + 'Data.txt';
BULK INSERT #Table
FROM ''' + @fileLocation + '''
WITH (
FIRSTROW = 2,
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n'
);
尝试了 FROM 代码的所有变体,但均未成功。有任何想法吗?谢谢。