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.
Author |
Topic |
miranwar
Posting Yak Master
125 Posts |
Posted - 2007-03-20 : 16:20:27
|
Hi I am archiving and deleting data with the following query:Insert into ProTonga_Reed_archive..tblDiaryDeletedMessageselect * from tblDiaryDeletedMessage WHERE iMessageToID in (select K_SO_id from sign_ons where k_event_id = @iEventid)OR iMessageFROMID in (select K_SO_id from sign_ons where k_event_id = @iEventid)Delete from tblDiaryDeletedMessageWHERE iMessageToID in (select K_SO_id from sign_ons where k_event_id = @iEventid)OR iMessageFROMID in (select K_SO_id from sign_ons where k_event_id = @iEventid)I am doing counts before and after. before the main database before the archive and after on the archive database to check the counts. I have found a discrepancy for one run where the before counts dont match the archive. I am wondering if there could be an issue with my count query:select count(*) as tblDiaryDeletedMessage_proTongafrom tblDiaryDeletedMessage , sign_onswhere ( iMessageToID = K_SO_id or iMessageFromID = K_SO_id) and k_event_id = @iEventid.The relationship between sign_ons tblDiaryDeletedMessage is one to many. Can anyone suggest a more accurate way to obtain the counts before and after the archive query.Thanks |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-20 : 17:16:30
|
The old style CROSS JOIN will produce more records if there are duplicate records in sign_ons!Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|