sorry don't have time to delve deeper but i would do something like this....
declare a dateColumn variable...
then "set" the name based on @ApplyDtRangeTo..
and then have 2 queries based on "@StartDt & @EndDt"...
declare @ColumnDt varchar(20)
if @ApplyDtRange = 'UD'
set @ColumnDt = 'sr.UpdatedDt'
else
set @ColumnDt = 'sr.CreatedDt'
IF @StartDt IS NOT NULL AND @EndDt IS NOT NULL
BEGIN
process....using AND (@ColumnDt BETWEEN @StartDt AND @EndDt)
RETURN
END
IF @StartDt IS NOT NULL
BEGIN
process...using AND (@ColumnDt >= @StartDt)
END
**ASCII stupid question, get a stupid ANSI !!!**