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 |
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2008-04-07 : 19:34:12
|
i have a table temp t that is used as a back up of live table . the table has following fileds( customer,customercardnumber,transactiondate)i need to insert these fields into another table t1 in such a way that no duplicate records are inserted .ie after once a table t1 is populated the next time insert statement should insert only the new records that were added to the temp table t but not all records.i think using max (transactiondate) of both tables can be considered for this . but don know put in codethanks .please suggest with the code. |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-04-07 : 20:09:33
|
Do you have to insert one-time or regularly? |
 |
|
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2008-04-07 : 21:42:44
|
regularly whenever new transaction is done by new customer o r the same customer.thanks |
 |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-04-07 : 22:07:07
|
1)create t1 table with same structure and with constraints added.2)-- Export distinct datainsert into t1( customer,customercardnumber,transactiondate) select distinct customer,customercardnumber,transactiondatefrom #t3) Create Trigger as:Create trigger [TR] on #tafter insertasbegin insert into t1(customer,customercardnumber,transactiondate) select distinct customer,customercardnumber,transactiondate from insertedend |
 |
|
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2008-04-07 : 23:12:21
|
thanks |
 |
|
|
|
|