Kric
Kric

Reputation: 103

SQL Server : drop fulltext catalogs in a different database

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.

Upvotes: 0

Views: 1267

Answers (1)

Ranjana Ghimire
Ranjana Ghimire

Reputation: 1815

try this

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

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

Upvotes: 2

Related Questions