• Jeff Moden (2/8/2016)


    mxy (2/8/2016)


    Thanks it worked let me work on first set of data in the file.

    Thanks again for your time.

    How? When I try to load the file with Luis' code, I get the following...

    Msg 515, Level 16, State 2, Line 1

    Cannot insert the value NULL into column 'ShipmentTrackingID', table 'tempdb.dbo.#ShipmentContents___________________________________________________________________________________________________000000000006'; column does not allow nulls. INSERT fails.

    The statement has been terminated.

    The header information in the file is the problem and the "first row" of 2 doesn't contain enough columns of data to offset things.

    Jeff, the DDL needs to be changed to make ShipmentTrackingID nullable as this is not available in the file. Making that change, the header information causes no problem.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2