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 |
|
rudba
Constraint Violating Yak Guru
415 Posts |
Posted - 2009-02-05 : 12:16:22
|
| i have two database db1 and db2both databases has same table structurs.Now i have to update db2's table with comparing db1.tbl1 has following fileds.id,fname,lname,email,statusnow i have to update db2's tbl1 (both db has tbl1)if db1's tbl1>> email is same as db2's tbl1>> emailthan i have to update db2>>tbl1>>status=1 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-02-05 : 12:21:24
|
| try thisupdate yset y.status = case when x.email = y.email then 1 else 0 end from db1.tbl1 xinner join db2.tbl1 y on y.id = x.id |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-05 : 12:21:43
|
| [code]update t2set t2.status=1from db1.dbo.tbl1 t1join db2.dbo.tbl2 t2on t2.email=t1.emailand t2.id=t1.id[/code] |
 |
|
|
rudba
Constraint Violating Yak Guru
415 Posts |
Posted - 2009-02-05 : 13:17:24
|
| thanks guys |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-06 : 09:15:51
|
| welcome |
 |
|
|
|
|
|