From: pvong on
Can someone tell me why this simple Select Case is wrong. This is my first
attempt at this. I'm doing this on SQL 2005. Works fine until I try to do
a CASE.

SELECT Case Limit
When 'MKT' THEN 'MKT'
ELSE 'LMT'
FROM MoxyOrders

This is the error message.


From: pvong on
Forgot to paste the error. This is it.


Missing or incomplete SELECT clause.
Unable to parse query text.


"pvong" <phillip*at*yahoo*dot*com> wrote in message
news:%23HcU0oQ6IHA.4112(a)TK2MSFTNGP05.phx.gbl...
> Can someone tell me why this simple Select Case is wrong. This is my
> first attempt at this. I'm doing this on SQL 2005. Works fine until I
> try to do a CASE.
>
> SELECT Case Limit
> When 'MKT' THEN 'MKT'
> ELSE 'LMT'
> FROM MoxyOrders
>
> This is the error message.
>
>


From: Steve Kass on
You forgot to end the CASE expression with the keyword END.

CASE ...
END

Steve Kass
Drew University
http://www.stevekass.com

pvong wrote:

>Can someone tell me why this simple Select Case is wrong. This is my first
>attempt at this. I'm doing this on SQL 2005. Works fine until I try to do
>a CASE.
>
>SELECT Case Limit
>When 'MKT' THEN 'MKT'
>ELSE 'LMT'
>FROM MoxyOrders
>
>This is the error message.
>
>
>
>
From: Plamen Ratchev on
You are missing the END part of CASE:

SELECT CASE Limit
WHEN 'MKT' THEN 'MKT'
ELSE 'LMT'
END
FROM MoxyOrders

HTH,

Plamen Ratchev
http://www.SQLStudio.com
From: SQL Menace on
You need to add END

SELECT Case Limit
When 'MKT' THEN 'MKT'
ELSE 'LMT' END AS Limit
FROM MoxyOrders


Denis The SQL Menace
http://www.lessthandot.com/
http://sqlservercode.blogspot.com
http://sqlblog.com/blogs/denis_gobo/default.aspx


On Jul 18, 3:16 pm, "pvong" <phillip*at*yahoo*dot*com> wrote:
> Can someone tell me why this simple Select Case is wrong.  This is my first
> attempt at this.  I'm doing this on SQL 2005.  Works fine until I try to do
> a CASE.
>
> SELECT     Case Limit
> When 'MKT' THEN 'MKT'
> ELSE 'LMT'
> FROM         MoxyOrders
>
> This is the error message.

 |  Next  |  Last
Pages: 1 2
Prev: Stored Proc problem
Next: Select Case Statement Part 2