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 2000 Forums
 SQL Server Development (2000)
 how to do this using an stored procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-04-27 : 09:04:25
prabu writes "how to Create a stored procedure that would verify the date of a message in table. If the message is older than 30 days,
then it should change the status of the message field.How to get the current date, and how to do this above validation. This stored procedure should run everyday night.

can any one help me in this...


pls"

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2004-04-27 : 09:28:05
Without more information, I cannot detail the solution here, but I would think it used date functions.

Books Online: DATEDIFF or DATEADD and GETDATE()

CREATE PROC myProc

UPDATE myTable
SET myMessageStatus = 'Old'
WHERE DATEDIFF(dd, myMessageDate, GETDATE()) > 30

using DATEADD

WHERE myMessageDate < DATEADD(dd, -30, GETDATE())

Go to Top of Page
   

- Advertisement -