2 steps in order to delete Full Text Catalog:
1. Drop the full-text indexes.
2. Drop the full-text catalog.
In Order to delete all the full-text catalogs of the DB, Run this script:
-- 1. drop fulltext indexes
DECLARE @ExecAlter nvarchar(1000), @ExecDrop nvarchar(1000)
DECLARE CursorFtINDEX CURSOR FORWARD_ONLY FOR
-------------- Start Select --------------------------
SELECT ('ALTER FULLTEXT INDEX ON ' + SCHEMA_NAME(o.schema_id) + '.' + o.name + ' DISABLE'),
('DROP FULLTEXT INDEX ON ' + SCHEMA_NAME(o.schema_id) + '.' + o.name)
FROM sys.fulltext_indexes fti
join sys.objects o ON fti.object_id = o.object_id
order by fti.fulltext_catalog_id
-------------- End Select ----------------------------
OPEN CursorFtINDEX
FETCH NEXT FROM CursorFtINDEX
INTO @ExecAlter, @ExecDrop
WHILE (@@FETCH_STATUS = 0)
BEGIN
exec (@ExecAlter)
exec (@ExecDrop)
--Get next record from cursor
FETCH NEXT FROM CursorFtINDEX
INTO @ExecAlter, @ExecDrop
END
CLOSE CursorFtINDEX
DEALLOCATE CursorFtINDEX
-- 2. drop full text catalogs
DECLARE CursorFT CURSOR FORWARD_ONLY FOR
-------------- Start Select --------------------------
SELECT ('DROP FULLTEXT CATALOG ' + name)
FROM sysfulltextcatalogs
-------------- End Select ----------------------------
OPEN CursorFT
FETCH NEXT FROM CursorFT
INTO @ExecDrop
WHILE (@@FETCH_STATUS = 0)
BEGIN
exec (@ExecDrop)
--Get next record from cursor
FETCH NEXT FROM CursorFT
INTO @ExecDrop
END
CLOSE CursorFT
DEALLOCATE CursorFT
go
No comments:
Post a Comment