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 |
|
RichardSteele
Posting Yak Master
160 Posts |
Posted - 2007-12-24 : 06:18:03
|
| How can I select records that have changed or are new when comparing a previous copy of a table with the live version of the table? There is no datetime stamp in these tables. Many thanks in advance. |
|
|
pootle_flump
1064 Posts |
Posted - 2007-12-24 : 06:26:32
|
| Union the two tables, group by all columns and return all records with COUNT(*) = 1. Only union by the PK to get new records (assuming your PK is unchanging). |
 |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2007-12-24 : 06:33:14
|
| just out of interest in SQL Server 2008 there is built in 'Change Data Capture' (CDC), which appears to work in much the same way as Oracles' CDC. not sure what version you're working with of course. 2005 and earlier you need to do something similar to pootle's suggestion or set up triggers to capture changes as they occur (costly solution though in terms of performance)Em |
 |
|
|
pootle_flump
1064 Posts |
Posted - 2007-12-24 : 06:45:03
|
quote: Originally posted by elancaster just out of interest in SQL Server 2008 there is built in 'Change Data Capture' (CDC), which appears to work in much the same way as Oracles' CDC. not sure what version you're working with of course. 2005 and earlier you need to do something similar to pootle's suggestion or set up triggers to capture changes as they occur (costly solution though in terms of performance)Em
Hopefully the live table isn't on 2008 |
 |
|
|
|
|
|