为用户定义的数据类型创建规则时,如何检查规则是否已存在?
-- does rule exist?
CREATE RULE MyRule
AS @MyVar IN ('foo1', 'foo2')
答案 0 :(得分:1)
if not exists(Select 1 from sys.all_objects where type='r')
begin
create rule syntax
end
您也可以使用sys.objects
if not exists(Select 1 from sys.objects where type='r')
begin
create rule syntax
end