Orphan restrictions in SQL Server database

Fulfillment of the following query leads to all restrictions in our client database. However, a few rows in the result set, do not seem to have a parent that is parent_object_id = 0and OBJECT_NAME(parent_object_id)returns NULL.

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'

Does this mean that there are orphan restrictions in the database? If so, how can I remove them?

From their names, I see that they are leftovers before most of the changes were made to the structure.

+3
source share
1 answer

Using sp_helptext, I see that they were created using an instruction CREATE DEFAULT, for example:

CREATE DEFAULT dbo.MyDefault AS 2

, , sp_binddefault MSDN DROP DEFAULT:

DROP DEFAULT dbo.MyDefault

, , -, SQL Server MSDN.

+5

All Articles