March 30, 2010 at 11:55 am
Hello -
"Sorry for reposting I posted this in the wrong forum before this one"
I'm in the process of using a script that will help with re-indexes. I keep getting the following errors.
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '('.
Msg 156, Level 15, State 1, Line 10
Incorrect syntax near the keyword 'ELSE'.
My database name is Backdrop and the table is dbo.PJTRAN and the index is pjtran0. Here is the script if someone can help me understand why I keep getting those errors.
IF EXISTS (SELECT [object_id],[index_id],[avg_fragmentation_in_percent] FROM sys.dm_db_index_physical_stats
(DB_ID(N'Backdrop'), OBJECT_ID(N'PJTRAN.PJTRAN0'), NULL, NULL , 'DETAILED')
WHERE [avg_fragmentation_in_percent] < 30)
BEGIN
ALTER INDEX ALL ON PJTRAN REORGANIZE
END
ELSE
ALTER INDEX ALL ON PJTRAN REBUILD
Thank you..
March 30, 2010 at 12:05 pm
Is that script dynamically generated? It seems to run on its own.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
March 30, 2010 at 12:08 pm
Hi - No its one that I would run manually. I got it from a DBA a while ago. But that person as since left the company. If there is another way of doing I'm open to anything.
Thanks...
March 30, 2010 at 12:21 pm
If you are looking for a powerful index reorganizing/rebuilding script, you could do much worse than look at MVP Michelle Ufford's very popular scripts:
http://sqlfool.com/category/sql-scripts/
The latest stable version is 3.0 I think.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply