Msg 492 Level 16 State 1 Line 3 Duplicate column names are not allowed in result sets obtained through OPENQUERY and OPENROWSET. The column name “A” is a duplicate. – SQLSERVERLEARNER https://sqlserverlearner.com LEARN SQL SERVER ONLINE Mon, 14 May 2012 05:32:31 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 Duplicate column names are not allowed in result sets obtained through OPENQUERY and OPENROWSET. The column name “A” is a duplicate. https://sqlserverlearner.com/2012/05/14/duplicate-column-names-are-not-allowed-in-result-sets-obtained-through-openquery-and-openrowset-the-column-name-a-is-a-duplicate/ https://sqlserverlearner.com/2012/05/14/duplicate-column-names-are-not-allowed-in-result-sets-obtained-through-openquery-and-openrowset-the-column-name-a-is-a-duplicate/#respond Mon, 14 May 2012 05:32:31 +0000 https://sqlserverlearner.azurewebsites.net/2012/05/14/duplicate-column-names-are-not-allowed-in-result-sets-obtained-through-openquery-and-openrowset-the-column-name-a-is-a-duplicate/ Error:

Msg 492, Level 16, State 1, Line 3
Duplicate column names are not allowed in result sets obtained through OPENQUERY and OPENROWSET. The column name “A” is a duplicate.

Possible Reason:
Column names being duplicate in the result set returned by OPENQUERY (or) OPENROWSET.

Example:
[sql]
SELECT 1 AS A,2 AS A
[/sql]
Executes Successfully!!!

When the same query is used in the OPENROWSET.
[sql]
SELECT * FROM OPENROWSET(‘SQLOLEDB’,
‘Server=(local);Trusted_Connection=Yes;Database=Master’,
‘SELECT 1 AS A,2 AS A’)
[/sql]

Errors Out with Msg 492, Level 16, State 1, Line 3.

Fix/Resolution:
Make sure that each and every column in the result set returned by OPENQUERY (or) OPENROWSET has a different name.
[sql]
SELECT * FROM OPENROWSET(‘SQLOLEDB’,
‘Server=(local);Trusted_Connection=Yes;Database=Master’,
‘SELECT 1 AS A,2 AS B’)
[/sql]

appropriate to SQL Server 2005,SQL Server 2008,SQL Server 2008 r2,SQL Server 2012

]]>
https://sqlserverlearner.com/2012/05/14/duplicate-column-names-are-not-allowed-in-result-sets-obtained-through-openquery-and-openrowset-the-column-name-a-is-a-duplicate/feed/ 0