Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Other SQL Server 2012 Topics
 Running a Command inside a FETCH

Author  Topic 

Dhudson29
Starting Member

23 Posts

Posted - 2014-10-28 : 12:28:54
I am trying to actually execute the ALTER FULLTEXT COMMAND in this code, but really don't know how. I debugged it and it actually assigns the database name, which is what I want, but then I need it to actually execute the command for each database. Can some help please?

--Declare Variable for selecting database files
DECLARE @SELDATABASE VARCHAR(255)
DECLARE @NAME VARCHAR(255)
DECLARE @RUNCATALOG VARCHAR(255)
SET @NAME = ''
DECLARE fulltextcatalog_cursor CURSOR FOR
Select name FROM MASTER.SYS.DATABASES
OPEN fulltextcatalog_cursor

FETCH NEXT FROM fulltextcatalog_cursor
INTO @name
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @SELDATABASE = 'USE [' + @NAME + ']'
FROM MASTER.SYS.DATABASES
SELECT @RUNCATALOG = 'ALTER FULLTEXT CATALOG' + ' ' + @NAME + ' ' + 'REBUILD'
Print ' catalog name is ' + @NAME
FETCH NEXT FROM fulltextcatalog_cursor
INTO @name
END
CLOSE fulltextcatalog_cursor
DEALLOCATE fulltextcatalog_cursor
GO

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-10-28 : 13:18:19
there's an undocumented procedure for that: http://weblogs.sqlteam.com/joew/archive/2008/08/27/60700.aspx
Go to Top of Page
   

- Advertisement -