Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
How to Alter the Existing Rule on a Column in SQL Server


Create rule [dbo].[AccountStatus] as @AccountStatus in ('A','C','N','T','I','D','F','M')


I want to Bind more Statuses

What I have tried:

ALTER rule [dbo].[AccountStatus] as @AccountStatus in ('A','C','N','T','I','D','F','M',
'X','R','Y')
Posted
Updated 28-Sep-16 21:35pm
v4
Comments
Suvendu Shekhar Giri 29-Sep-16 3:24am    
How about DROP and CREATE ?

I got the Solution, here it is

4 steps need to be followed.

1)Drop the existing rule
2)Unbind the existing Rule
3)Create the New Rule
4)Bind the New Rule

SQL
DROP RULE [AccountStatus] as @AccountStatus

EXEC sp_unbindrule 'BsmasterAcnt.AccountStatus'

EXEC sp_bindrule  'AccountStatus','Bsmasteracnt.AccountStatus'
 
Share this answer
 
v2
You drop the rule and create the corrected one: DROP RULE (Transact-SQL)[^]

But more importantly you should not use RULE statement. This is an old syntax which will be removed in the near future. Instead of rules. use constraints: Unique Constraints and Check Constraints[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900