I have a query on a database table like this select * from dbo.MyTable
which works fine even though for reason I don't know the table MyTable
has been created with trailing spaces in the identifier.
That should not let me worry as described here since SQL Server just ignores trailing spaces. Unfortunately, I have a case where I need to select the data from that table using a linked server like this:
select *
from linkedserver.targetdb.dbo.[MyTable ]
I need to use the quotename including the spaces otherwise I get the error:
An invalid schema or catalog was specified for the provider "SQLNCLI11" for linked server "linkedserver"
Unfortunately the queries are generated dynamically and don't account for the trailing space as a comparison of the object name with the information_schema
table works (correctly ignoring the trailing spaces).
Could this be related to the provider SQLNCLI11 or a configuration of the linked server?