IIF Function simulation in update queries?? 
Author Message
 IIF Function simulation in update queries??

I am transferring some data from an AS/400 database to a SQLServer
database. Some of the fields on the AS/400 need to be transformed, eg. on
the AS/400  the field STATUS may be "A", "I" or null while in SQLServer
Status is either "A" or "I".  In Access this would be simple using an IIF
function, eg. Status = IIF(STATUS = "I","I","A") which return A if STATUS
is not an I.

How is this type of thing done in SQL Server?  I am guessing that my
updates would run much faster if I can dump the data from the AS/400 into a
temporary table on SQLServer and then run an UPDATE on SQLServer rather
than use Access as an intermediary.



Fri, 17 Dec 1999 03:00:00 GMT
 IIF Function simulation in update queries??

That does what I was after. Thank you


Quote:
>I'm not really familiar with the IIF function here. Do you mean, if
STATUS
>is I, set STATUS to I, otherwise set STATUS to A? If so, you can use the
>CASE Expression in SQL Server:

>update mytable
>set status = case status
> when 'I' then 'I'
> else 'A'
>         end  -- of case

>HTH
>--
>Kalen Delaney
>MCSE, SQL Server MCT, MVP
>For SQL Server Technical Seminars: Check out www.sqlinc.com



>> I am transferring some data from an AS/400 database to a SQLServer
>> database. Some of the fields on the AS/400 need to be transformed, eg.
on
>> the AS/400  the field STATUS may be "A", "I" or null while in SQLServer
>> Status is either "A" or "I".  In Access this would be simple using an
IIF
>> function, eg. Status = IIF(STATUS = "I","I","A") which return A if
STATUS
>> is not an I.

>> How is this type of thing done in SQL Server?  I am guessing that my
>> updates would run much faster if I can dump the data from the AS/400
into
>a
>> temporary table on SQLServer and then run an UPDATE on SQLServer rather
>> than use Access as an intermediary.



Sun, 19 Dec 1999 03:00:00 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. IIF function in sql statement equal to what is used in Access-Query

2. IIF function in query

3. Using IIF Function in Sql Server 2000 Query ?

4. IIf function for this Microsoft Access query?

5. IIF Function not recognized as valid function

6. History, Update, Simulation

7. IIF function

8. TSQL equivalent of IIF function

9. IIf Function ???

10. IIF function on SQL Server?

11. iif function in views

12. how can I use IIF function in sqlserver


 
Powered by phpBB® Forum Software