How to fetch data using OPENDATASOURCE and Linked Server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ankitmathur
    New Member
    • May 2007
    • 36

    How to fetch data using OPENDATASOURCE and Linked Server

    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(Identifie r)
    FROM OPENDATASOURCE
    (
    'SQLOLEDB','Dat a Source=1.1.1.1; User ID=vUser;Passwo rd=getdata;'
    )[1.1.1.2].RadiusDB.dbo.S essions WHERE IDentifier='ank it' 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
Working...