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 |
|
eem_2055
Yak Posting Veteran
69 Posts |
Posted - 2009-02-02 : 06:54:06
|
| Hi guys, I need your help:I have two tables A and B. Database A updates table 1 and table 2. but my prob is I want to update at the same time database B with the same table.what query can I use to update the other table wherein I just want to update table with the ' ' value. |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2009-02-02 : 07:50:26
|
Your question is not clear!I'm assuming that the databases are on the same sever??In that case you can use 3 part notation for the tables (database.schema.table). Like this.UPDATE a SET [foo] = x.[bar]FROM database1.dbo.table1 a JOIN database2.dbo.table2 x ON x.[whatever] = a.[whatever] If database B should always be a copy of A then you probably want to use replication. I don't know much about that.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-02 : 08:30:41
|
quote: Originally posted by eem_2055 Hi guys, I need your help:I have two tables A and B. Database A updates table 1 and table 2. but my prob is I want to update at the same time database B with the same table.what query can I use to update the other table wherein I just want to update table with the ' ' value.
sounds like what you need is transactional replicationm. Anyways, would like to have detailed explanation on what you want before suggesting further. |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-02 : 09:30:01
|
quote: Originally posted by visakh16
quote: Originally posted by eem_2055 Hi guys, I need your help:I have two tables A and B. Database A updates table 1 and table 2. but my prob is I want to update at the same time database B with the same table.what query can I use to update the other table wherein I just want to update table with the ' ' value.
sounds like what you need is transactional replicationm. Anyways, would like to have detailed explanation on what you want before suggesting further.
Although Transactional replication can be implemented here,It is not good idea to use in same instances. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-02 : 09:52:33
|
| would you mind giving some scenarios where its not intended? |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-02 : 10:29:27
|
| I mean in same instance between 2 databases. Why there is need of Replication here? |
 |
|
|
eem_2055
Yak Posting Veteran
69 Posts |
Posted - 2009-02-03 : 01:53:29
|
| Database Amaster table --> field1 and field2master2 table --> field1 and field2Database 2master table --> field1 and field2master2 table --> field1 and field2The only database that has been updated is Database1. On the other hand, master and master2 table of database 2 has a different fields. What I want to do is to update all null values of field1a and field 2 of master and master2 table of Database2.I want to write a query where I can schedule it on my SQL agent.Thanks |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-03 : 09:09:09
|
| you want to update both from corresponding values of database1? how frequently should it happen? |
 |
|
|
|
|
|