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 |
Ilyas
Starting Member
1 Post |
Posted - 2007-06-01 : 03:14:38
|
I was hoping someone could assist me. I would like to know how to structure a SQL query in an attempt to compare data across two databases?For example:I'd like to know when salary in one database is changed in another and if it has, then list the new salary so I was thinking of something like this:select DB1.name, DB1.salaryFrom DB1.EmployeeTable, DB2.EmployeeTablewhere DB1.salary <> DB2.salaryAny feedback would be great. |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-06-01 : 03:21:06
|
[code]Select t1.Name, t1.Salary, t2.Name, t2.salaryFrom DB1..EmployeeTable t1 Join DB2..EmployeeTable t2on t1.Pk = t2.pk and t1.salary <> t2.salary[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-01 : 08:47:55
|
If the user is not dbo, then specify the user alsoDB1.username.EmployeeTableMadhivananFailing to plan is Planning to fail |
|
|
|
|
|