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-09-25 : 09:30:53
|
| Alex writes "Right now I am in the process of converting a FoxPro application over to Sql Server! (Loads of fun) The problem I keep running into, is that there is no way to call an IF...ELSE statement as integrated in a select for SQL server allowing the statement to be run on the fly. FoxPro does this by using an IIF statement. Ex:FoxPro--SELECT * FROM MyTABLE WHERE IIF(fieldname1 = True , return true _expression , return false _expression) ORDER BY fieldname3; This type of sntax allows the WHERE clause to be generated dynamically as the select retreives each record and determines the value of fieldname1 in that record to delegate which WHERE clause applies.So, if this was in SQL it should look something like thisSELECT * FROM MyTABLE WHERE IF(fieldname1 = True ) THEN return true _expression ELSE return false _expression END IF ORDER BY fieldname3;I need SQL to actually change the WHERE clause restrictions based on the value of each record as it's specific field is elvaluated in the condition clause. In other words, every time fieldname1's record contains a true value the WHERE restrictions for the select are altered accordingly (on the fly). Please Please help, if you can.Thanks,Alexaaversa@metro-data.com" |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2002-09-25 : 12:11:55
|
| IFF's in ACCESS are replaced in SQL by CASE statements....It may be reasonable to presume that something similiar happens for converted FOXPRO code.There are plenty of examples of (complicated) CASE statements on this site..."forum search" for "CASE" and see if you get lucky.... |
 |
|
|
|
|
|