Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


INDEX REBULID


INDEX REBULID

Author
Message
pradeep.k 50453
pradeep.k 50453
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 Visits: 503
HI,

ANY ONE GIVE ME SCRIPT FOR INDEX REBULID AND UPDATE STATISTICS IN SQL 2008 R2
Neeraj Dwivedi
Neeraj Dwivedi
SSC Eights!
SSC Eights! (905 reputation)SSC Eights! (905 reputation)SSC Eights! (905 reputation)SSC Eights! (905 reputation)SSC Eights! (905 reputation)SSC Eights! (905 reputation)SSC Eights! (905 reputation)SSC Eights! (905 reputation)

Group: General Forum Members
Points: 905 Visits: 1319
Index rebuild itself update stats so, you do not have to update stats after index rebuild.

here is one script from web. But if you google it you will find many more., Choose the one which suits you best.

http://sqlfool.com/2009/03/automated-index-defrag-script/

But before implementing this... read through this..

http://msdn.microsoft.com/en-us/library/ms189858.aspx
pradeep.k 50453
pradeep.k 50453
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 Visits: 503
thank you
Orlando Colamatteo
Orlando Colamatteo
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8259 Visits: 14368
Another option for automating index and stats maintenance that I highly recommend:

http://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Jim Youmans-439383
Jim Youmans-439383
SSC Journeyman
SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)

Group: General Forum Members
Points: 98 Visits: 454
I agree with opc.three. This is one of the best scripts ever.

http://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html
Glen Schwickerath
Glen Schwickerath
Grasshopper
Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)

Group: General Forum Members
Points: 23 Visits: 326
The Ola Hollengren scripts are hands down best.
pnauta
pnauta
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 178
+1 for Ola Hallengren.
pradeep.k 50453
pradeep.k 50453
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 Visits: 503
thanks for all updates
Bhaskar.Shetty
Bhaskar.Shetty
Right there with Babe
Right there with Babe (778 reputation)Right there with Babe (778 reputation)Right there with Babe (778 reputation)Right there with Babe (778 reputation)Right there with Babe (778 reputation)Right there with Babe (778 reputation)Right there with Babe (778 reputation)Right there with Babe (778 reputation)

Group: General Forum Members
Points: 778 Visits: 509
ReIndex all the Indexes from the Databases.
EXEC sp_msforeachtable @COMMAND1="PRINT '?' DBCC DBREINDEX('?','',80)"
GO



Update all Statistics from the Database.

EXEC SP_UPDATESTATS
GO


pnauta
pnauta
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 178
The reason why Ola Hallengren's solution is better than the DBCC REINDEX commands:
- Microsoft recommends doing a reorganize only when fragmentation > 5% and < 30% and even do nothing when fragmentation < 5%, and then even ignore tables with < 10 000 rows.
- DBCC REINDEX syntax is deprecated (SQL 2000 syntax).

Ola Hallengren's script will dynamically choose what to do based on several factors:
- Licensing models (REBUILD ONLINE when possible)
- fragmentation level
- fields in tables (XML fields will prohibit REBUILD ONLINE and force REBUILD OFFLINE)

I have struggled for years with Microsoft Maintenance plans, and when this came along, I have started using it on all my db's. Whorks everytime, it's a no brainer and is even actively supported and updated.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search