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
 SQL Server Development (2000)
 Function returning more than one row

Author  Topic 

cokebaby666
Starting Member

7 Posts

Posted - 2005-03-10 : 21:49:50
OK, got another one for you =)
I have a UDF that should be returning a scalar value but is on occasion trying to return more than one row. The code is as per my previous post. I want to use something like MAX to return the highest of these values, but where do I put it if my variable assignement is like this:

declare @Result @int
select @Result = case
when bla then bla
...
end
from TableA join TableB on ...etc

return @Result

can I tell it to just give me the Max value or is the error happening before I get to trying to shove 2+ rows into an int?
Thanks again people!

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-03-10 : 22:07:01
[code]
declare @Result int
select @Result = max(
case
when bla then bla
...
end)
from TableA
join TableB on ...etc
[/code]

Be One with the Optimizer
TG
Go to Top of Page

cokebaby666
Starting Member

7 Posts

Posted - 2005-03-11 : 05:41:31
thanks - works in isolation but not for some reason within another function: it's probably something stupid somewhere else. I did try that before but had only tested it when within another function.
Cheers!
Go to Top of Page
   

- Advertisement -