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 |
|
Utpal
Posting Yak Master
179 Posts |
Posted - 2002-04-06 : 01:16:56
|
| Hi everybody, Is it possible to access a table in another database in a database trigger? Something like a statement in an Update trigger of Purchase_Orders table in InvMEDI2001 database :SELECT @LastDate = LastDate FROM InvCommon.Company WHERE Year(FirstDate) = 2001where InvCommon is the name of another database and Company is a table in it ? |
|
|
smccreadie
Aged Yak Warrior
505 Posts |
Posted - 2002-04-06 : 07:16:19
|
| According to BOL, You can create a trigger only in the current database, although a trigger can reference objects outside of the current database.I'd recommend caution because if the reference database is down, the trigger will fail. |
 |
|
|
Utpal
Posting Yak Master
179 Posts |
Posted - 2002-04-07 : 00:09:49
|
| Thanks ! How is a table in an outside database to be referenced ? The table name I want to reference is "Company" and the name of the outside database is "InvCommon". |
 |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-04-07 : 01:00:13
|
| by using four part naming convention.servername.databasename.owner.tablenameif the server is same . you can reference your table by using invCommon.dbo.company HTH-------------------------------------------------------------- |
 |
|
|
Utpal
Posting Yak Master
179 Posts |
Posted - 2002-04-08 : 02:09:39
|
| Thanks a lot Nazim ! |
 |
|
|
|
|
|