Hi, I'm trying to write some code that automatically deletes all records that were posted over 183 days ago. The code needs to run continuosly, so far i've written the code below, which doesn't work, any ideas how to write the (query/Procedure?trigger???) correctly - CREATE PROCEDURE deletevacancy AS BEGIN DELETE VacancyID, VacancyEmployeeID, VacancyEmployerID, VacancyTitle, VacancyCategory, VacancyLocation, VacancyType, VacancyPaye, VacancyPayeType, VacancyStartDate, VacancyDatePosted, VacancyPostedFor, VacancyReference, VacancyDescription, VacancyDuration FROM [dbo].[Vacancy] WHERE VacancyDatePosted > DATEADD(DAY, 182, GETDATE()) END
WHERE VacancyDatePosted < DATEADD(DAY -182, GETDATE()) -- Michael Abair Programmer / Analyst Chicos FAS Inc. [quoted text, click to view] "GTN170777" <GTN170777@discussions.microsoft.com> wrote in message news:80D89C64-192F-4626-8A69-FA481C6AB10A@microsoft.com... > Hi, > > I'm trying to write some code that automatically deletes all records that > were posted over 183 days ago. The code needs to run continuosly, so far > i've > written the code below, which doesn't work, any ideas how to write the > (query/Procedure?trigger???) correctly - > > CREATE PROCEDURE deletevacancy > AS > BEGIN > DELETE VacancyID, > VacancyEmployeeID, > VacancyEmployerID, > VacancyTitle, > VacancyCategory, > VacancyLocation, > VacancyType, > VacancyPaye, > VacancyPayeType, > VacancyStartDate, > VacancyDatePosted, > VacancyPostedFor, > VacancyReference, > VacancyDescription, > VacancyDuration > FROM [dbo].[Vacancy] > WHERE VacancyDatePosted > DATEADD(DAY, 182, GETDATE()) > END > > Thank you
Thanks Michael, Is it a procedure that i need to write? and is the - CREATE PROCEDURE deletevacancy AS BEGIN correct? Thanks a lot [quoted text, click to view] "Michael Abair" wrote: > WHERE VacancyDatePosted < DATEADD(DAY -182, GETDATE()) > > -- > Michael Abair > Programmer / Analyst > Chicos FAS Inc. > > > "GTN170777" <GTN170777@discussions.microsoft.com> wrote in message > news:80D89C64-192F-4626-8A69-FA481C6AB10A@microsoft.com... > > Hi, > > > > I'm trying to write some code that automatically deletes all records that > > were posted over 183 days ago. The code needs to run continuosly, so far > > i've > > written the code below, which doesn't work, any ideas how to write the > > (query/Procedure?trigger???) correctly - > > > > CREATE PROCEDURE deletevacancy > > AS > > BEGIN > > DELETE VacancyID, > > VacancyEmployeeID, > > VacancyEmployerID, > > VacancyTitle, > > VacancyCategory, > > VacancyLocation, > > VacancyType, > > VacancyPaye, > > VacancyPayeType, > > VacancyStartDate, > > VacancyDatePosted, > > VacancyPostedFor, > > VacancyReference, > > VacancyDescription, > > VacancyDuration > > FROM [dbo].[Vacancy] > > WHERE VacancyDatePosted > DATEADD(DAY, 182, GETDATE()) > > END > > > > Thank you > >
Don't see what you're looking for? Try a search.
|