[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 348
  • Last Modified:

Linked Server Query - Trying to set up an OPENQUERY with a server that is addressed by IP

I have set up a linked server within enterprise manager. When I try to run the statement below in SQL Query Analyzer I recieve an error:
select * from OPENQUERY(66.240.29.197,'select * from XMCTStatus.dbo.tblTZ')
Error: Line 1: Incorrect syntax near '64.240'.

Can I run this against a server defined with an IP?
0
infutech
Asked:
infutech
  • 3
  • 2
1 Solution
 
ShogunWadeCommented:
what is the name of your linked server?


select * from OPENQUERY(MyLinkedServerName,'select * from XMCTStatus.dbo.tblTZ')
0
 
infutechAuthor Commented:
The name is 66.240.29.197.  
0
 
ShogunWadeCommented:
try this:

select * from OPENQUERY([66.240.29.197],'select * from XMCTStatus.dbo.tblTZ')
0
 
infutechAuthor Commented:
Worked like a charm! Thanks.
0
 
ShogunWadeCommented:
your welcome.

Basically the issue was that the linked server name in the openquery statement is defined as a sysname datatype.  sysname types containing white space or punctuation must be enclosed in  [ ]
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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