Press enter to see results or esc to cancel.

what happened when more than one rule assigned to a column in SQL Server


this is a complex case

suppose we created 2 rules

 

create rule rule11
as @r =100

create rule rule111
as @r =1001

and there is a tbale

create table t11( cind int)

what will happen if we tried to bound these 2 rules to this table

sp_bindrule’rule11′,’t11.cind’
sp_bindrule’rule111′,’t11.cind’

now try

sp_help t11

RowGuidCol
No rowguidcol column defined.

Data_located_on_filegroup
PRIMARY

The object ‘t11′ does not have any indexes, or you do not have permissions.

constraint_type constraint_name delete_action update_action status_enabled status_for_replication constraint_keys
RULE on column cind (bound with sp_bindrule) rule111 (n/a) (n/a) (n/a) (n/a) create rule rule111
as @r =1001

No foreign keys reference table ‘t11′, or you do not have permissions on referencing tables.
No views with schema binding reference table ‘t11′.

Conclusion

When binding more than one rule to a column , earlier binding will be replaced by later binding



Comments

Comments are disabled for this post