Cannot bind a rule to a computed column or to a column of data type text, ntext, image, timestamp, varchar(max), nvarchar(max), varbinary(max), xml or sqlclr type.

Error Message:
Msg 15107, Level 16, State 1, Procedure sp_bindrule, Line 143
Cannot bind a rule to a computed column or to a column of data type text, ntext, image, timestamp, varchar(max), nvarchar(max), varbinary(max), xml or sqlclr type.

Severity level:
16.

Description:
This error message appears, when you try bind a rule to one of the in the message mentioned data types.

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 can not be executed this way. You can not bind a rule to a BLOB data type.

Versions:
All versions of SQL Server

Example(s):
USE tempDB
IF OBJECT_ID(‘t’) > 0
 DROP TABLE t
 
CREATE TABLE t
(
 id int NOT NULL PRIMARY KEY,
 c1 text
)

INSERT INTO t(id, c1) VALUES (1, ‘This is a long text’)
GO
DROP RULE myRule
GO
CREATE RULE myRule
AS @value LIKE ‘__-%[0-9]’
GO
EXEC sp_bindrule ‘myRule’, ‘t.c1

Remarks:
CREATE RULE and sp_bindrule are deprecated constructs and will be removed in a future SQL Server version. Use CHECK constraints instead.

]]>

Leave a comment

Your email address will not be published.