質問

次のクエリを実行すると、クライアントのデータベースのすべての制約になります。ただし、結果セット内の複数の行は親を持つことはありません。

SELECT name, type_desc, OBJECT_NAME(parent_object_id), parent_object_id
FROM sys.objects
WHERE is_ms_shipped = 0
AND type_desc LIKE '%_CONSTRAINT'
.

これはデータベースに孤児の制約があることを意味しますか?もしそうなら、これらを取り除くのですか?

彼らの名前から、それらが構造の変化があった前から残りのものであることがわかります。

役に立ちましたか?

解決

Using sp_helptext I can see they were created using a CREATE DEFAULT statement, e.g.:

CREATE DEFAULT dbo.MyDefault AS 2

This means they are simply unbound defaults, which can be bound using the sp_binddefault according to MSDN, and removed with a simple DROP DEFAULT statement:

DROP DEFAULT dbo.MyDefault

I wasn't aware of this syntax, which apparently will be removed in a future version of SQL Server, according to the aforementioned MSDN article.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top