• Basically tblevents has a field name sstatus and I am capturing oldstatus and then in the update statement if the status changes to newstatus and then comparing them

    USE [databasename]

    GO

    /****** Object: StoredProcedure [dbo].[sp_Mail_UpdateEvents] Script Date: 07/15/2013 14:36:00 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    Create PROCEDURE [dbo].[sp_MailUpdateEvents]

    AS

    SET nocount ON

    BEGIN TRY

    declare @EventId int

    declare @EventName nvarchar(500)

    declare @EventDate datetime

    declare @sstatus nvarchar(50)

    declare @oldstatus nvarchar(50)

    declare @newstatus nvarchar(50)

    select @oldstatus=sstatus from tblEvents where EventID=@Eventid

    --create TABLE #StatusChanges ( Status1 Varchar(20),Status2 VARCHAR(20));

    UPDATE [tblEvents]

    SET [EventName] = @EventName, [EventDate] = @EventDate,

    [sstatus]= @sstatus, [Updateuser]=@Updateuser,UpdateDate=GetDate()

    WHERE [EventID] = @Eventid

    select @newstatus=sstatus from tblEvents where EventID=@eventid

    --if oldstatus doesnot matches with newstatus then execute rest

    if @oldstatus <> @newstatus