November 5, 2003 at 1:26 pm
I'm presently converting SQL statements from Microsoft Access to SQL Server. In Access it is possible to use non-ansi function calls to VB functions; such as InStr, Mid, and so forth. Most of these have an equivalent T-SQL capability but one, in particular, has us searching for a solution. The Access SQL uses IIF in a query to select various states of information.
IIF(Statement, Is True, Is False)
If the statement is true then you select the first item after the statement, else you select the second.
I would appreciate any solutions or work arounds to solving this problem. Could a user function be developed and called from within the SQL to return the correct response?
CREATE FUNCTION IIF
(
@Expression nvarchar(255),
@TruePart nvarchar(255),
@FalsePart nvarchar (255),
@Response nvarchar(255) OUT
)
November 5, 2003 at 2:04 pm
Cannot you use CASE?
Eg.
SELECT CASE WHEN <condition> THEN <result1> ELSE <result2> END
Cheers,
- Mark
Cheers,
- Mark
November 5, 2003 at 3:06 pm
Thanks Mark,
I believe that's just what I could use. It's the obvious solution that I should have recognized; -- but didn't.
Steve
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply