CREATE FUNCTION failed because a column name is not specified for column %d.

Error Message:
Msg 4514, Level 16, State 1, Procedure myfunction, Line 6
CREATE FUNCTION failed because a column name is not specified for column %d

Severity level:

This error message appears when you try to create a user-defined function in which for at least one column no explicite name was specified or SQL Server wasn’t able to deduct such a column name.

The T-SQL statement can be parsed, but causes the error at runtime.

Errors of the Severity Level 15 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. Each column in a table-valued user-defined function must have a unique name.

All versions of SQL Server.

USE Northwind
IF OBJECT_ID (‘dbo.myfunction’) > 0
 DROP FUNCTION dbo.myfunction;
CREATE FUNCTION dbo.myfunction (@CustomerID nchar(5))
 SELECT *, 1
   FROM Northwind.dbo.Orders
  WHERE CustomerID = @CustomerID
SELECT * FROM dbo.myfunction (‘ALFKI’);

A single SELECT statement such as

 SELECT CustomerID, COUNT(*)
   FROM Northwind.dbo.Orders
  WHERE CustomerID = @CustomerID
  GROUP BY CustomerID

works fine even with the missing column name for the COUNT(*) expression. In this case will SQL Server automatically assign a dummy name. However, this does not work for table-valued functions.

Related Articles :

  • No Related Articles Found

No comments yet... Be the first to leave a reply!

Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |