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 2008 Forums
 Transact-SQL (2008)
 function for multiple values

Author  Topic 

kiranmurali
Yak Posting Veteran

55 Posts

Posted - 2010-07-14 : 07:13:59
how to write a function to return muliple values and how to call that func in stored procedure in SQL SERVER 2008.




THANKS IN ADVANCE

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2010-07-14 : 08:19:05
[code]
CREATE FUNCTION dbo.udf_test
(
@Id INT = NULL
)
RETURNS @result TABLE ( EmployeeId INT, EmployeeName VARCHAR(256) )
AS
BEGIN
INSERT INTO @result
SELECT
employeeid,
EmpName, desgination

FROM
employeetable
where employeeid = @id

RETURN

END

create proc dbo.usp_testproc
(
@id int
) as
SET NOCOUNT ON
BEGIN

SELECT * FROM dbo.udf_test(@id)

END
SET NOCOUNT OFF

[/code]
Go to Top of Page
   

- Advertisement -