0
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
);
4

2 に答える 2

1
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) 
于 2013-10-06T18:29:17.783 に答える