By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,364 Members | 1,268 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,364 IT Pros & Developers. It's quick & easy.

How to fetch data using OPENDATASOURCE and Linked Server

P: 36
Hi I'm using the following query to connect to my MSSQL 2000 DB1 and further use a linked server to connect and fetch data from DB2 there to get the data finally into DB3.

Example IPs
DB1: 1.1.1.1
DB2: 1.1.1.2
DB3: 1.1.1.3

My Query
SELECT Identifier, Count(Identifier)
FROM OPENDATASOURCE
(
'SQLOLEDB','Data Source=1.1.1.1;User ID=vUser;Password=getdata;'
)[1.1.1.2].RadiusDB.dbo.Sessions WHERE IDentifier='ankit' GROUP BY IDentifier


But am facing some syntax issues with this query.

Server: Msg 170, Level 15, State 1, Line 5
Line 5: Incorrect syntax near '1.1.1.2'.



Can somebody help me correct my query.

Note: I can't connect my linked server (DB2) directly from my third DB i.e. DB3 and have to go via DB1.


Thanks
Ankit
Jun 10 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.