Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Programming / SQL / July 2008

Tip: Looking for answers? Try searching our database.

Select Case Statement

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pvong - 18 Jul 2008 20:16 GMT
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.
Plamen Ratchev - 18 Jul 2008 20:16 GMT
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
Steve Kass - 18 Jul 2008 20:17 GMT
You forgot to end the CASE expression with the keyword END.

CASE ...
END

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

>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
[quoted text clipped - 8 lines]
>
>  
pvong - 18 Jul 2008 20:20 GMT
Forgot to paste the error.  This is it.

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

> 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
[quoted text clipped - 6 lines]
>
> This is the error message.
SQL Menace - 18 Jul 2008 20:20 GMT
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

> 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
[quoted text clipped - 6 lines]
>
> This is the error message.
pvong - 18 Jul 2008 20:27 GMT
Thanks everyone!!!

> 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
[quoted text clipped - 6 lines]
>
> This is the error message.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.