June 8, 2005 at 9:41 am
hiya.. how can you use case statements that return more than 1 value?
eg:
SELECT CASE WHEN x = 1
THEN (SELECT dates FROM Alldates
WHERE Y)
ELSE (SELECT dates FROM Alldates
WHERE Z)
END
cheers!
June 8, 2005 at 9:47 am
You can't, you make 2 different statements, or you move the case to the where condition :
Select * from dbo.AllDates where 1 = case when X = 1 and Y then 1
when X = 2 and Z Then 1
else 0
end
You might also test which version of the proc is the fastest (different statements or the case)
June 9, 2005 at 1:37 am
Read BOL closely. The T-SQL CASE expression is not like CASE in other programming languages. But it's certainly one of the most powerful tools in SQL.
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
June 9, 2005 at 9:28 am
I have to add that it's the most powerfull tool, if the programmer can figure out all the possible uses.
June 9, 2005 at 1:29 pm
Why did I know, that you would comment on this?
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
June 9, 2005 at 1:30 pm
Because you didn't know... you assumed.
Now you know .
June 9, 2005 at 1:52 pm
It's not all that hard to guess, assume, know.. call it whatever you like, since you comment on each and everything currently.
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
June 9, 2005 at 1:56 pm
It's not true...
I didn't comment this post today : http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=7&messageid=189223
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply