The View does not support Case Structure (1 Viewer)

accessman2

Registered User.
Local time
Yesterday, 23:43
Joined
Sep 15, 2005
Messages
335
SELECT Date, [Check] = CASE WHEN [Elec] = 'A' THEN 'T' ELSE 'Exe' END
FROM Employees

The View query does not support Case statement. Whereas Query Analyzer support it. In View, how can I make if statement over there?
 

pdx_man

Just trying to help
Local time
Yesterday, 23:43
Joined
Jan 23, 2001
Messages
1,347
This works fine:
Code:
use Northwind
GO

Create View NorthTemp AS
SELECT e.LastName, [Check] = CASE WHEN e.Region = 'WA' THEN 'T' ELSE 'Exe' END
FROM northwind.dbo.Employees e 
GO

select * from northwind.dbo.NorthTemp

GO
drop view NorthTemp
 

tehNellie

Registered User.
Local time
Today, 07:43
Joined
Apr 3, 2007
Messages
751
I've noticed a couple of instances where the View designer objects to things such as linked servers that will work just fine in Query Analyser. I can only suggest designing the View using the view designer if you want to and then using Query Analyser to actually create or amend the view.
 

jknow

New member
Local time
Today, 01:43
Joined
Oct 23, 2007
Messages
9
I have used CASE statements in many views.
Will this not work?
SELECT Date, CASE WHEN [Elec] = 'A' THEN 'T' ELSE 'Exe' END as [Check]
FROM Employees
 

pdx_man

Just trying to help
Local time
Yesterday, 23:43
Joined
Jan 23, 2001
Messages
1,347
It will ... there is something else going on here, but Accessman2 never follows up with the results of what he gleans from here. :(
 

jknow

New member
Local time
Today, 01:43
Joined
Oct 23, 2007
Messages
9
I'm sorry to hear that. I like to be able to see what works and what doesn't so that everyone can benefit.
 

pdx_man

Just trying to help
Local time
Yesterday, 23:43
Joined
Jan 23, 2001
Messages
1,347
Yeah, I do too. It is the reason Accessman2 has red jello (reputation). He doesn't play nice. :D
 

Users who are viewing this thread

Top Bottom