Click here to Skip to main content
16,004,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Problem is i have 2 databases in same sql server..i want to access a table data of 1st database in 2nd database table..what's the best way to do this.?
Posted
Comments
shek124 19-Oct-11 7:22am    
improve your question

if DB's are in different sql server than u can use linked server,

add a linked server to your sqlserver,
and access that server by a store procedure using linked server u have added
or access that linked server by a view and join your main data's
 
Share this answer
 
v2
I am not sure if I understand your question correctly, but if you want to (for example) join two tables from different databases on the same SQL server you can use the following syntax:
SQL
SELECT * FROM database1.dbo.table1 CROSS JOIN database2.dbo.table2 ...


the name in front of .dbo. indicates the database...

hope this helps,
cheers
Andy
 
Share this answer
 

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