SQLTeam.com | Weblogs | Forums

Create view looking at two database

Hi There,

I need to create a view where part of the data is on a different database.
Rentals table is on the table where the view will be created and customers is in a different database.
How can I create a view referencing the two databases?
The databases are on the same server.

Thanks for the help.

Best Regards,

Steve.

Use the 3-part naming convention to refer to tables in the other database - databasename.schemaname.tablename. For example, Database1.dbo.Rentals

If the objective of creating the view is to limit the permissions of the user of the view, research cross database ownership chaining rules and security risks that come with it.