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)
 Update a table

Author  Topic 

copeleto
Starting Member

5 Posts

Posted - 2005-08-17 : 10:56:46
Hi guys

Well 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 me

Carlos

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 FirstTable
insert into FirstTable(columns...)
select columns... from SecondTable
Where DateCreated > getdate()-14 -- this insert data from previous 14 days

Go with the flow & have fun! Else fight the flow
Go to Top of Page

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!!
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-08-17 : 11:14:35
I think you want to look at this

http://weblogs.sqlteam.com/brettk/archive/2004/04/23/1281.aspx



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

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
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-08-17 : 11:38:11
quote:
Originally posted by spirit1
then how do you define new data???



The second table is.....Old data + new data

Did you look at the link?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

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
Go to Top of Page

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)?
Go to Top of Page
   

- Advertisement -