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 |
|
bogus
Starting Member
41 Posts |
Posted - 2006-05-31 : 19:48:04
|
| I have been working on a project to create a db copy utility using VB6.Thanks to this place, I have it working.However, it leaves me with one annoying problem... whenever a db is dropped, the junk remains... the .mdf file is deleted, but the .bak stays. How can I force SQL to ditch that junk?Any input would be greatly apprecaited.Thanks! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-05-31 : 19:48:58
|
| There is no way to force SQL Server to delete a file. So you must code for this. You can delete a file via T-SQL using xp_cmdshell.Tara Kizeraka tduggan |
 |
|
|
nosepicker
Constraint Violating Yak Guru
366 Posts |
Posted - 2006-05-31 : 19:59:28
|
| If you're just doing development, I guess you'll consider the backup (.bak) files junk. But if your database "accidentally" gets dropped, you won't consider those backup files junk, and you'll be very glad that they didn't get automatically deleted in the process. |
 |
|
|
bogus
Starting Member
41 Posts |
Posted - 2006-05-31 : 20:10:10
|
| np - I appreciate your concern!! Trust me!! However, I have dedicated a folder on the live server, along with unique names, and, a database controlling those names.the chances of a live db being deleted by this is slim to none.... seriously. I have taken all of those potentials into consideration.With the client, they want to be able to preserve snapshots, run tests on those snapshots and create different scenerios. When they are creating copies of this size (each db is about 4 gigs), keeping old junk around is just not efficient.tk - I will check t-sql via the xp_cmdshell. thanks!!! |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-05-31 : 20:56:12
|
if you're just deleting files, why not just create a batch file for that instead of doing it in tsql? then you can call that bat file when you drop the database --------------------keeping it simple... |
 |
|
|
bogus
Starting Member
41 Posts |
Posted - 2006-06-01 : 12:43:40
|
| Jen - I would love too... but the problem is the way the servers are set up here. I don't have access to the drive directly, and, the file names are unique, with a time date stamp.For this, I think the xp_cmdshell is my solution! |
 |
|
|
|
|
|
|
|