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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create a view on 2 different databases

Status
Not open for further replies.

hencyt

MIS
Joined
Mar 14, 2003
Messages
122
Location
US
Can someone tell me how to create a view using tables from 2 different databases?

Thanks,
Sunny
 
Just qualify the names of your tables using database.owner.table (you can omit the owner if it is dbo).

Code:
CREATE VIEW myview
AS

SELECT t1.col1, t2.col2
FROM db1..table1 t1
  JOIN db2..table2 t2 ON t1.id = t2.id
GO

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top