Tuesday, February 26, 2013

[SQL Server] Auto delete datas from database

[SQL Server] Auto delete datas from database


Auto delete datas from database

Posted: 26 Feb 2013 05:52 AM PST

Hello everyone,You helped me pretty well last time so I hope you will be able to do the same this time :)So I created a database on SQL server that I fill up with SSIS. I created a job with sql agent that update the database weekly. However, I also need to delete the old datas. So in my table (incident) I have a column named " created " . The format is " yyyy-mm-dd- "The datas should be kept for 2 years. So, i am pretty sure that with a job I have the possibility to delete the old datas but I don't know how ... Is it possible that every week, the job checks the datas and if they are two years old it deletes them ? If yes, how please? Thank you :)

change a result into one record

Posted: 26 Feb 2013 04:49 AM PST

this is the code I used to retrieve a record set.SELECT p.HPROP, p.STYPE, p.SVALUE, NSFFee = CASE WHEN p.STYPE = 'nsffee' THEN p.hvalue END, SecDepIntRate = CASE WHEN p.STYPE = 'DDEPOSITINTEREST' THEN p.hvalue END FROM PROPOPTIONS PWHERE p.hprop = '240' and p.STYPE IN ('nsffee','DDEPOSITINTEREST')my result is as followedHPROP STYPE SVALUE NSFFee SecDepIntRate240 DDEPOSITINTEREST 0 NULL 3000.0000240 NSFFee 50.0000 NULLis there a way to get only one record or am i doint this wrong.

intersect procs?

Posted: 26 Feb 2013 02:55 AM PST

Hi all,I have 2 procs. Both return a list of values. I need to be able to create 3rd proc that would intersect procs 1 and 2. Is something like this possible in SS2008R2?[code="sql"]create procedure proc_3 asbegin exec proc_1; intersect exec proc_2;end;[/code]Thanks,

No comments:

Post a Comment

Search This Blog