Re: [Emerald] SQL Agent?

David Routh ( drouth@davlin.net )
Tue, 09 Nov 1999 20:01:48 -0600

>> To do this would I remove the "Step 1" in the task that says "Exec
>> CheckDatabase" then "Open" checkdb.sql and make that "Step 1"... basically
>> overwrite the "Exec Checkdatabase" that's in that task now?
>
>What you should do is replace the contents of the CheckDatabase
>stored procedure with the checkdb.sql script. Then you don't have
>to change the task.
>

This is what the stored proc looks like for CheckDatabase... Does this look
right... I removed all the "GO" parts as when I left them in it didn't like
it. Was I right to remove them? Will this work?

Thanks for your help.
David

CREATE PROC CheckDatabase AS
DBCC CheckDB(Emerald)
DBCC NewAlloc
DECLARE @query VARCHAR(100)
SELECT @query = "DBCC UpdateUsage("+ DB_NAME() + ")"
EXEC (@query)
DBCC CheckIdent(Actions)
DBCC CheckIdent(Charges)
DBCC CheckIdent(ChargeTypes)
DBCC CheckIdent(ClassDates)
DBCC CheckIdent(Classes)
DBCC CheckIdent(Credits)
DBCC CheckIdent(Domains)
DBCC CheckIdent(ExternalSystems)
DBCC CheckIdent(ExternalTrans)
DBCC CheckIdent(Groups)
DBCC CheckIdent(Incidents)
DBCC CheckIdent(InvoiceItems)
DBCC CheckIdent(Invoices)
DBCC CheckIdent(Mail)
DBCC CheckIdent(MasterAccounts)
DBCC CheckIdent(Payments)
DBCC CheckIdent(RadATConfigs)
DBCC CheckIdent(RadConfigs)
DBCC CheckIdent(Rates)
DBCC CheckIdent(Reports)
DBCC CheckIdent(Scripts)
DBCC CheckIdent(Servers)
DBCC CheckIdent(SubAccounts)
DECLARE @tablename varchar(30)
DECLARE @tablename_header varchar(75)
DECLARE tnames_cursor CURSOR FOR SELECT name FROM sysobjects WHERE type =
'U'
OPEN tnames_cursor
FETCH NEXT FROM tnames_cursor INTO @tablename
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
SELECT @tablename_header = "Updating " +
RTRIM(UPPER(@tablename))
PRINT @tablename_header
EXEC ("UPDATE STATISTICS " + @tablename )
END
FETCH NEXT FROM tnames_cursor INTO @tablename
END
PRINT " "
PRINT " "
SELECT @tablename_header = "************* NO MORE TABLES"
+ " *************"
PRINT @tablename_header
PRINT " "
PRINT "Statistics have been updated for all tables."
DEALLOCATE tnames_cursor

For more information about this list (including removal) go to:
http://www.iea-software.com/support/maillists/liststart