.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Delete Folders which is older than some specific days

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :Sql Server
Hi All, I have scenerio where we are taking daily backup files as datebasename_<today'sdate>.Dat_bak under databaseName_<today's date> folder under root database_backup folder.  So I need to delete folders which are older than 10 days where it automatically deletes backup files also.  Can anyone tell me how to delete folders which are older than some specific days?  Btw, we are using sql server 2005 enterprise edition Thanks in advance Anand R  

View Complete Post

More Related Resource Links

Delete files older than 3 days using SSIS tasks


I want to delete all files in a given folder that are older than 3 days from today's date.

I tried using a "Foreach Loop container"  with a "File System" task inside it but found I couldn't access any file properties such as the file creation date. Am I using the wrong task for this job?






P.S. History of the problem:

I used the sql 2005 Database maintenance program to setup our database backup jobs. One day I noticed that the free space on the drive where we keep the dumps had grown small. I found that we had at least 4 weeks of dumps in there, not the 3 days I wanted to keep!  I looked but could not find the "delete file" option in the SSIS package generated by the Database Maintenance Wizard. No wonder the files were piling up.

SSRS 2008 SP1 - Enabling "My Reports" allows users delete reports in folders they should not be able

Issue: Users that have “My Reports” SSRS Role assigned to them can delete reports in other “shared” folders. My understanding was that they will be able to do the tasks specified only  in the “My Reports” workspace not everywhere. I have “My Reports” enabled via SSMS. Users have “My Reports” role assigned to them at the root level. My SSRS Role “My Reports” has only the following tasks assigned: 1.       View Reports 2.       Manage reports 3.       View Folders 4.       Manage Folders To test, I'm using Development version of SQL Server 2008 SP1. Thanks in advance, Martina


How do you limit the execution of stored procedure / or update of items only to happen on specific days.   i need this only to execute if today is day 3 through day 7 (tue - sat) UPDATE itm SET AVG_WHSL_PRC = AWP.CURR_AWP_AMT ,AWP_EFF_DT = @Pricing_Date ,UPDT_DTS = GETDATE() ,UPDT_OPR_ID = RIGHT(SUSER_SNAME(), 7) FROM dbo.T_ITEM_PRC_CHG itm JOIN #TEMP_AWP awp ON itm.EM_ITEM_NUM = awp.EM_ITEM_NUM WHERE itm.PRC_CURR_CD IN ('C','F') AND @Pricing_Date BETWEEN itm.PRC_EFF_DT AND itm.PRC_END_DT AND itm.HOME_ACQ_COST > 0 AND ISNULL(itm.AVG_WHSL_PRC, 0) <> awp.CURR_AWP_AMT

Delete specific permissions programatically in Sharepoint 2010

I have created a windows application to create custom permission levels(4) in sharepoint 2010 for deployment purpose of our sharepoint site. I am able to create custom permission levels(4) successfully. My requirement is, each time when I run this windows application, I need to check whether those 4 custom permissions levels already exists or not and if they exist, I need to delete those 4 permission levels and recreate them. How can I check whether the site contains these permission levels already and it contains them, how can I delete those 4 only and recreate them?

How to delete "Users Folders" from the Home...

Hello, all.  I recently had to rebuild my Reports Server.  Luckily I had all reports, data sources saved in a Viz Studio project so I just redeployed.  My question is how do I delete this annoying "Users Folders" link from the Home folder.  Clicking the "Users Folders" link, I see additional folders of the few users I have.  I'd like to delete the Users Folders link altogether from the Home folder.  However when I attempt to delete a folder or multi select and delete all of them, I get an error "The permissions granted to user 'SAWS\rhall' are insufficient for performing this operation. (rsAccessDenied)".  I believe I am an Administrator on this server...or at least I should be.  Can anyone help?

Thanks in advance folks,
Roz <

create stored procedure to remove records older than 90 days.


Hi All, i want to create two new stored procedures to remove records older than 90 days from tables DirStaging.Trr.FullEnrollmentImport and DirStaging.Trr.WeeklyMonthlyImport. The same stored procedure will remove all records from Dir.dbo.ErrorTable where there is not a record in Dir.Trr.FullEnrollment and Dir.Trr.WeeklyMonthly.    Both the procedures will accept an input variable called @CleanupDays. This will be passed from the calling system. there is a field called EtlId in DirStaging.Trr.FullEnrollmentImport which i would have to use to get recent load of information. i mean, if i am loading thousand records then they would have same EtlId. so i guess i have to have @EtlId and @CleanupDays as input variables.

I tried something like moving all the data from the DirStaging.Trr.FullEnrollmentImport to temp table, truncate DirStaging.Trr.FullEnrollmentImport and apply condition on temp table to get recent

SharePoint Designer Workflow - how to compare the Items if it is modified date is older than 20 days


I have a workflow which will keep track of specific meta data selection for a Custom List, as soon as an item gets updated to a specific selection say it as Resolved, I am sending an email to an user.


But after this I will need to check for every item in the list that If an item gets resolved and older than 20 days, I will have to move this item to a different list. I can get the resolved item date, store it an variable, but from here I will need to check if the item is older than 20 days and if it is this needs to be moved.

My point is the work-flows will be fired only when an item gets changed or updated, how to keep track of every item in the list and automatically move the older items without any manual intervention.


Am I clear in my requirement, if not kindly let me know.

If you have knowledge, let others light their candles in it.

Events don't show up in a specific month and in last days of months whose calendar view include day



I actually faced a strange problem which is that when I add events in september 2011, they don't show up in the calendar view and the view remains empty but they appear in the all events view but events in other months appear.

Another strange thing is that I was adding events in July 2011. In the calendar view of July 2011, the first 6 days of August appear but this isn't the problem but the problem is that when I add about 3 events in 31 July then about another three from 31 July to 4 August and then about 2 events from 1 to 4 August, the events are collapsed and the 3 more items appear but when I click the link, I don’t see the events that were just on 31 July and I tried this too in the end of March so it seems that the months whose calendar view includes some days from the next month have a problem.

And finally when I change the month to be october 2010, I get error page with the text:

An unexpected erro has occured.

web parts maintenance page: If you have permission, you can use this page to temporarily close Web Parts or remove personal settings. For more information, contact your site administrator.

and I checked in more than one calendar and in more than one site and it's the same, So I'm asking if any one faced something like th

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

SharePoint document migration challenges when migrating files and folders

There are several challenges when migrating documents to Microsoft SharePoint. While these challenges can be overcome, they are a real pain if the migration source, content and file systems are not SharePoint friendly.

SqlCommand.ExecuteNonQuery() returns -1 when doing Insert / Update / Delete

Sometimes you end up with a return value of -1 when using the SqlClient.SqlCommand.ExecuteNonQuery method.

Why is that?

Well, the ExecuteNonQuery method is there for statements for changing data, ie. DELETE / UPDATE /INSERT, and the returned value are the number of rows affected by that statement.

When checking the documentation we can see that there are some conditions that return -1.

For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command.

When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of

rows affected by the trigger or triggers. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.

Button specific code


I have 2 submit buttons on my page. Right now, the only way to run the code behind with razor is to to If(IsPost). Since I have 2 buttons, how would I destinguish between the two in post? Is there a way to request a button that sent a post request?  

update/delete not working on server only


my aspx page works in VWD, and everything works on the server EXCEPT update and delete sql functions. any ideas?


How to use TOP in DELETE



I have a large database in MSSQL 2005 (rows around 3,788,299 : size 4GB)

Two questions

1. SQL query ~ select top 100 * from [tablename], how do capture the next 100 record?

2. SQL query ~ delete top 100 from [tablename] --- MSSQL show me syntax error? How can I only delete the top 100 record?



delete record from excel sheet



           I have write the code for deleting the data in excel sheet. but we have got the error" Deleting data in a linked table is not supported by this ISAM."

     below I paste some code snippest.

string strDelete = "Delete  from [" + strSheetName + "$]";

            cmdExcel.Connection = con;
            cmdExcel.CommandType = CommandType.Text;
            cmdExcel.CommandText = strDelete;


Please can anybody this answer.It is urgent

delete data in excel sheet



           I have write the code for deleting the data in excel sheet. but we have got the error" Deleting data in a linked table is not supported by this ISAM."

     below I paste some code snippest.

string strDelete = "Delete  from [" + strSheetName + "$]";

            cmdExcel.Connection = con;
            cmdExcel.CommandType = CommandType.Text;
            cmdExcel.CommandText = strDelete;


Please can anybody this answer.It is urgent

Getting list of users reporting from specific Manager from Active Directory


Dear All,

I am have requirement like displaying all the user information reporting to specific manager from Active Directory.

Please help me regarding this.



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend