Results 1 to 3 of 3

Thread: Linked Server Query

  1. #1
    Join Date
    Nov 2006
    Posts
    1

    Linked Server Query

    I'm using MS SQL Server Express and I've added a linked server. (I created the linked server by right mouse clicking on Server Objects, selecting SQL and entering the SQL2 as the name.) Now I'm trying to query a linked table. The following query works.

    SELECT * FROM SQL2.PA.dbo.Counties

    This one doesn't:

    Select * from OPENQUERY(SQL2,"SELECT * FROM SQL2.PA.dbo.Counties")

    Msg 102, Level 15, State 1, Line 1
    Incorrect syntax near 'SELECT * FROM SQL2.PA.dbo.Counties'.

    Can you tell me why?

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Try this

    Select * from OPENQUERY(SQL2,"SELECT * FROM PA.dbo.Counties")

  3. #3
    Join Date
    Sep 2002
    Posts
    5,938
    That's right, don't need four-part fully qualified name in openquery.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •