Unix Technical Forum

DECODE in SQL Server?"

This is a discussion on DECODE in SQL Server?" within the SQL Server forums, part of the Microsoft SQL Server category; --> "DHatheway" <dlhatheway@mmm.com.nospam> wrote in message news:ck18oi$m31$1@tuvok3.mmm.com... > "Daniel Morgan" <damorgan@x.washington.edu> wrote in message > news:1096932539.547042@yasure... > > N wrote: ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 02-29-2008, 05:28 AM
-P-
 
Posts: n/a
Default Re: DECODE in SQL Server?"

"DHatheway" <dlhatheway@mmm.com.nospam> wrote in message news:ck18oi$m31$1@tuvok3.mmm.com...
> "Daniel Morgan" <damorgan@x.washington.edu> wrote in message
> news:1096932539.547042@yasure...
> > N wrote:
> > > What is the function in SQL that works like DECODE in Oracle?"
> > > Thanks,
> > >
> > > N

> >
> > As you know CASE is not the same as DECODE ... but SQL Server hsa no
> > functionality equivalent to DECODE so you will have to adapt CASE to
> > do the job.
> > --
> > Daniel A. Morgan
> > University of Washington
> > damorgan@x.washington.edu
> > (replace 'x' with 'u' to respond)
> >

>
> OK, then, what does DECODE do?
>



DECODE( exp, search1, result1 [,search2, result2]... ) is semantically equivalent to:

CASE exp
when search1 then result1
when search2 then result2
... END

The difference between CASE and DECODE is that CASE also allows the form:
CASE
WHEN exp1 = search1 then result1
WHEN exp2 = search2 then result2
... END

DECODE can't do that.

--
Paul Horan[TeamSybase]

VCI Springfield, Mass
www.vcisolutions.com



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:35 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com