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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 compare date with current date

Author  Topic 

robbierut
Starting Member

1 Post

Posted - 2011-11-11 : 13:28:43
Hey,

I need to compare the date of when a record is added(is in the record itself) with the date of today and when it expires (after 28 days) it needs to delete the whole record.

Is this best done with a sql query or with a macro, and how should it start?

Thanks in advanced!!!

X002548
Not Just a Number

15586 Posts

Posted - 2011-11-11 : 13:43:25
What's a macro?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2011-11-11 : 14:23:34
1. create a sproc that compares each rows date with today's date and then deletes if it is stale
2. Plug the sproc into a SQL job that runs daily or whatever frequency you want it to run

?

If you don't have the passion to help people, you have no passion
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-12 : 05:44:01
quote:
Originally posted by robbierut

Hey,

I need to compare the date of when a record is added(is in the record itself) with the date of today and when it expires (after 28 days) it needs to delete the whole record.

Is this best done with a sql query or with a macro, and how should it start?

Thanks in advanced!!!


we've few tidying up jobs like this and it makes use of sql procedures to do this and we've automated them using sql server agent for automated execution as yosiaz suggested

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -