Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
SamC
White Water Yakist
3467 Posts |
Posted - 2004-10-15 : 09:50:20
|
I've got a stored proc that I can schedule to execute periodically which determines if any users are currently logged into the datase. There's usually an hour or two Saturday / Sunday AM when there's nobody on.I'd like to schedule a job that will defragment the database at that time. I mean a disk defragmentation of only the database file (not a DBCCREINDEX or DBCCDEFRAG) ... using the "contig" software from sysinternals .The trick is the database must be detached, run contig, then attached again. Using a scheduled SQL job, one approach would be to detach, run a windows batch file which would execute contig, attach the DB and the Job terminates normally. Maybe send an email to the DBA so he/she feels good.I was wondering if anyone had done something like this already. Any caveats, suggestions, or tomatos? Free code? Sam |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-10-16 : 03:13:34
|
| Detached? or can you just stop/start the SQL service (which you can do from DOS)If there any other SQL databases which must be UP at this time then I don't suppose this will be a very good idea ... but if that's the case maybe you could flag the DB to be defragged as "offline" during that time - I think that will mean that its files are not "open", and thus will be candidates for defrag ...Sorry, no free code available for this one, but I'd like to enjoy my free lunch with you ...Kristen |
 |
|
|
|
|
|