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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-03-15 : 10:00:14
|
| Dani writes "Hello!I get an error with the following part of code of an Stored Procedure:...case when @codPer is null then '1,2' else numendIN case when @codPer is null then '1,2' else (select num from T1 where codPer=@codPer)end and...The error that I get is Error 156: Incorrect syntax near the keyword 'case'. Incorrect syntax near the keyword 'end'.Replacing the IN with the equal operator it works but fails when I try to execute the stored procedure.I don't know If it's impossible to do. Before, I have a condition like ...num=@codPer... but it doesn't work because some results have the value NULL in the column num, and with this condition the Stored Procedure doesn't returns the results with the NULL value in the column num.Please help me about this problem!Thanks!Dani." |
|
|
setbasedisthetruepath
Used SQL Salesman
992 Posts |
Posted - 2002-03-15 : 13:31:12
|
| You could rewrite the IN clause as follows:IN ( select num from T1 where codPer=@codPer and @codPer is not null union select '1' where @codPer is null union select '2' where @codPer is null ) |
 |
|
|
|
|
|