• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 147
  • Last Modified:

SQL 2005 connectiion link

i am using sql server 2005. i have another database which is on the other network. and i have odbc connection settings if i want to link to that database in my sql how can i link that database and start writing queries.
0
romeiovasu
Asked:
romeiovasu
  • 2
1 Solution
 
imitchieCommented:
this can get you started: (let's say the servers are svr1 and svr2)
on svr1
sp_addlinkedserver 'svr2'
then to run a query
    select top 10 * from svr2.database.dbo.tablename
you can even join to local tables, like
    select top 10 * from svr2.database.dbo.tablename inner join dbo.localtable on ...

check books online for sp_addlinkedserver. the example above will use the current login (to svr1) to authenticate with svr2. so if you're on a domain and using windows authentication, shouldn't be a problem
0
 
romeiovasuAuthor Commented:
i am getting this error The OLE DB provider "MSDASQL" has not been registered.
0
 
imitchieCommented:
http://msdn2.microsoft.com/en-us/library/aa259589(SQL.80).aspx

does the other server have an instance name? the following adds it to be referred locally as myserver, but is actually connecting to server\instance1

EXEC sp_addlinkedserver  
   @server='myserver',
   @srvproduct='',
   @provider='SQLNCLI',
   @datasrc='server\instance1'

usage:
 select top 10 * from myserver.database.dbo.table
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now