I have this Stored Procedure below. The IF/ELSE examples that I could find in MSDN and so forth do not have IF/ELSE capabilities on the "SET" Parameter.
BEGIN
UPDATE c_section_status
-- put in if else statement here to update page has changed or not.
SET status_ID = @status_id,
status_date = GETDATE(),
page_has_not_changed = @page_has_not_changed
/*------------------------------------------------------------------*/
-- log data to history table
OUTPUT INSERTED.cppsa_ID,INSERTED.menuitem_ID
,INSERTED.status_ID,
INSERTED.page_has_not_changed,
INSERTED.status_date
,@user,GETDATE(),0
INTO c_section_status_HIST
/*------------------------------------------------------------------*/
WHERE cppsa_id = @cppsa_id
and menuitem_id = @menuitem_id
END
So I want to Set the status_date = GETDATE() only if the page has changed. If the @page_has_not_changed is equal to 1 Then I want to keep the old status_date and not update it.
Is this possible?