问题描述:

My SQL Server instance has a linked server to an eloquence database. I need to select data from one of the tables in the eloquence database, but I need to do it with SQL syntax, since I'm running the code FROM SSMS.

One of the columns has a forward slash in its name (I didn't create it, nor do I have the authority to change it), which throws the following syntax error when I run my query:

OLE DB provider [ProviderName] for linked server [LinkedServerName] returned message "Prepare: Syntax error or access violation {Syntax error in item list (select).}".

OLE DB provider [ProviderName] for linked server [LinkedServerName] returned message "Prepare: Syntax error or access violation {Expression syntax error in aggregate function.}".

Msg 7321, Level 16, State 2, Line 1

An error occurred while preparing the query "SELECT [TableName.ColumnName/WithForwardSlash] FROM [TableName]" for execution against OLE DB provider [ProviderName] for linked server [LinkedServerName].

I have tried:

  • Select * from.... throws the same error
  • Aliasing the column...throws the same error
  • Selecting the tablename.column name...throws the same error
  • Enclosing column name in brackets...throws the same error
  • Escaping the forward slash...throws 'Column not found' error

Note: I lack permissions to access the server directly, so I must query it via the linked server from SQL Server.

How can I select this column from SSMS via the linked server if it has a forward slash in it? How can I get around this error?

Help! Please and thank you.

SQL/R documentation here: http://www.marxmeier.com/sqlr/docs.html

相关阅读:
Top