Microsoft
Software
Hardware
Network
Question : sql
I am attempting to write a query that will loop through all the databases and rebuild all the indexes for each table.
I would like to use sp_msforeachtable and msp_msforeachdb
[code]
EXEC master..sp_MSForeachdb '
USE [?]
BEGIN
declare @starttime datetime
set @starttime = getdate()
print ''?''
EXEC sp_MSforeachtable @command1="DBCC DBREINDEX (''?'')"
declare @endtime datetime
SELECT @endtime = GETDATE()
INSERT INTO DBADB..MaintPlans values (getdate(), ''indexes'',db_name(), datediff(minute,@StartTime
, @EndTime))
END'
GO
[/code]
and i am receiving an error. is it possible to use both of these commands together? Also, i would like to include the fillfactor = 90% (DBCC REINDEX ( tablename, '', 90)
Any assistance you could provide would be great.
Answer : sql
>is it possible to use both of these commands together?
No, you cannot use both of them together
Random Solutions
Stored Procedure Fails To Populate Recordset
How to run SELECT statement against DataSet object
Error when updating from MS Money 2000 to MS Money 2008
T-SQL: calculate totals in SELECT statement witout GROUP BY
CF - Syntax error in Update statement
Sum column in datagrid
Use of Pipes?
Variable 'dataRS' is used before it has been assigned a value. A null reference exception could result at runtime.
how to pull week day and time from a query
Copied all vb files (..vb file, project, solution, user options) for a project but getting errors.