Column name '%.*ls' does not exist in the target table or view.

Error Message:
Msg 1911, Level 16, State 1, Line 2
Column name ‘%.*ls’ does not exist in the target table or view.

Severity level:
16.

Description:
This error message appears when you try to create an index on a table or view, but the specified column name does not exist in these objects.

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

Resolution:
Error of the Severity Level 16 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. The column on which the index should be created must exist in the table or view.

Versions:
All versions of SQL Server

Example(s):
USE Northwind;
GO

SET NUMERIC_ROUNDABORT OFF;
SET ANSI_PADDING,
    ANSI_WARNINGS,
    CONCAT_NULL_YIELDS_NULL,
    ARITHABORT,
    QUOTED_IDENTIFIER,
    ANSI_NULLS ON;
GO

IF OBJECT_ID (‘dbo.MyOrderView’, ‘View’) > 0
   DROP VIEW dbo.MyOrderView;
GO
CREATE VIEW dbo.MyOrderView
WITH SCHEMABINDING
AS
SELECT SUM(o.UnitPrice*od.Quantity*(1.00-o.Discount)) AS Revenue,
    COUNT_BIG(*) AS MyCount
  FROM dbo.[Order Details] AS od
  JOIN dbo.[Order Details] AS o
    ON od.OrderID = o.OrderID
 GROUP BY od.OrderID;
GO

CREATE UNIQUE CLUSTERED INDEX cix_MyOrderView
    ON dbo.MyOrderView (OrderDate, ProductID);
GO

Remarks:
In the above example we try to create an index on the view MyOrderView. Because the column OrderDate does not exist in this view, the error is raised.

]]>

Leave a comment

Your email address will not be published.