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.
| 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 @intselect @Result = casewhen bla then bla...endfrom TableA join TableB on ...etcreturn @Resultcan 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 intselect @Result = max( case when bla then bla ... end)from TableA join TableB on ...etc[/code]Be One with the OptimizerTG |
 |
|
|
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! |
 |
|
|
|
|
|