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
 SQL Server Development (2000)
 compare table data

Author  Topic 

lesoft
Starting Member

1 Post

Posted - 2006-04-05 : 18:42:08
Hi,

I have two tables (mater_table and temp_table) with identical structure but they have different values. How do I write a store procedure to return a result with the following

1) showing new records
2) show updated records

For now, the table has only one varchar column "name".

Thanks in advance for your help!
Tuan

nr
SQLTeam MVY

12543 Posts

Posted - 2006-04-05 : 19:07:10
You can't show updated rows if there is only one column - how do you know it's updated rather than deleted and a new row?

For new rows
select tmp.*
from tmp
left join master
on master.name = tmp.name
and master.name is null



==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-04-05 : 19:19:18
"I have two tables (mater_table and temp_table) with identical structure but they have different values"
What is the relationship between these 2 tables ? What is the temp_table for ?

"1) showing new records"
What do you mean by new records ? Records exist in temp_table but not in master_table ?

2) show updated records
What do you mean by updated records ?

What are you trying to achieve here ?




KH


Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-06 : 04:16:59
Also refer
http://weblogs.sqlteam.com/jeffs/archive/2004/11/10/2737.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -