Friday, February 17, 2012

Create view with tables from 2 different servers

Is it possible to create a view on one SQL server and add a table to the
view from another SQL server?
Tim"Tim Kelley" <tkelley@.company.com> wrote in news:e8Zfl0atGHA.4968
@.TK2MSFTNGP03.phx.gbl:

> Is it possible to create a view on one SQL server and add a table to the
> view from another SQL server?
I cannot remember anything stating that it does not work, but I guess
you'll have to use sp_addlinkedserver first.
Ole Kristian Bangs
MCT, MCDBA, MCDST, MCSE:Security, MCSE:Messaging, MCTS, MCITP|||You need to add the remote server as a linked server, using sp_addlinkedserv
er.
Then you can use the four part naming convention.
SELECT
l.Column1
, l.Column2
, r.Column1
, r.Column2
FROM LocalTable l
JOIN RemoteServer.DatabaseName.Schema.RemoteTable r
ON l.PKColumn = r.FKColumn
WHERE {criteria}
--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"Ole Kristian Bangs" <olekristian.bangas@.masterminds.no> wrote in message news:Xns9812F31EE
656Folekristianbangaas@.207.46.248.16...
> "Tim Kelley" <tkelley@.company.com> wrote in news:e8Zfl0atGHA.4968
> @.TK2MSFTNGP03.phx.gbl:
>
>
> I cannot remember anything stating that it does not work, but I guess
> you'll have to use sp_addlinkedserver first.
>
> --
> Ole Kristian Bangs
> MCT, MCDBA, MCDST, MCSE:Security, MCSE:Messaging, MCTS, MCITP

No comments:

Post a Comment