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.
| Author |
Topic |
|
ostinoh
Yak Posting Veteran
66 Posts |
Posted - 2010-03-30 : 10:30:35
|
| Hello - 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 2Incorrect syntax near '('.Msg 156, Level 15, State 1, Line 10Incorrect 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)BEGINALTER INDEX ALL ON PJTRAN REORGANIZEENDELSEALTER INDEX ALL ON PJTRAN REBUILDThank you.. |
|
|
namman
Constraint Violating Yak Guru
285 Posts |
Posted - 2010-03-30 : 13:09:21
|
| 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)BEGINALTER INDEX ALL ON PJTRAN REORGANIZEENDELSEALTER INDEX ALL ON PJTRAN REBUILDI do not see any error from that part.Could you post the entire script up here?Note: the condition is likely always true?!!? |
 |
|
|
|
|
|
|
|