December 13, 2008 at 4:15 pm
Sorry if this is a silly question but I need some help.
I need to create a SQL Server 2000 view with this format:
SELECT
case when failed = 'N' then
(select * from aaa)
else
(select * from bbb)
end
FROM
dimstatus
The command succeed but when I try to execute I get this message:
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
I also tried to create it with an IF statement, but I figured out that the IF is not allowed, can you please help me?
Thanks SO much in advance,
Joe.
December 14, 2008 at 9:56 am
what does the structure of "aaa" and "bbb" look like? Instead of your select * you need to select the one value you want. if you think about what the case statement is trying to achieve, your looking for one value, whereas your putting a * in which it cant return. You will also need to put a where clause in unless your table only has one row.
It may be easier describing your full problem as i dont think a case statement will be the best method.
December 14, 2008 at 10:26 am
Same question reported twice!
http://www.sqlservercentral.com/Forums/Topic619170-169-1.aspx
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply