Hi. I'm a sql newbie, I use mssql2005
I like to do join Action depnding on input parameter.
CREATE PROCEDURE SelectPeriodicLargeCategoryData
@CATEGORY_LEVEL CHAR(1),
@CATEGORY_CODE VARCHAR(9)
AS
...
JOIN CATEGORY_AD_SYS CAS WITH(NOLOCK)
ON CA.CATEGORY_ID = [[[[[ HERE ]]]]
above the sql.
if @CATEGORY_LEVEL = 'L'
then I like to join on CAS.LCATEGORY
else if @CATEGORY_LEVEL = 'M'
then I like to join on CAS.MCATEGORY
else if @CATEGORY_LEVEL = 'S'
then I like to join on CAS.SCATEGORY
...
how can I do this?