Eugene Goldberg
Eugene Goldberg

Reputation: 15544

Can a Sql Server View reference a table in a different database?

I have a third party Sql Server data, which I need to use as a data source for my custom database, without duplicating data. One thing, which comes to mind is to create a View in my custom database, which would reference one or more tables from this third party database. Is this possible with Sql Server 2014?

Upvotes: 0

Views: 3265

Answers (2)

Rahul
Rahul

Reputation: 77876

Yes very much it is possible but you need to fully qualify the table name like

create view testview
as
select * from db_name.schema_name.table_name

Upvotes: 1

Bruce Dunwiddie
Bruce Dunwiddie

Reputation: 2908

Yes, as long as they're on the same server, TSQL: Create a view that accesses multiple databases . If they're on different servers, then you'd have to create a linked server, which I wouldn't suggest unless you're aware of the pitfalls.

Upvotes: 2

Related Questions