Friday, March 23, 2012

EXEC

Hi,

I have a written a SP to do indexdefrag to all user table indexes in a databases...I had to use dynamic sql so I can reuse this code for any DB...

declare @.strsql varchar(500)

set @.strsql = ' dbcc indexdefrag('+'''DBName'''+',554556545,3)'

exec (@.strsql)

When I execute the above script, I immeaditely see the results in the query analyser like below:

Pages Scanned Pages Moved Pages Removed
- -- -
3 0 0

Looks like the indexdefrag did not happen since the logical fragmentation is still a high number like 30%.....

Just wondering whats goin on..

Thanks.

Ranga

Please take a look at the whitepaper below. That should answer most of your questions.

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx

|||Thanks Umachandar...the article was enlightening...

No comments:

Post a Comment