Index Physical Stats

Hi Experts!

I would like to ask, what could be wrong with this procedure:

USE iass_ent3
GO
SELECT object_id, index_id, avg_fragmentation_in_percent, page_count
FROM sys.dm_db_index_physical_stats(DB_ID('iass_ent3'),
OBJECT_ID('dbo.ad_master'), NULL, NULL, NULL);

Open in new window


it returns:

Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '('.

In my other database server, I just changed the database name and table name, the procedure is working fine.

Thank you.
MediaBancAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Racim BOUDJAKDJIConnect With a Mentor Database Architect - Dba - Data ScientistCommented:
or you can do the following with older compatibility...

declare @db_id smallint, @table_id int
set @db_id=db_id('iass_ent3')
set @tab_id=object_id( 'dbo.ad_master')
select object_id, index_id, avg_fragmentation_in_percent, page_count
from sys.dm_db_index_physical_stats(@db_id,@table_id, NULL, NULL , NULL)
go

Open in new window


hope this helps...
0
 
Racim BOUDJAKDJIDatabase Architect - Dba - Data ScientistCommented:
please make sure the current compatibility of iass_ent3 is at least 90.
0
 
Anthony PerkinsCommented:
As Racimo has pointed out the function dm_db_index_physical_stats() was not available prior to SQL Server 2005.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.