locked
SSIS Null inserts in tables RRS feed

  • Question

  • I have a tab delimited text file. I am loading the text file intoaSQL Serve table. There are fields where there is no data and hence has to be inserted as NULL into the table. But however a 0 (zero) is inserted in its place. Note the default value for tht field is NOT set to any value. Can anyone let me know why this is happening?
    Tuesday, March 29, 2011 12:33 PM

Answers

  • I am using the OLE DB destination as the end point in data flow task. The problem is that when i view the data in the data viewer just after the Flat file source, a zero is read instead of NULL. In such a case i cannot use a derived column transformation too, as there is no blank record coming in. I guessing if there are any other propert setting that needs to be done.


    Did you try my suggestion to set the "Retain null values from the source as null values in the dataflow" in the Flat File Source?
    MCTS, MCITP - Please mark posts as answered where appropriate.
    • Marked as answer by karthikbjadav Thursday, March 31, 2011 5:39 AM
    Wednesday, March 30, 2011 5:33 AM

All replies

  • use a derived column and write an expression to load "0" as default value if data is not there.. something like below..

    Trim(coulnm1)=="" ? NULL , column1


    Let us TRY this |

    My Blog :: http://quest4gen.blogspot.com/
    Tuesday, March 29, 2011 12:39 PM
  • I think the question asked needs a solution for doing exactly the opposite of what is proposed in top: Inserting NULL instead of 0.

    You have 2 choices:

    1- Replace ADO .NET Destination with OLE DB Destination;

    2- Add a Derived Column transformation after Flat File Source to convert 0 to NULL using the following SSIS expression:

    column1 == 0 ? NULL, column1

    Cheers!


    Please mark as answer if this helps. Thank you.

    http://thebipalace.wordpress.com

    Tuesday, March 29, 2011 1:07 PM
  • The zeroes are inserted as the Flat File Source replaces null values by 0 when fetching the data. If you do not want this, simply select the checkbox at
    "Retain null values from the source as null values in the dataflow". That should solve your problem.
    MCTS, MCITP - Please mark posts as answered where appropriate.
    Tuesday, March 29, 2011 1:13 PM
  • I am using the OLE DB destination as the end point in data flow task. The problem is that when i view the data in the data viewer just after the Flat file source, a zero is read instead of NULL. In such a case i cannot use a derived column transformation too, as there is no blank record coming in. I guessing if there are any other propert setting that needs to be done.

    Wednesday, March 30, 2011 4:49 AM
  • I am using the OLE DB destination as the end point in data flow task. The problem is that when i view the data in the data viewer just after the Flat file source, a zero is read instead of NULL. In such a case i cannot use a derived column transformation too, as there is no blank record coming in. I guessing if there are any other propert setting that needs to be done.


    Did you try my suggestion to set the "Retain null values from the source as null values in the dataflow" in the Flat File Source?
    MCTS, MCITP - Please mark posts as answered where appropriate.
    • Marked as answer by karthikbjadav Thursday, March 31, 2011 5:39 AM
    Wednesday, March 30, 2011 5:33 AM
  • Thanks Koen. It worked!!! I had missed to check it.
    Thursday, March 31, 2011 5:39 AM
  • Thanks Koen. It worked!!! I had missed to check it.

    Great! Glad you could solve your problem!
    MCTS, MCITP - Please mark posts as answered where appropriate.
    Thursday, March 31, 2011 5:46 AM