views:

35

answers:

3

Hi there !

I'm trying to query a database view that's not located on the same server as the stored procedure I'm running.

I heard about using "linked servers", but I have no access to the server's configuration at all ...

Thanks in advance !

A: 

tried <servername>.<databasename>.<schema>.<viewname>

e.g. servera.MyDatabase.dbo.vwCustomView ?

EDIT: Sorry I slightly misread the question. I've only ever done cross database queries on the same server, so not sure if this works.

mrnye
A: 

You can do this, but it does require the DBA to set up the link. If you don't have access to the server's configuration and the DBA is not on board, you're out of luck.

Dave Markle
+1  A: 

Use OPENDATASOURCE:

SELECT   *
FROM      OPENDATASOURCE(
         'SQLOLEDB',
         'Data Source=ServerName;User ID=MyUID;Password=MyPass'
         ).Northwind.dbo.Categories
tekBlues
This requires enabling `ad hoc distributed queries` which are disabled by default.
Quassnoi
Thanks ! This is just what I needed.
Alvaro V.