BulkInsert In Stored Procedure

  • I have a BULK INSERT command as below

    BULK INSERT slave_tab

    FROM 'C:\Documents and Settings\INTEL1\Desktop\exampledata.txt'

    WITH

    (

    FIELDTERMINATOR ='^',

    ROWTERMINATOR ='^$'

    its working fine...

    I need to pass the file 'C:\Documents and Settings\INTEL1\Desktop\exampledata.txt' as the parameter of an Stored Procedure...how can I do it...

    exampledata.txt' contains a string of data as below...

    677^5678^hhh^44^$5566^5678^hgg^33^$777^5678^fg^55^$666^5678^ff^333^$

    Thanks!

  • Build a dynamic query for your BULK INSERT

    exec ('BULK INSERT slave_tab

    FROM ''' + @YourFileName + '''

    WITH

    ( FIELDTERMINATOR =''^'',

    ROWTERMINATOR =''^$'')')

    Good luck!

    -- CK

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

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