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 |
|
copeleto
Starting Member
5 Posts |
Posted - 2005-08-17 : 10:56:46
|
| Hi guysWell I have two tables with the same format but one of the tables is is an update (in terms of data) of the other one (I mean the second table contains the first table + new data), I need to copy only the new information into the first table in order to avoid duplication.I create a sp with a cursor but it is not very efficient because the number of row is around 25.000.000 in one tabla and 30.000.000 in the second one.Thanks in advance if you can help meCarlos |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-08-17 : 11:00:42
|
well you need a column that tells you which data is new...if it's a date then:truncate table FirstTableinsert into FirstTable(columns...)select columns... from SecondTableWhere DateCreated > getdate()-14 -- this insert data from previous 14 daysGo with the flow & have fun! Else fight the flow |
 |
|
|
copeleto
Starting Member
5 Posts |
Posted - 2005-08-17 : 11:05:56
|
| Hi,I can not classify the data by the date...new data could be created before!! |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-08-17 : 11:29:14
|
i said IF...then how do you define new data??? just use those columns that define new data in the where part and use proper conditions.Go with the flow & have fun! Else fight the flow |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-08-17 : 11:38:11
|
quote: Originally posted by spirit1then how do you define new data???
The second table is.....Old data + new dataDid you look at the link?Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-08-17 : 11:49:53
|
LOL brett Go with the flow & have fun! Else fight the flow |
 |
|
|
mmarovic
Aged Yak Warrior
518 Posts |
Posted - 2005-08-18 : 06:22:42
|
| Do you have identity column on source table (old data + new datat table)? |
 |
|
|
|
|
|