'Can't select column name from Eloquence database that has a forward slash in it (from a linked server in SQL Server)
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 SQL Server Management Studio (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?
The SQL/R documentation: SQL/R A.03 Documentation
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|