-- Drop RavenSync_* tables
DECLARE @tableName NVARCHAR(255)
DECLARE table_cursor CURSOR FOR
SELECT name FROM sys.tables WHERE name LIKE 'RavenSync_%'

OPEN table_cursor
FETCH NEXT FROM table_cursor INTO @tableName
WHILE @@FETCH_STATUS = 0
BEGIN
    EXEC('DROP TABLE [dbo].[' + @tableName + ']')
    FETCH NEXT FROM table_cursor INTO @tableName
END
CLOSE table_cursor
DEALLOCATE table_cursor

-- Drop triggers on each target table (you can add/remove names as needed)
DECLARE @triggerName NVARCHAR(255)
DECLARE trigger_cursor CURSOR FOR
SELECT name FROM sys.triggers WHERE name LIKE 'tr\_%' ESCAPE '\'

OPEN trigger_cursor
FETCH NEXT FROM trigger_cursor INTO @triggerName
WHILE @@FETCH_STATUS = 0
BEGIN
    EXEC('DROP TRIGGER [dbo].[' + @triggerName + ']')
    FETCH NEXT FROM trigger_cursor INTO @triggerName
END
CLOSE trigger_cursor
DEALLOCATE trigger_cursor
