DECLARE @path text;
SET @path = 'c:\bulk'
BULK INSERT [HumanResources].[Employee] FROM -- I Want to use the variable here !!
WITH (
CHECK_CONSTRAINTS,
CODEPAGE='ACP',
DATAFILETYPE='widechar',
FIELDTERMINATOR='\t',
ROWTERMINATOR='\n',
KEEPIDENTITY,
TABLOCK
);
DECLARE @path nvarchar(2000);
SET @path = 'c:\bulk.(extension)';
DECLARE @sql NVARCHAR(MAX) =
'''BULK INSERT [HumanResources].[Employee] FROM' + @path + '
WITH (
CHECK_CONSTRAINTS,
CODEPAGE=''ACP'',
DATAFILETYPE=''widechar'',
FIELDTERMINATOR=''\t'',
ROWTERMINATOR=''\n'',
KEEPIDENTITY,
TABLOCK
)'''
EXECUTE sp_executesql(@sql)
这篇关于我想使用我在其他地方声明的变量,但我不能(简单的 sql 查询)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!