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 |
|
JeffS23
Posting Yak Master
212 Posts |
Posted - 2007-12-27 : 12:42:22
|
| I need to execute a simple Case Statement. Strangely, if I include a comparison operator I receive an error message showing a syntax error (Message 102, Level 15). But the same statement without the operator works jsut fine. Works:Select LastName, Group = Case AgeWhen 15 Then '1'When 18 Then '2'Else '20'From tblAgeGroupEndDoes Not Work:Select LastName, Group = Case AgeWhen <15 Then '1'When <18 Then '2'Else '20'From tblAgeGroupEndAlso, I noticed that this does not work in any other combination of the "When.." clause.Any help is appreciated.Thanks |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-12-27 : 12:43:22
|
| Select LastName, Group = Case When Age<15 Then '1'When Age<18 Then '2'Else '20'From tblAgeGroupEnd==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-28 : 01:38:20
|
| Thats why I suggested to always use CASE WHEN Expression instead of CASE Expression WHENMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|