Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBCC Command results to table or file?? 1

Status
Not open for further replies.

Catadmin

Programmer
Oct 26, 2001
3,097
US
Has anyone had any success in getting DBCC commands (mostly just the DBCC CheckDB) to export into a User table or a file?

Thanks in advance.



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
I don't think you can write the results of checkdb to a table because it is only returning messages.

- Paul
- Database performance looks fine, it must be the Network!
 
Yeah, that's what I thought. But since the Integrity Check task isn't working in SQL 2k5, my boss wants me to schedule overnight jobs running 'DBCC CheckDB'.

Which doesn't help us a whole lot because there's no one there to see the messages.

Just wanted verification that I was right. Thanks, Paul.



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
There is a work around for that.
It's not great but you can send the results to an out put file if you exec the command through a bat file like this.

Create the following bat file

Code:
-isql -Usa -Ppassword -SyourServer -i "C:\path to sql file.sql" -o "c:\path to output file"

Creat the following .sql file

Code:
USE yourdb
GO
DBCC CHECKDB

you can call the bat from your scheduled job.

then check the results of the file in the morning.


- Paul
- Database performance looks fine, it must be the Network!
 
Aha. Didn't think of using a .bat file.

I'll try that. Thanks.



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
I haven't had to use that method since 7.0 so I had almost forget all about it. I just happed to stumble across it in my script library.

- Paul
- Database performance looks fine, it must be the Network!
 
I have to use SQLCMD, not ISQL. I've got SQL 2005 and not only is ISQL not supported anymore, but OSQL is another of those "We're going to take this away but not tell you when" Microsoft features in 2k5.

Still, job is scripted and scheduled for tonight, so I'll see how it goes. Thanks again, Paul.



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
I didn't know they took it away. Good Luck.


- Paul
- Database performance looks fine, it must be the Network!
 
Another trick....try putting it into a job and setting the output to a file.

Then manually run the job.

-SQLBill

Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top