Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create view in my database server from another database server

Is it possible to create view in my database server of another servers database table?

Let's say you have a database called Testing on server1 and you have another database Testing2 on server2. Is it possible to create view of Testing2's table Table2 in server1's database Testing?

Also, I am using SQL Server 2008.

Please let me know if you have any questions.

Thanks,

like image 269
Huzaifa Avatar asked Feb 17 '23 01:02

Huzaifa


1 Answers

Yes, you can. First, you need to link to the other server, using something like sp_addlinkedserver.

Then you can access the data using 4-part naming. Here is an example:

create view v_server1_master_tables as
    select *
    from server1.master.information_schema.tables;
like image 168
Gordon Linoff Avatar answered Mar 10 '23 11:03

Gordon Linoff