Check if FullText Catalog exists (SQL SERVER 2008 R2)
Question
Friday, June 3, 2011 5:41 AM
Hello.
I have tried to find out if a fulltext catalog exists.
I guess it would be something with
OBJECT_ID('mycatalog'')
?
All replies (4)
Friday, June 3, 2011 7:44 AM âś…Answered | 3 votes
Hi,
Please find the sample script below:
IF EXISTS (SELECT 1 FROM sys.fulltext_catalogs WHERE [name] = 'AW2008FullTextCatalog')
PRINT 'Catalog exists'
ELSE
PRINT 'Catalog does not exists';
I hope it helps.
J.
There are 10 type of people. Those who understand binary and those who do not.
Friday, June 3, 2011 6:04 AM
Hi,
Try to use the sys.fulltext_catalogs DMV.
I hope it helps.
J.
There are 10 type of people. Those who understand binary and those who do not.
Friday, June 3, 2011 6:25 AM
Can you state an SQL query for that? There is no sql query to be found on the internet, and I guess it might help other people, too.
Friday, June 3, 2011 8:37 AM
Thank you very much, works!
For the newbies among us, here is some extended example code in VB.NET:
Private Function pCatalogExists(ByVal uName As String) As Boolean
Dim cmd As New SqlClient.SqlCommand
cmd.Connection = m_Cn
cmd.CommandText = "SELECT 1 FROM sys.fulltext_catalogs WHERE [name] = '" & uName & "'"
Dim reader As SqlClient.SqlDataReader = cmd.ExecuteReader()
Dim b As Boolean
b = False
While reader.Read() 'If nothing to read, we will not come to the line "b = True"
b = True 'We have something to read, meaning that the recordset was filled
End While
reader.Close()
cmd.Dispose()
pCatalogExists = b
End Function