unable to load data from flat file to sql table using bulk insert sql statement

  • Hi,

    I am unable to load data from flat file to sql table using bulk insert sql statement

    my code:-

    DECLARE @filePath VARCHAR(200)

    DECLARE @sql VARCHAR(8000)

    Declare @filename varchar(100)

    set @filename='CCNVZ_150401054418'

    SET @filePath = 'I:\IncomingFiles\'+@FileName+'.txt'

    DECLARE @TableName VARCHAR(225)

    declare @sqltruncate varchar(250)

    SET @TableName = 'DataStaging.dbo.Staging_Temp'

    SET @sql = 'BULK INSERT '+ @TableName +

    ' FROM ''\\RLDEVOLP04\IncomingFiles\'+@FileName+'.txt''

    WITH (FORMATFILE = ''I:\Format.xml'',BATCHSIZE = 10000) '

    SELECT @sql

    select @filePath

    select @filename

    select @TableName

    please help me to get resolved the issue.

    regards,

    Vipin jha

  • Looks like the only thing missing is actually to execute the dynamic sql

    😎

    EXEC (@sql);

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply