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 |
|
mdhingra01
Posting Yak Master
179 Posts |
Posted - 2004-03-04 : 16:34:41
|
| I am trying to convert foxpro code to SQL Server, and ther is a bit of code I am having trouble with. Hope someone can help...Thankscase colltmp.SS_ACTIV='13'if colltmp.FUNCTION = '50' .or. colltmp.function='60'replace colltmp.program with 'DE'else if inlist(colltmp.function,'00','01','02','03','04','05','07','08','09','12','13','30','41') replace colltmp.program with 'CI' endifendif |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-03-04 : 16:41:36
|
| CASE statements go like this:CASE WHEN Column1 = 1 THEN 2WHEN Column2 = 4 THEN 3ENDI don't know what your CASE statement is currently doing, so I can't convert it. But maybe something like this:case colltmp.FUNCTION IN ('50','60') THEN colltmp.program = 'DE'WHEN inlist IN (colltmp.function,'00','01','02','03','04','05','07','08','09','12','13','30','41') THEN colltmp.program = 'CI'ENDWHERE colltmp.SS_ACTIV='13'Look up CASE in SQL Server Books Online for syntax.Tara |
 |
|
|
mdhingra01
Posting Yak Master
179 Posts |
Posted - 2004-03-04 : 16:45:12
|
| Thanks Tara...I was curious to know how to integrate an If statement into a case in SQL, is that possible?Thanks |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-03-04 : 16:46:27
|
| No it is not. You can run IFs but not within a SELECT statement.IF @Var1 = 2PRINT 'Do something'ELSEPRINT 'Do something else'Tara |
 |
|
|
mdhingra01
Posting Yak Master
179 Posts |
Posted - 2004-03-04 : 16:49:33
|
| Tara: Is it posible to use IIF in a case or should I consider embedding case in one other? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-03-04 : 16:50:59
|
| IIF doesn't exist in SQL Server. I'm not sure if you can embed multiple CASE statements in a query.Tara |
 |
|
|
mdhingra01
Posting Yak Master
179 Posts |
Posted - 2004-03-04 : 16:52:46
|
| Thanks for all your help Tara. |
 |
|
|
|
|
|
|
|