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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL question, DB limitation? 1

Status
Not open for further replies.

strantheman

Programmer
Mar 12, 2001
333
US
I know I should post this in the SQL forum but CF programmers generally have more trouble shooting knowledge with different DB software.

Im just trying to get a CASE statement to work. Im testing on my web based ISP (onviasites.com). They're running MS SQL server (probably 7) and CF 4.5. I've tried two methods, and the error is not specific, just says "syntax error or access violation"

Method 1)
--get text and type, output "this is type1" or "this is type2"
select
text
, "type" =
CASE
when TypeID = 1 then "this is type1"
when TypeID = 2 then "this is type2"
else "other"
END
from myTable

Method 2)
SELECT text,
CASE TypeID
WHEN = 1
THEN 'type 1'
ELSE 'other other other'
END
FROM myTable

Any SQL server saviors out there?

 
replace the double quotes by single quotes in side the case loop.

select
text
, "type" =
CASE
when TypeID = 1 then 'this is type1'
when TypeID = 2 then 'this is type2'
else "other"
END
from myTable


It worked for me
 
Thank you! Thank the lord for another set of eyes.

Worked great, now to get into the complicated part .. :-D

see ya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top