• I have created a small script that cleans up all the mess. You might need to run it a few times and/or extend it with your own objects. Make sure you set the date properly, otherwise it won't do anything.

    DECLARE @date date

    SELECT @date = '2099-01-01' -- Adjust to the date that you started the mess :-)

    DECLARE @statement nvarchar(250)

    -- Kill all processes that have a connection to this database

    DECLARE ForeignKeyCursor CURSOR LOCAL FORWARD_ONLY

    FOR SELECT fk.name, tab.name

    FROM sys.objects fk

    INNER JOIN sys.objects tab ON fk.parent_object_id = tab.object_id

    WHERE fk.TYPE = 'F'

    DECLARE @keyName sysname

    DECLARE @tableName sysname

    OPEN ForeignKeyCursor

    FETCH NEXT FROM ForeignKeyCursor INTO @keyName, @tableName

    WHILE @@FETCH_STATUS = 0

    BEGIN

    SET @statement = 'ALTER TABLE [' + @tableName + '] DROP CONSTRAINT [' + @keyName + ']'

    EXEC sp_executeSql @statement

    FETCH NEXT FROM ForeignKeyCursor INTO @keyName, @tableName

    END

    CLOSE ForeignKeyCursor

    DEALLOCATE ForeignKeyCursor

    -- Kill all processes that have a connection to this database

    DECLARE ObjectCursor CURSOR LOCAL FORWARD_ONLY

    FOR SELECT name, type FROM sys.objects WHERE create_date >= @date

    DECLARE @name sysname

    DECLARE @type nvarchar(10)

    OPEN ObjectCursor

    FETCH NEXT FROM ObjectCursor INTO @name, @type

    WHILE @@FETCH_STATUS = 0

    BEGIN

    SET @statement =

    CASE @type

    WHEN 'FN' THEN 'DROP FUNCTION [' + @name + ']'

    WHEN 'IF' THEN 'DROP FUNCTION [' + @name + ']'

    WHEN 'TF' THEN 'DROP FUNCTION [' + @name + ']'

    WHEN 'P' THEN 'DROP PROCEDURE [' + @name + ']'

    WHEN 'U' THEN 'DROP TABLE [' + @name + ']'

    WHEN 'V' THEN 'DROP VIEW [' + @name + ']'

    ELSE null

    END

    IF @statement IS NOT NULL

    EXEC sp_executeSql @statement

    FETCH NEXT FROM ObjectCursor INTO @name, @type

    END

    CLOSE ObjectCursor

    DEALLOCATE ObjectCursor

    GO

    Unfortunately, I couldn't find a way to safely detect if a user-defined type could be deleted. You have to do this by hand.