RE: Rebuilding all indexes on all table

RE: Rebuilding all indexes on all table

 

  

Hi!,

The script will automatically reindex every index in every
table of any database you select, and provide a fill factor
of 90%. You can substitute any number appropriate for the
fill factor in the below script.

USE <DatabaseName>

DECLARE @TableName varchar(255)

DECLARE TableCursor CURSOR
FOR
SELECT table_name FROM information_schema.tables
WHERE table_type = 'base table'

OPEN TableCursor
FETCH NEXT FROM TableCursor INTO @TableName

WHILE @@FETCH_STATUS = 0
BEGIN
DBCC DBREINDEX(@TableName,' ',90)
FETCH NEXT FROM TableCursor INTO @TableName
END

CLOSE TableCursor
DEALLOCATE TableCursor

Regards,
Milind Amin
Software Professional
TechProcess Solution Ltd
Direct: +91-22-66528612 (M-F Firstly)
Cell: +91-9819916106 (M-S Secondly)
------------------------------------
TEAMWORK...
Coming together is a beginning;
Keeping together is progress;
Working together is a success;
-------------------------------------


-----Original Message-----
From: BOUCHE Sylvain GBM
[mailto:mssqldba-ezmlmshield-x77013264.[Email address protected]
om]
Sent: Friday, December 29, 2006 8:15 PM
To: LazyDBA Discussion
Subject: Rebuilding all indexes on all table


Hi,


Has anybody got a script for rebuiling all indexes on all
tables in a
specified db using the ALTER INDEX statement?

Thanks,
Sylvain

************************************************************
***********************
The Royal Bank of Scotland plc. Registered in Scotland No
90312. Registered Office: 36 St Andrew Square, Edinburgh EH2
2YB.
Authorised and regulated by the Financial Services Authority


This e-mail message is confidential and for use by the
addressee only. If the message is received by anyone other
than the addressee, please return the message to the sender
by replying to it and then delete the message from your
computer. Internet e-mails are not necessarily secure. The
Royal Bank of Scotland plc does not accept responsibility
for
changes made to this message after it was sent.

Whilst all reasonable care has been taken to avoid the
transmission of viruses, it is the responsibility of the
recipient to
ensure that the onward transmission, opening or use of this
message and any attachments will not adversely affect its
systems or data. No responsibility is accepted by The
Royal Bank of Scotland plc in this regard and the recipient
should carry
out such virus and other checks as it considers appropriate.

Visit our websites at:
www.rbs.com
www.rbsgc.com
www.rbsmarkets.com
************************************************************
***********************


------------------------------------------------------------
---------
TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST
REPLY
To post a dba job: http://jobs.lazydba.com
To subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html

--


"This e-mail message may contain confidential, proprietary or legally privileged information. It
should not be used by anyone who is not the original intended recipient. If you have erroneously
received this message, please delete it immediately and notify the sender. The recipient
acknowledges that ICICI Bank or its subsidiaries and associated companies, (collectively "ICICI
Group"), are unable to exercise control or ensure or guarantee the integrity of/over the contents of the information contained in e-mail transmissions and further acknowledges that any views
expressed in this message are those of the individual sender and no binding nature of the message shall be implied or assumed unless the sender does so expressly with due authority of ICICI Group.Before opening any attachments please check them for viruses and defects."



MS Sql Server LazyDBA home page