An object or column name is missing or empty

In this article, we will talk about the SQL Server error message “An object or column name is missing or empty” and see how you can easily overcome this error.

 

More about this error message

So, you ran a query and got the error message: An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name.

As the above error message explains, you are trying to run a SELECT INTO statement without specifying a column name.

 

Example – Reproducing the Error Message

Consider the below example:

SELECT 1, 'TEST1'
INTO #tblTest;
GO

If you run the above T-SQL statement, you will get the “An object or column name is missing or empty.” error message.

 

Resolving the Error

If you specify column names in your SELECT INTO statement, then the query will run without the above error:

SELECT 1 AS ColumnName1, 'TEST1' AS ColumnName2
INTO #tblTest;
GO

 

Learn Essential SQL Server Development Tips – Enroll to our Online Course!

Check our online course titled “Essential SQL Server Development Tips for SQL Developers(special limited-time discount included in link).

Sharpen your SQL Server database programming skills via a large set of tips on T-SQL and database development techniques. The course, among other, features over than 30 live demonstrations!

Essential SQL Server Development Tips for SQL Developers - Online Course
(Lifetime Access, Q&A, Certificate of Completion, downloadable resources and more!)

Learn More

 

Our Featured Online Courses

 

Read Also:

 

Rate this article: 1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 5.00 out of 5)

Loading...

Reference: SQLNetHub (https://www.sqlnethub.com)

© SQLNetHub