SQL Server : drop fulltext catalogs in a different database

1k Views Asked by At

Wondering if anyone know how to drop a fulltext catalog from a different database? I am trying to write a stored procedure, and I need to check if a fulltext catalog exists before creating it.

I've tried

IF EXISTS (SELECT * FROM DBName.sys.fulltext_catalogs WHERE Name = 'MyCataLog')
    DROP FULLTEXT CATALOG MyCataLog 

(it will only drop the catalog on the same DB)

it does not work. Anyone have done it before? I googled it and still can't find a solution.

Thanks much.

1

There are 1 best solutions below

0
Ranjana Ghimire On

try this

IF EXISTS (select * from DATABASE.sys.fulltext_catalogs WHERE Name = 'CATALOGNAME')   

EXEC ('USE <DATABASE NAME>;DROP FULLTEXT CATALOG MyCataLog')