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
"Error 1327 Invalid Drive F:/" on Sprint USB Wireless Installation
How can I get the Start and End dates used in a seach to display on the report? MS RS 2005
Problem with site in IE 8
How to Receive the windows message DBT_DEVICEQUERYREMOVE
Load BitMaps into a "Picture Control in MFC Dynamically
VFP 9.0 and Installshield
Getting Data off of a hard drive
When does System.IO.Ports.SerialPort<wbr /> DataReceived event fire?
Simple excel question
Automatically backup a PST file without closing it.