jasonhuibers
Programmer
I want to INNER JOIN a table only if a parameter condition is met. I am trying to do something like below. How can I do this?
IF @EnteredDate >= CONVERT(CHAR, GetDate(), 101)
INNER JOIN Names WITH (NOLOCK) ON Emp.Code = Names.Code
ELSE
INNER JOIN tmp_Names WITH (NOLOCK) ON EMP.Code = Names.Code
IF @EnteredDate >= CONVERT(CHAR, GetDate(), 101)
INNER JOIN Names WITH (NOLOCK) ON Emp.Code = Names.Code
ELSE
INNER JOIN tmp_Names WITH (NOLOCK) ON EMP.Code = Names.Code