hi, i am using SQL Server 2005. i have a database DBOneshelp, in that Database there is a table - tblSearch. now i want to see the fragmentation status of that table so execute the following Query: SELECT PK_SalesId, avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats (DB_ID(N'DBOneshelp'), OBJECT_ID(N'tblSearch'), NULL, NULL , 'Detailed') go but there is a syntax error: Msg 102, Level 15, State 1, Line 3 Incorrect syntax near '('. can any one tell me what is the error i have done in the above sql statement thanks in advance regards, suvresh
http://www.sql-server-performance.com/articles/per/detect_fragmentation_sql2000_sql2005_p1.aspx http://msdn2.microsoft.com/en-us/library/ms188917.aspx fyi
try the following: SELECT PK_SalesId, avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats (DB_ID('DBOneshelp'), OBJECT_ID('tblSearch'), NULL, NULL , 'Detailed')
You can use the following with the compatible level 80 Declare @db_id smallint Declare @tab_id int set @db_id=db_id('DBOneshelp') set @tab_id=object_id( 'tblSearch') SELECT PK_SalesId, avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats (@db_id,@tab_id, NULL, NULL , 'Detailed') go