Home > Archive > MS SQL Server DTS > July 2005 > sql reindex









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author sql reindex
benamis

2005-07-20, 11:23 am

hi

maybe someone has a script which recreates the indexses on db?

i think the best way is to use

CREATE unique INDEX
WITH DROP_EXISTING

and the procedure sp_MSforeachtable

the problem is that i don't know how to "join" these 2 options as every
table has lots of indexses...

currently i use this:

exec sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?')"

but it is 2x less effective as "CREATE unique INDEX WITH DROP_EXISTING"


thanx

P.S. i am not too good in sql programing :)

Andrew J. Kelly

2005-07-20, 1:23 pm

What do you mean by 2x less effective? Did you have plenty of free space in
the database before you issued the DBCC DBREINDEX? If not then the files
would have had to grow, probably multiple times. This can be a real
performance issue and you should always ensure you have plenty of free space
at all times. Never shrink the files after you do a reindex or you just
waste the effort in the first place. You can not recreate the indexes in
the manor you indicate and should not try. DBCC DBREINDEX is usually the
best method to deal with reindexing all the indexes on a table.

--
Andrew J. Kelly SQL MVP


"benamis" <nera@meilo.lt> wrote in message
news:u9%23Wj6TjFHA.576@TK2MSFTNGP15.phx.gbl...
> hi
>
> maybe someone has a script which recreates the indexses on db?
>
> i think the best way is to use
>
> CREATE unique INDEX
> WITH DROP_EXISTING
>
> and the procedure sp_MSforeachtable
>
> the problem is that i don't know how to "join" these 2 options as every
> table has lots of indexses...
>
> currently i use this:
>
> exec sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?')"
>
> but it is 2x less effective as "CREATE unique INDEX WITH DROP_EXISTING"
>
>
> thanx
>
> P.S. i am not too good in sql programing :)
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com