Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update table in diff db

Status
Not open for further replies.

rewdee

Programmer
Aug 17, 2001
295
0
0
US
I have to write an update trigger that updates records in another table in another database (same SQL Server though). Do I create another connection (if so, how? Or do I write something like :
Code:
USE PUBS
Update Customer blah blah
Any help would be appreciated.

Thanks,
Rewdee
 
To update a table on a different database on the same server

use the following

update database_name.user.table
set field = value
where ...

i.e.

update database1.dbo.table1
set field1 = "TEST"
where field2 = "TEST"

Same applies for select statements etc.

Hope this helps

 
Code:
UPDATE DBNAME.TABLENAME
SET FIELD1 = (SELECT FIELD1 FROM DB2NAME.TABLENAME
WHERE DBNAME.TABLENAME.IDFIELD = DB2NAME.TABLENAME.IDFIELD)


[bandito] [blue]DBomrrsm[/blue] [bandito]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top