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 |
lcsgeek
Starting Member
38 Posts |
Posted - 2013-02-08 : 12:39:47
|
Can someone help me with this syntax? Thanks muchSELECT column1 , column2 , IF @Subject = 'Mathematics' OR @Subject = 'Reading' BEGIN 'Applicable Value' END ELSE BEGIN 'N/A' END AS brSpringTargetFROM ... I want to check the value of the @Subject paramter and act accordingly. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-02-08 : 12:45:42
|
Use a case expression instead of the IF clause. IF is a control flow construct, which cannot be used in this contextSELECT column1 , column2 , CASE WHEN @Subject = 'Mathematics' OR @Subject = 'Reading' THEN 'Applicable Value' ELSE 'N/A' END brSpringTargetFROM ... |
|
|
lcsgeek
Starting Member
38 Posts |
Posted - 2013-02-08 : 12:59:25
|
Thank you James |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-02-08 : 12:59:47
|
You are very welcome - glad to help. |
|
|
|
|
|