December 19, 2009 at 12:30 pm
Presently I'm using the below t-sql to manually rebuild the indexes of all the tables in the db:AdventureWorks
use adventureWorks
GO
EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)"
GO
===================================================================
How can I modify the query to "build all the indexes of all the tables of the databases"?
Pls suggest.
Thanks.
December 19, 2009 at 12:51 pm
Do we have any T-sql code to know when the indexes of the tables were rebuilt last time?
Thanks.
December 19, 2009 at 12:52 pm
there are lots of scripts in the Script section on this site that can help you.
you want to reuild typically not on when they were last rebuilt, but either on a schedule because of data changes, or based on fragmentation.
December 19, 2009 at 10:40 pm
Sourav-657741 (12/19/2009)
Presently I'm using the below t-sql to manually rebuild the indexes of all the tables in the db:AdventureWorksuse adventureWorks
GO
EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)"
GO
===================================================================
How can I modify the query to "build all the indexes of all the tables of the databases"?
Pls suggest.
Hi,
"sp_MSforeachtable" undocumented system stored procedures could not be supported in the future SQL Server versions.
Muthukkumaran Kaliyamoorthy
https://www.sqlserverblogforum.com/
December 19, 2009 at 10:47 pm
Sourav-657741 (12/19/2009)
Do we have any T-sql code to know when the indexes of the tables were rebuilt last time?
Hi,
Please read the 1'st link added in my signature this ll help u.
I wrote custom index rebuild script that maintaining the history table.
Muthukkumaran Kaliyamoorthy
https://www.sqlserverblogforum.com/
December 20, 2009 at 1:40 am
Please also note that DBCC DBREINDEX is deprecated, should not be used in new development and will be removed in a future version of SQL. The replacement is ALTER INDEX ... REBUILD
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
December 20, 2009 at 10:45 am
I'm not sure what's available in 2k8, but if you lookup DBCC SHOWCONTIG, there's a fully written script near the bottom of that help listing.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply