Saturday, February 25, 2012

Query that automatically deletes records that are older than 3

Thanks Tom, great help now that i know that where do i create it so that it
runs automatically? would it be a UDF?
thanks
"Tom Moreau" wrote:

> Leave out the column names:
> DELETE FROM [dbo].[RECadvert]
> WHERE RECadDatePosted < DATEADD(dd,-365,getdate())
>
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinpub.com
> ..
> "GTN170777" <GTN170777@.discussions.microsoft.com> wrote in message
> news:84131850-B81C-4878-84CD-BC8C0116AD56@.microsoft.com...
> Hi all,
> I'm trying to build a self running query that deletes all records that are
> older than 365 days. the code i've used is -
> DELETE RECadvertId
> RECadRecruiterId
> RECadreference
> RECadjobtype
> RECadLocation
> RECadJobTitle
> RECadSalary
> RECadcategory
> RECadduration
> RECadstartdate
> RECadDatePosted
> RECadCompanyID
> RECadDescription
> RECadDescriptionshort
> RECaddayspostedfor
> RECadBenefits
> FROM [dbo].[RECadvert]
> WHERE RECadDatePosted > DATEADD(d,365,RECadDatePosted)
> It isn't working, any ideas?
> thanks
>Make a sql server task to run once a day. write the script into it to
execute
"GTN170777" <GTN170777@.discussions.microsoft.com> wrote in message
news:62833ACE-EC24-464B-A19E-AD0FEE340AB4@.microsoft.com...
> Thanks Tom, great help now that i know that where do i create it so that
> it
> runs automatically? would it be a UDF?
> thanks
> "Tom Moreau" wrote:
>|||How do you do that?
"Mubashir Khan" wrote:

> Make a sql server task to run once a day. write the script into it to
> execute
> "GTN170777" <GTN170777@.discussions.microsoft.com> wrote in message
> news:62833ACE-EC24-464B-A19E-AD0FEE340AB4@.microsoft.com...
>
>|||From Enterprise Manager:
1) Go to Management->SQL Server Agent->Jobs
2) Right-click and select New Job
3) Fill in the appropriate bits. such as steps and schedules.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
"GTN170777" <GTN170777@.discussions.microsoft.com> wrote in message
news:CE1E0AA5-EAA2-4562-BB07-1B1C27CE9861@.microsoft.com...
How do you do that?
"Mubashir Khan" wrote:

> Make a sql server task to run once a day. write the script into it to
> execute
> "GTN170777" <GTN170777@.discussions.microsoft.com> wrote in message
> news:62833ACE-EC24-464B-A19E-AD0FEE340AB4@.microsoft.com...
>
>

No comments:

Post a Comment