Syntax '%ls' is not allowed in schema-bound objects.

Error Message:
Msg 1054, Level 15, State 8, Procedure MyOrderView, Line 9
Syntax ‘%ls’ is not allowed in schema-bound objects.

Severity level:
15.

Description:
This error message appears when you try to use invalid syntax for schema-bound objects.

Consequences:
The SQL statement cannot be parsed and further execution is stopped.

Resolution:
Error 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. You must use valid syntax for schema-bound objects. The offending parts in the statement must be rewritten or removed.

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(UnitPrice*Quantity*(1.00-Discount)) AS Revenue,
    OrderDate, ProductID, COUNT_BIG(*) AS MyCount
  FROM dbo.[Order Details] AS od
  JOIN dbo.Orders AS o
    ON od.OrderID = o.OrderID
 GROUP BY ALL;
GO

Remarks:
In the above example we try to create a schema-bound view. The view definition contains the GROUP BY ALL clause. This is not permitted in schema-bound objects an raises the error.

]]>

Leave a comment

Your email address will not be published.