Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there any "decode" function available in Micorosoft SQL syntax? 1

Status
Not open for further replies.

rostik

Programmer
May 17, 2001
20
0
0
US
Hi everybody!
In Informix or Oracle there is a "decode" function. What it does is
converts some available values in the field and changes to
whatewer you ask. For examle:
SELECT employee_name, DECODE(employee_code, "A", "1", "B",
"2", "C", "3")
FROM emp_table
(It will change "A" value to 1, "B" to 2 and so on.)
Is there any "decode" function available in Micorosoft SQL syntax?

Thanks in advance,
:cool: Rostik
 
It sound like you want to use the "Update" query. Go to querys and create a new one. Then go to the menu bar and change the type to "Update Query".
 
Erik, I know that.
I need help with alternative to decode function! (read my question, please)
 
No Access does not have a DECODE function. You can probably create a work-around using the MID function. This along with the Len function should give you the position of the string you need. Also look into the InStr function.

Hope this helps. ljprodev@yahoo.com
ProDev, MS Access Applications B-)
 
Rostik,
There are several

IIF(Condition,True Result,False Result) <--these can be nested
Switch(Condition,True Result,Condition,True Result,Condition,True Result)
Choose(Oridnal#,result1,result2,resultN)

-Jim
 
Or write a custom function to do the decode for you.

Craig
 
Actually, I *did* read your post. I don't see you saying anywhere that you know about the update query, and I also don't see why the update query won't help you.
 
As has been said, there is no Decode() available. However you can write any custom function and call it from a query, so you can get equivalent functionality. In a query, you'd define a column as:

NewName:SomeFunction([arg1],[arg2],...)

The only requirement is that you must pass a field name for the function to execute for every row.

That would be closest to what your looking for.
Jim.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top