How do i access different databases
-
Hey How can i run a query which can be an insert/update query from one database referring another database. For example i need to insert a row in my database1.table1 from database2 thanks Cheers, Venkatraman Kalyanam Bangalore - India "Being Excellent is not a skill, it is an attitude" Reality is an illusion caused by caffeine deficiency(one Microsoft Research scholor)
-
Hey How can i run a query which can be an insert/update query from one database referring another database. For example i need to insert a row in my database1.table1 from database2 thanks Cheers, Venkatraman Kalyanam Bangalore - India "Being Excellent is not a skill, it is an attitude" Reality is an illusion caused by caffeine deficiency(one Microsoft Research scholor)
Is this
- Two SQL Server databases on the same server instance
- Two SQL Server databases on two different server instances
- Not SQL Server at all?
If the first or second: You can reference any object in SQL Server (table, view, function) by a full name:
_server_._database_._owner_._object_
. The first three can be omitted when referencing an object in the same database as you're currently accessing; owner is typically only used to disambiguate where two users have an object with the same name, although functions require the owner part. The simplest syntax for referring to an object in another database on the same server - say you wanted to access the titles table in the pubs database ispubs..titles
(note the two dots, signifying that the owner oftitles
has been omitted). If you want to refer to an object on another server, you need to set up a linked server, which you can do in Enterprise Manager, under Security > Linked Servers. I believe Access has the concept of foreign tables.