Solved

SQL 2005 connectiion link

Posted on 2007-11-16
3
139 Views
Last Modified: 2012-05-05
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
Comment
Question by:romeiovasu
  • 2
3 Comments
 
LVL 25

Expert Comment

by:imitchie
ID: 20303815
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
 

Author Comment

by:romeiovasu
ID: 20304462
i am getting this error The OLE DB provider "MSDASQL" has not been registered.
0
 
LVL 25

Accepted Solution

by:
imitchie earned 500 total points
ID: 20324942
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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now