Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 if exists question

Author  Topic 

ronin2307
Posting Yak Master

126 Posts

Posted - 2008-07-22 : 13:04:00
hi,

quick background...Our ERP package has a gaping hole in the reporting of WIP(Work In Progress)
so to go around this deficiency, i have decided to take a snapshot of appropriate data at the end of the month and copy it over to a entirely different database/table.

so far so good. I can do that without any issues with a SP attached to a job.

What i am curious about is the prevention of duplicate data in my target table. When i do my select statement from the original table, i get about 1000 rows back. What i would like to do is check if any of these rows exists in my target table and skip those that do.
can that be done?If so, how?

thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-07-22 : 13:10:01
You can use

1) LEFT JOIN with IS NULL check
2) You can use NOT EXISTS



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

ronin2307
Posting Yak Master

126 Posts

Posted - 2008-07-22 : 13:28:48
will not exists work for a number of records in one query or does it work only for one? I hope you understand what i mean
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-22 : 13:41:54
quote:
Originally posted by ronin2307

will not exists work for a number of records in one query or does it work only for one? I hope you understand what i mean


it will work for number of records. b/w can i ask if you will having only inserts happening on your main table or will updates happen too? in which dont you require updated info to be also brought in?
Go to Top of Page

ronin2307
Posting Yak Master

126 Posts

Posted - 2008-07-23 : 14:48:23
just inserts
all i am trying to do is save the data as is on the last day of the month, so i can run a query to report on the WIP.
Go to Top of Page
   

- Advertisement -