Hi,
This is an procedure to rebuild all the indexes in a database. It puts some
output into a table called indexreport. DBCC DBREINDEX is the main
procedure that is run in this script and does it for all tables in the
database through a cursor........
create procedure change_index
as
set nocount on
declare indx_csr cursor for
select name from sysobjects where type = 'U' order by name
open indx_csr
declare @tablename sysname
fetch indx_csr into @tablename
while (@@fetch_status = 0)
begin
insert into indexreport values (@tablename, getdate (), 'started')
DBCC DBREINDEX (@tablename, '',100)
insert into indexreport values (@tablename, getdate (), 'completed')
fetch indx_csr into @tablename
end
deallocate indx_csr
return
Hope that helps with question 2.
Meg
Meg Hardy | Mondial Assistance UK | Junior DBA | Tel +44 208 681 2525
-----Original Message-----
From: M B Shibu [ <mailto:basher.[Email Address Removed] Tuesday, July 09, 2002 8:36 PM
To: [Email Address Removed] queries ,indexes and performance reports
Hi friends.........
I have a few questions on sqlserver .
1) How can i find the expensive queries running against sqlserver ??
Can anyone send me some white papers u have on query tuning in
sqlserver ??
2) How to find the indexes that needs to be rebuilded and how to rebuild
the indexes ??
3) What are the daily work u do sqlserver production database . I mean is
there any way to take
any kinda performance reports from the database
Please help me ..... i work mostly on oracle and dunno much about
sqlserver
Thanks
shibu
**********************************************************************
DISCLAIMER
Any opinions expressed in this email are those of the individual and not necessarily of Mondial Assistance (UK) Ltd. This email and any files transmitted with it, including replies and forwarded copies (which may contain alterations) subsequently transmitted from the Company, are confidential and solely for the use of the intended recipient. If you are not the intended recipient or the person responsible for delivering to the intended recipient, be advised that you have received this email in error and that any use is strictly prohibited.
If you have received this email in error please notify the IT support desk by telephone on +44 (0)208 2393984 or via email to
[Email Address Removed] including a copy of this message. Please then delete this email and destroy any copies of it. Thank you.
Mondial Assistance (UK) Ltd
Mondial House
102 George Street
Croydon
CR9 1AJ
Mondial Assistance (UK) Ltd Registered in England No.1710361 Registered office as above
**********************************************************************
This message has been checked for all known viruses by the
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/
MS Sql Server LazyDBA home page