Querry for missing data from warehouse?

  • Hi,

    I have two data bases. One SQL and One Oracle. The MSSQL is my production and the Oracle is my warehouse.  I use linked servers to querry my warehouse tables.  The problem I have is that sometimes, records do not get into the warehouse table.

    How can I with a querry find the which record exists in the production table that does not exist in the warehouse table for a given time frame?

    Thanks,

    Brian

  • SELECT * FROM [LinkedServer].DB.Owner.Table

      WHERE NOT EXISTS (SELECT * FROM Production.DB.Owner.Table)

    ???? Possibly ???  See BOL for more information on NOT EXISTS (my syntax may need tweaking)



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • I think the query will return all the rows if the destination is empty and no rows if the destination has one or more rows.

    I believe that

    Select * from [LinkedServer].DB.Owner.Table

    where [UniqueColumn] not in (Select [UniqueColumn] from Production.DB.Owner.Table)

    would do what you want.  Note that [UniqueColumn] would be the Primary Key in most cases, but not all cases.  If the key is composite, then you'd have to rewite the query somewhat.

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

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