[dba-SQLServer]dbcc checkdb

MartyConnelly martyconnelly at shaw.ca
Thu Nov 13 14:51:37 CST 2003


How about running a stored procedure query out of an Access ADP
I haven't done this in awhile.
Then email your reports from Access. There are other ways to do this 
from SQL.

Here is a sample I used to checking SQL throttling stats in MSDE using dbcc

ALTER PROCEDURE StoredProcedureDBCCworks

AS
SET NOCOUNT ON
-- Create the table to accept the results or use #tracestatus #indicates 
temptable
If NOT EXISTS
(SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID('DBCCtracestatus ') AND 
sysstat & 0xf=3)
DROP TABLE DBCCtracestatus
BEGIN
CREATE TABLE DBCCtracestatus (
   maint varchar(4096),
   TraceFlag INT,
   Status INT
   )
END
-- Execute the command, putting the results in the table
INSERT INTO DBCCtracestatus(maint)
   EXEC master..xp_cmdshell 'OSQL -E -Q " DBCC CONCURRENCYVIOLATION  
WITH NO_INFOMSGS"'
/*
You can use xp_cmdshell to start a osql session to which you supply the 
DBCC page command. xp_cmdshell always returns rows.

   EXEC ('DBCC TRACESTATUS (-1) WITH NO_INFOMSGS')
INSERT INTO #maint(Results) EXEC(master..xp_cmdshell OSQL -E -Q dbcc 
checkdb(master))
*/
-- Display the results
SELECT *
FROM DBCCtracestatus
GO
    /* SET NOCOUNT ON */
    RETURN

Mark Boyd wrote:

>In an effort to control any allocation and/or consistency errors with
>SQL tables, I'd like to set up a job that would run dbcc_checkdb
>everynight.
>
>I would also like the results of this function to be emailed to a number
>of people in our IT dept.
>
> 
>
>Has anyone done this before?  If so, can you offer any suggestions?
>
> 
>
>Thanks,
>
>Mark Boyd
>
>Sr. Systems Analyst
>
>McBee Associates, Inc.
>
> 
>
>_______________________________________________
>dba-SQLServer mailing list
>dba-SQLServer at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>http://www.databaseadvisors.com
>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada





More information about the dba-SQLServer mailing list