BlargleMonster
BlargleMonster

Reputation: 1622

Check if a full text catalog exists in 2000

I'm trying to detect whether a database has a specific full text catalog so that I can either use it or avoid executing part of a script that would create errors without the catalog. I know in sql server 2005 you can use:

IF EXISTS(SELECT 1 FROM sys.fulltext_catalogs WHERE name = 'catalog_name')

But we have to support sql server 2000 still and I can't use that. Is there another way to check for the catalog?

Upvotes: 1

Views: 2565

Answers (1)

mr.Reband
mr.Reband

Reputation: 2430

The @@version check might need altering, but this should work:

declare @catalogExists tinyint
set @catalogExists = 0

if (@@version like ('%SQL%Server%2000%')) begin
    if exists(SELECT 1 FROM [master].[dbo].[sysfulltextcatalogs] WHERE name = 'catalog_name') 
        set @catalogExists = 1
end
else begin
    IF EXISTS(SELECT 1 FROM sys.fulltext_catalogs WHERE name = 'catalog_name')
        set @catalogExists = 1
end

print @catalogExists

Upvotes: 6

Related Questions