Home All Groups Group Topic Archive Search About

Any function in SQL Server similar to decode function in oracle ?

Author
21 Jul 2006 12:26 PM
Amit20
Hi,

Is there any function in SQL Server similar to decode function in oracle ?

Thanks,
Amit

Author
21 Jul 2006 12:35 PM
Omnibuzz
I think it can be handled with CASE expressions.
--
-Omnibuzz (The SQL GC)

http://omnibuzz-sql.blogspot.com/



Show quote
"Amit20" wrote:

> Hi,
>
> Is there any function in SQL Server similar to decode function in oracle ?
>
> Thanks,
> Amit
Author
21 Jul 2006 12:35 PM
Dan Guzman
You can use a CASE expression (ANSI-standard).  See the Books Online for
details.  An example:

SELECT
    CASE Status
        WHEN 'A' THEN 'Active'
        WHEN 'I' THEN 'Inactive'
        ELSE ''Unknown'
    END AS Status
FROM dbo.MyTable

--
Hope this helps.

Dan Guzman
SQL Server MVP

Show quote
"Amit20" <Ami***@discussions.microsoft.com> wrote in message
news:6AB5BE13-5089-4800-98EF-E780358A9E3A@microsoft.com...
> Hi,
>
> Is there any function in SQL Server similar to decode function in oracle ?
>
> Thanks,
> Amit
Author
22 Jul 2006 3:39 PM
--CELKO--
>> Is there any function in SQL Server similar to decode function in Oracle ? <<

CASE expression, same as you now have in Oracle.

AddThis Social Bookmark Button