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 2005 Forums
 Transact-SQL (2005)
 plz give example??

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 Optimizer
TG
Go to Top of Page

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 Optimizer
TG





create function name
declare @cnt int
select @Cnt=isnull(max(Datediff(day,TaskStartDate,TaskFinishDate)),0)
from (select ProjectUID,TaskName,Min(TaskStartDate) as TaskStartDate
from Msp_EpmTask_UserView
where TaskName = 'Audit Field Work'
group by ProjectUID, TaskName) afw
inner join
(select ProjectUID, TaskName,TaskFinishDate from Msp_EpmTask_UserView
where TaskName = 'Final Report Circulation date')frc
on 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.ProjectUID
order by TaskStartDate
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-10-27 : 16:38:37
Thanks for posting that statement - it was very entertaining. But what does that have to do with your question?

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -