Search code examples
sqlsql-serversql-server-2008sql-server-2005linked-server

column names with periods on a 2008 linked server


I'm using SQL Server 2005 and trying to select columns from a SQL Server 2008 linked server that have periods in them.

I've checked this post:

Selecting a column with period in the column name SQL Server

But I'm not getting the same error.

This is the code

    INSERT INTO [Linked_Server].Database.dbo.Table
           ([Column_Name], [Column.Name])
    SELECT 
           [Column_Name], [Column.Name] FROM local_table

I can select from the table locally, but when I try to select the same columns from the same table on the linked server, I get this error:

    Msg 207, Level 16, State 1, Line 3
    Invalid column name 'Column.Name'.

EDIT: Fixed a typo with "[Column_Name)". This was a typo only in stackoverflow however. The typo is not the problem


Solution

  • Looks like this is a known issue with Linked Servers in SQL Server 2008. I had seen this page while I was researching, but I didn't see the workaround section at the bottom.

    I ended up changing the query to use OPENQUERY instead, and now it works.

    http://support.microsoft.com/kb/972856