Hi All,
When I run the script below I get the error "Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name '#table'".
CREATE TABLE #table (Check_Log VARCHAR(1000), Log_Time datetime default GetDate())
INSERT #table(Check_Log)
EXEC master..xp_cmdshell 'osql -S server -U user -P password -d db -Q"DBCC CHECKDB"'
EXEC master..xp_cmdshell 'bcp dbname.user.#table out Z:\Test\CheckDBRes.txt -S server -U user -P password'
SELECT * FROM #table
IF EXISTS (SELECT * FROM #table
WHERE Check_Log = 'CHECKDB found 0 allocation errors and 0 consistency errors in database')
PRINT 'No errors'
ELSE
RETURN
DROP TABLE #table
Can you please tell what I am doing wrong?
ThanksDidn't we do this laready?
All you had to do was curt and paste my origina;|||This is a little bit different. Your script doesn't put the results of checkdb into the text file. But this is one of the requirements.|||You will need to make this a permanent table
Also, make sure you put the batch column back in|||What is the purpose of the batch column?|||So that multiple processes can use trhe samme table, you can retain all of the logs, and then only ftp out 1 "batch" dbcc process at a time.
Trust me it will make life a lot easier
http://www.dbforums.com/showthread.php?t=1612711|||Thanks for your help.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment