Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 T-SQL equivalent to the CASE statement

Author  Topic 

Ledell
SQL NASCAR Parsing Chick

107 Posts

Posted - 2004-10-13 : 13:51:16
I tried using a CASE statement when createing a view and SQL Server wouldn't let me. Does anyone know an alternative method to doing that?

Thanks.


*************************
Got some code from Rob. Can anyone help?

Kristen
Test

22859 Posts

Posted - 2004-10-13 : 13:55:18
CASE should be fine, can you post the statement you were trying to run please?

Kristen
Go to Top of Page

Ledell
SQL NASCAR Parsing Chick

107 Posts

Posted - 2004-10-13 : 13:58:03
SELECT CASE
WHEN f.FC_CONDITION_NO IN (1, 101, 3, 103, 7) THEN 'Activate Then Deactivate'
WHEN f.FC_CONDITION_NO IN (5, 105, 9, 6, 106, 10) THEN 'Activate Then Deactivate for FD_NP'
WHEN f.FC_CONDITION_NO IN (2, 102, 4, 104, 8) THEN 'Deactivate Then Activate'
ELSE 'UNKNOWN' END AS ACT_DEACT,
f.fc_act_date, f.fc_deact_date, i.rel_act_date, i.rel_end_date
FROM false_churn.dbo.vfc_detail f LEFT JOIN false_churn.dbo.vrel_info i ON f.rel_nar_id = i.rel_nar_id

The error message I get is...
"The Query Designer does not support the CASE SQL construct."

*************************
Got some code from Rob. Can anyone help?
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-10-13 : 14:09:34
the problem is:

The Query Designer does not support the CASE SQL construct.


Don't use the query designer if you need to use CASE. Never understood why it doesn't support CASE, but either way, you are better off learning how to use Query Analyzer.


- Jeff
Go to Top of Page

Ledell
SQL NASCAR Parsing Chick

107 Posts

Posted - 2004-10-13 : 14:50:57
I usually do use QA, but I don't know how to create a view except in EM.

*************************
Got some code from Rob. Can anyone help?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-10-13 : 15:58:13
To create a view in QA, just write up your select statement, then add this:

CREATE VIEW MyView
AS

<YourQueryGoesHere>

Tara
Go to Top of Page
   

- Advertisement -