Skip to content
Advertisement

SQL Server query erroring with ‘An object or column name is missing or empty’

I have the following query in a stored procedure in SQL server:

When the query is run I get the following error:

An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.

Can anyone tell me why? #PWCM does not appear anywhere until this query.

Advertisement

Answer

When you SELECT INTO a table, it creates the table (in this case, a temp table). In order to create a table, each column needs a name, which your count column does not. You just need to give it a name:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement