Reputation: 988
How to use the case statement in views...
When I try to execute the case statement, it is giving warning message and showing the output, but when I try to save the views it is giving no output column specified errors
Query
Select
emp_code,
case
when emp_name = 'a' then 'Apple'
else 'dummy'
end as emp_name
from table1
There is any other option is available instead of case.
Need query help
Upvotes: 1
Views: 120
Reputation: 755491
I don't think you can name your new "case" computed column the same (emp_name
) as a column that already exists in the table - try using some other name!
SELECT
emp_code,
CASE
WHEN emp_name = 'a' THEN 'Apple'
ELSE 'dummy'
END AS new_emp_name
FROM dbo.table1
Upvotes: 1