Quantcast
Channel: SQL Errors – SQLSERVERLEARNER
Viewing all articles
Browse latest Browse all 74

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

$
0
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


Viewing all articles
Browse latest Browse all 74

Trending Articles