Error: No column name was specified for column [n] of 'a'
When validating SQL with a computed column in a Query Layer in SQL Server, the following error may occur.
Underlying DBMS error: ~ No column name was specified for column [n] of 'a'.
A column alias is not specified for a computed column.
When a query layer is initially created, the user defined query is utilized as a sub-query to select the geometry column.
SELECT objectid, shape.STConvexHull() as shape2 FROM sde.mySpatialTable
A database trace returns:
exec sp_prepare @p1 ...,N'select shape2 from (SELECT objectid, shape.STConvexHull() as shape2
FROM sde.mySpatialTable) a',1
If an alias is not provided for the STConvexHull() computed column in the Query Layer dialog, such as in the case below:
SELECT objectid, shape.STConvexHull() FROM sde.mySpatialTable
an error occurs.
Underlying DBMS error [[Microsoft][SQL Server Native Client 10.0][SQL Server}
No column name was specified for column 2 of 'a'.]
Solution or Workaround
Ensure computed columns receive a column alias. See the example below.
SELECT shape.STConvexHull() AS MyConvexHull FROM MySpatialTable;
Last Published: 5/5/2016
Article ID: 000012401