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
 General SQL Server Forums
 New to SQL Server Programming
 Help with the stored procedure

Author  Topic 

rds207
Posting Yak Master

198 Posts

Posted - 2010-06-16 : 12:55:16
Hi

I am trying to create a stored procedure which generates an email when the max (datetime) field in my table dw_t_jobdata is not euqual to today's date ,starttime is the datetime field in table dw_t_jobdata , so i need to write a syntax something like

if the dw_t_jobdata.starttime is not equal to getdate() generate an email

Could anybody please help me writing the if clause here ?Or any suggestions in achieving this other than using an stored procedure ?

Thanks in advance



Here is my code for generating an email :

CREATE PROCEDURE [dbo].[Proc_Job_Monitor]
AS
BEGIN

EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'qctreport',
@recipients = '****@*****.com',
@subject=N'ALERT :: Job Hanged ...' ;
END

GO



Sachin.Nand

2937 Posts

Posted - 2010-06-16 : 14:05:09
You can write something like this

if((select max(dateadd(dd,datediff(dd,0,yourdate),0))from yourtable)<> dateadd(dd,datediff(dd,0,GETDATE()),0))
Dosomething
Else
DoSomethingElse



Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page
   

- Advertisement -