I want to apply a where condition with the following, is it possible or it has to be conmpletely modified to a dynamic SQL?:If Modulename='SU' then 'join Tab_Submittals su on Modulerecordid = su.suid and su.deleted = '0'If Modulename='RF' then 'join Tab_RFI RF on Modulerecordid = rf.rfid and RF.deleted = '0'If Modulename='RM' then 'join Tab_RM RM on Modulerecordid = RM.RMID and RM.deleted = '0'-- This STP returns the mytasks actionitems and reviewers listALTER PROCEDURE [dbo].[USP_GetMyAlerts]( @userid int)ASDECLARE @ErrorCode intSET NOCOUNT ONSELECT @ErrorCode = @@ErrorIF @ErrorCode = 0BEGIN Select actionid, 'ACT' as Type, actiondescription, rtrim(isnull(ModuleName,'')) as ModuleName,ModuleRecordID,[days] = CASE WHEN duedate < GetDate()THEN -1 * DATEDIFF(Day, duedate, GetDate())ELSE CONVERT(varchar(20), DATEDIFF(Day, GetDate(), duedate))ENDFROM Tab_CCSNETACTIONS where AssignedTo = @userid and CompleteDate IS NULLORDER BY days ASCSELECT @ErrorCode = @@ErrorENDSET NOCOUNT OFFRETURN @ErrorCode
Thank you very much for the helpful information.