Duplicate column names are not allowed in result sets obtained through OPENQUERY and OPENROWSET. The column name “A” is a duplicate.

Posted on : 14-05-2012 | By : Devi Prasad | In : SQL Errors, SQL Server Basics

Share:

0


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:

SELECT 1 AS A,2 AS A

Executes Successfully!!!

When the same query is used in the OPENROWSET.

SELECT * FROM OPENROWSET('SQLOLEDB',
                         'Server=(local);Trusted_Connection=Yes;Database=Master',
                         'SELECT 1 AS A,2 AS A')

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.

SELECT * FROM OPENROWSET('SQLOLEDB',
                         'Server=(local);Trusted_Connection=Yes;Database=Master',
                         'SELECT 1 AS A,2 AS B')

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

(Visited 1,404 times, 1 visits today)



References : Devi Prasad (sqlserverlearner.com)

Need Help On SQL Server?

Cannot Find Solution to your problem (or) If you are looking for some help on SQL Server. Dont worry Click Here to Post your question and solve your issue.


Do you like my blog?

If you liked reading this blog, please help spread the word by sharing this blog with your friends.




Write a comment



Tags: