Home Forums SQL Server 2005 Business Intelligence How to validate data of a flat file source with the data of different tables of my database? RE: How to validate data of a flat file source with the data of different tables of my database?

  • Ashok

    OK, I'm assuminng you know how to get all your data into a staging table, which we'll call SampleData. I'm not sure I understand the second and third rules, but you can do the first one something like this. I'm inserting into an error table rather than file for ease; if you need to, you can export it out to a file at the end.

    INSERT INTO ErrorTable (ErrorDate, ColA, ColB, ColC, ColD, ColE)

    SELECT

    CURRENT_TIMESTAMP

    ,ColA

    ,ColB

    ,ColC

    ,ColD

    ,ColE

    FROM

    SampleData s

    LEFT JOIN

    TableA t ON s.ColA = t.ColA

    WHERE

    s.ColA IS NULL

    John