Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jonesboy21
Starting Member
2 Posts |
Posted - 2006-10-31 : 09:15:21
|
Any ideans on how or if I can actually use a case statment in this respect:INNER JOIN dbo.ufnTopEmpIdentification(null,@EDICreateDate) ei on ei.personid = p.personid AND ei.EmpCatId IN (CASE WHEN @PRCycleTypeCode IN ('NB','SB') THEN ('1') ELSE ('2,3') END )Throws this error:Syntax error converting the varchar value '2,3' to a column of data type int.I did try using integers instead of characters, i.e.(CASE WHEN @PRCycleTypeCode IN ('NB','SB') THEN (1) ELSE (2,3) END ) |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-31 : 09:17:37
|
The ELSE part can only return 1 value.Peter LarssonHelsingborg, Sweden |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-31 : 09:20:43
|
[code]INNER JOIN dbo.ufnTopEmpIdentification(null,@EDICreateDate) ei on ei.personid = p.personidWHERE CASE WHEN @PRCycleTypeCode IN ('NB','SB') AND ei.EmpCatId IN (1) THEN 1 WHEN @PRCycleTypeCode NOT IN ('NB','SB') AND ei.EmpCatId IN (2, 3) THEN 1 ELSE 0 END = 1[/code]Peter LarssonHelsingborg, Sweden |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-31 : 09:58:58
|
or use simple if elseIF @PRCycleTypeCode IN ('NB','SB') SELECT..... INNER JOIN dbo.ufnTopEmpIdentification(null,@EDICreateDate) ei on ei.personid = p.personid AND ei.EmpCatId IN (1)ELSE SELECT..... INNER JOIN dbo.ufnTopEmpIdentification(null,@EDICreateDate) ei on ei.personid = p.personid AND ei.EmpCatId IN (2,3) MadhivananFailing to plan is Planning to fail |
 |
|
jonesboy21
Starting Member
2 Posts |
Posted - 2006-10-31 : 13:36:56
|
Thank you Peso, your solution worked perfectly! I appreciate your help |
 |
|
|
|
|
|
|