Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a database 'abc' and i am trying to write procedure which requires to interact with table in database 'xyz'. What can i do.

What I have tried:

I have a database 'abc' and i am trying to write procedure which requires to interact with table in database 'xyz'. What can i do.
Posted
Updated 12-Mar-17 9:23am

See the answer to this post sql server - How do I query tables located in different database?[^]
Basically you just need to use the fully qualified table name. If the databases are on different servers then you will need to link them first - Linked Servers (Database Engine)[^]
 
Share this answer
 
you must use the 3 part name for tables means database1=abc,database2=xyz then [abc].[dbo].[table1] and [xyz].[dbo].[table2]
 
Share this answer
 
Comments
CHill60 13-Mar-17 5:31am    
Adds no additional information to Solution 1 posted 2 days ago.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900