Solved

Index Physical Stats

Posted on 2013-05-11
3
326 Views
Last Modified: 2013-05-13
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.
0
Comment
Question by:MediaBanc
  • 2
3 Comments
 
LVL 23

Expert Comment

by:Racim BOUDJAKDJI
ID: 39158419
please make sure the current compatibility of iass_ent3 is at least 90.
0
 
LVL 23

Accepted Solution

by:
Racim BOUDJAKDJI earned 500 total points
ID: 39158426
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39159771
As Racimo has pointed out the function dm_db_index_physical_stats() was not available prior to SQL Server 2005.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now