Solved

Index Physical Stats

Posted on 2013-05-11
3
322 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

746 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

12 Experts available now in Live!

Get 1:1 Help Now