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!
Our Featured Online Courses
- Boost SQL Server Database Performance with In-Memory OLTP
- Essential SQL Server Administration Tips
- SQL Server Fundamentals – SQL Database for Beginners
- Essential SQL Server Development Tips for SQL Developers
- The Philosophy and Fundamentals of Computer Programming
- .NET Programming for Beginners – Windows Forms with C#
- Introduction to Data Science and SQL Server Machine Learning
- Introduction to Azure SQL Database for Beginners
- SQL Server 2019: What’s New – New and Enhanced Features
- Entity Framework: Getting Started – Complete Beginners Guide
- How to Import and Export Data in SQL Server Databases
- Learn How to Install and Start Using SQL Server in 30 Mins
- A Guide on How to Start and Monetize a Successful Blog
- Error converting data type varchar to float
- Operating System Error 170 (Requested Resource is in use)
- There is no SQL Server Failover Cluster Available to Join
- Installing SQL Server 2016 on Windows Server 2012 R2: Rule KB2919355 failed
- Setup failed to start on the remote machine. Check the Task scheduler event log on the remote machine.
- A connection was successfully established with the server, but then an error occurred during the login process.
- SQL Server 2008 R2 Service Pack Installation Fails – Element not found. (Exception from HRESULT: 0x80070490)
- There is insufficient system memory in resource pool ‘internal’ to run this query.
- Argument data type ntext is invalid for argument …
- Could not load file or assembly ‘Microsoft.SqlServer.Smo, Version=10.0.0.0, …
- … more SQL Server troubleshooting articles
Rate this article:
Reference: SQLNetHub (https://www.sqlnethub.com)
Artemakis Artemiou is a Senior SQL Server Architect, Author, a 9 Times Microsoft Data Platform MVP (2009-2018) and a Udemy Instructor. He has over 15 years of experience in the IT industry in various roles. Artemakis is the founder of SQLNetHub and TechHowTos.com. Artemakis is the creator of the well-known software tools Snippets Generator and DBA Security Advisor. Also, he is the author of many eBooks on SQL Server. Artemakis currently serves as the President of the Cyprus .NET User Group (CDNUG) and the International .NET Association Country Leader for Cyprus (INETA). Moreover, Artemakis teaches on Udemy, you can check his courses here.