question

sunithalee143 avatar image
sunithalee143 asked

updation of tables in 2 databases at a time

hi every one , i am having 2 databases in windows 2003 server using SQl 2005 i want to update a table which was same in both databases a column needed to be updated . can i open the databases staying in the masters Query window only if i open this two databases at a time and update the column in both databe tables then that will be great. can any one have the command to do this please provide me the solution for this. Thanks in advance....
sql-server-2005
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sp_lock avatar image
sp_lock answered
Is this what you are seeking? UPDATE db1.dbo.TableA SET colA = 'Me' WHERE id = 1 UPDATE db2.dbo.TableA SET colA = 'Me' WHERE id = 1
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sunithalee143 avatar image sunithalee143 commented ·
Excellent solution Jonlee you have saved me in the right time when i was exactly lacking this command and it worked thanks a lot for giving this command.
0 Likes 0 ·
aRookieBIdev avatar image
aRookieBIdev answered
Hi , You need to provide the fully qualified name . DatabaseName.TableName example: select * from AdventureWorks.dbo.DatabaseLog
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image
Grant Fritchey answered
Also, as has already been pointed out, there is no way to do these "at the same time." You will have to fully qualify the table name and run the updates in sequence, but to get them to be at the same time, you need to wrap them in a transaction and then commit that transaction. Otherwise it will be one, then the other.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.