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 |
|
krish001
Yak Posting Veteran
61 Posts |
Posted - 2009-10-27 : 16:10:29
|
| how to write function which return multiple values?? |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-10-27 : 16:23:45
|
| You could create a table valued function or your could create a scalar (single value) function where the return value was a complex type. The type could be XML or an encoded string or even a binary value.If you can't figure it out from (Books Online t-sql reference CREATE FUNCTION) then post an example of what your starting values are and what you want to end up with.Be One with the OptimizerTG |
 |
|
|
krish001
Yak Posting Veteran
61 Posts |
Posted - 2009-10-27 : 16:27:53
|
quote: Originally posted by TG You could create a table valued function or your could create a scalar (single value) function where the return value was a complex type. The type could be XML or an encoded string or even a binary value.If you can't figure it out from (Books Online t-sql reference CREATE FUNCTION) then post an example of what your starting values are and what you want to end up with.Be One with the OptimizerTG
create function namedeclare @cnt intselect @Cnt=isnull(max(Datediff(day,TaskStartDate,TaskFinishDate)),0)from (select ProjectUID,TaskName,Min(TaskStartDate) as TaskStartDate from Msp_EpmTask_UserViewwhere TaskName = 'Audit Field Work'group by ProjectUID, TaskName) afwinner join(select ProjectUID, TaskName,TaskFinishDate from Msp_EpmTask_UserViewwhere TaskName = 'Final Report Circulation date')frcon afw.ProjectUID = frc.ProjectUID where afw.Projectuid in(select projectuid from msp_epmProject_Userview Where ProjectStartDate >= '01-01-2009' and ProjectFinishDate <='12-12-2009' and BU='wbpo' and [Audit Type]='fa'and [Status of Audit]='Completed' GROUP BY BU,[Audit Type],projectuid) group by afw.TaskStartDate,frc.TaskFinishDate,afw.ProjectUIDorder by TaskStartDate |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
|
|
|
|
|
|
|