Home > Ask the SQL Server Experts > Joe Toscano - Integration Services/Development Questions & Answers > Delete .bak files automatically with CLR
Ask The SQL Server Expert: Questions & Answers
EMAIL THIS

Delete .bak files automatically with CLR

Joe Toscano EXPERT RESPONSE FROM: Joe Toscano

Pose a Question
Other SQL Server Categories
Meet all SQL Server Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 16 February 2007
I have a query and I want to know if there is a stored procedure, SQL script, or T-SQL script to delete the .bak files, which are older than seven days. I have set up daily backups and after the day seven, the .bak files should purge off. How can I get these .bak files to delete?

>
EXPERT RESPONSE
Ideally you should use a database maintenance plan to handle this. The functionality is built in and handled by maintenance plans in both SQL Server 2000 and 2005. I just don't think Transact-SQL is the right tool for deleting old backup files. Before SQL Server 2005 I did use xp_cmdshell to execute OS commands. While these extended stored procedures still exist, they'll eventually go away because of what CLR integration provides.

Since you are running SQL Server 2005 you are able to create stored procedures in C# or VB.Net using Visual Studio 2005. That is exactly the route I would recommend. If you do, you will be able to execute the CLR procedure just like you would execute a Transact-SQL created stored procedure.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Joe Toscano - Integration Services/Development
How to convert DTS packages to SSIS and overwrite data
How to migrate DTS to SSIS and deploy SSIS packages
Query to search text in old DTS packages in SQL Server?
Error importing Excel data to SSIS in SQL Server 2005
DTS package designed to overwrite extract.xls
Displaying a SQL Server database report in Excel
Call triggers in a stored procedure
Stored procedure practices in SQL Server
SQL Server permission to create jobs and schedules in SSIS
Problems with structured exception handling

SQL Server stored procedures
SQL Server trigger vs. stored procedure to receive data notification
How to use SQL Server 2008 hierarchyid data type
SQL and SQL Server Tutorial and Reference Guide
SQL Server stored procedures tutorial: Write, tune and get examples
Check SQL Server database and log file size with this stored procedure
SQL Server source code analysis and management adds database security
Configure SQL Server Service Broker for sending stored procedure data
Find size of SQL Server tables and other objects with stored procedure
Track changes to SQL Server 2000 and 2005 with one simple utility
Troubleshoot SQL Server 2005 temporary table performance problems

SQL Server Development
Change tempdb from 'C' drive
Tempdb changes in SQL Server 2005
Sub-queries supported in Analysis Services MDX
MDX functions: SCOPE, THIS and FREEZE
More powerful Analysis Services MDX in SQL Server 2005
CASE statements now supported by MDX script
Top 5 SQL Server query tips
Update table rows in SQL Server 2000
Utility to dump SQL Server Express database as text file
Stored procedure overview in SQL Server
SQL Server Development Research

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
library  (SearchSQLServer.com)
trigger  (SearchSQLServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



SQL Solutions - SQL Database Design
HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2005 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts