Unanswered: Time/date In A Scheduled Stored Procedure
SQL newbie here, and thanks for any help you may able to provide.
My intention is to schedule/execute a stored procedure every morning at 12:00 a.m. that deletes all records with a column value of the day before. I.E., one of my Table columns is named POSTDAY, and could have values such as Sunday, Monday, Tuesday, etc, and on Tuesday morning, I'd like to DELETE all records with a POSTDAY value of Monday.
I think I can do this by creating and scheduling 7 different stored procedures (each with the actual DayName), but was wondering if it's possible to just have 1 accomplish the same thing, and without having to pass any parameters to it.
And I'm kind of suprised POSTDAY = DATENAME(weekday, GETDATE()) worked for you. Is POSTDAY a text field, or is it datetime? And anyway, your syntax is going to returne TODAY's datename, and I thought you wanted to delete YESTERDAY's data...
...so I still think:
where datediff(day, YourDateValue, getdate()) = 1
...is the way to go.
If it's not practically useful, then it's practically useless.