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
sql statement needed
how to unlock an folder which is locked in dos mode
Data Modelling
How do you share the root of a Windows 7 drive to an XP machine?
Can Paypal Standard Checkout be integrated with a MS Publisher created web site?
Internet Explorer has stopped working
Error:Cannot open database". It may not be a database that your application recognizes, or the file may be corrupt.
ReportViewer Export to PDF Loses Tabs or Multiple Blnak Spaces
How to read field names from an XSD file.
Reformatting Drives C D E and F