Help with bulk insert

  • KEEPNULLS will keep any NULL value as in what would be in column C here ... "A,B,,D"

    But your data has a value, and that value is the word "NULL".

    I do believe, you'll either need to pull in your data as varchar, change NULL to 0 or actually set to NULL, or intercept/modify the input data before importing.

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • i think the issue is BULK INSERT cannot differentiate between a string between two commas and the keyword NULL;

    I'm not sure how to tackle that, other than putting it into a temporary table and importing from that based on a case statement.

    SomeValue,1,OtherValue --expected int value

    SomeValue,,OtherValue --would make the second value in the set NULL,

    SomeValue,Null,OtherValue --assumes it's a string

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Ah, didn't think about my value being the WORD null.

  • can you pre-process the file by replacing Null with String.Empty? then you could continue using bulk insert

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 4 posts - 1 through 5 (of 5 total)

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