About Me

My photo
Mumbai, Maharastra, India
He has more than 7.6 years of experience in the software development. He has spent most of the times in web/desktop application development. He has sound knowledge in various database concepts. You can reach him at viki.keshari@gmail.com https://www.linkedin.com/in/vikrammahapatra/ https://twitter.com/VikramMahapatra http://www.facebook.com/viki.keshari

Search This Blog

Sunday, November 27, 2011

Function Returning Table in SQL Server

Give the return type as Table in Function signature then you can return the result of any select statement as a table to calling function.

Example: Here we create a function say 'fun_returning_tab' which is taking a parameter @pnr_no and returning table to the calling function.

Create function fun_returning_tab( @pnr_no varchar(7)) return table
as
Begin
return (select * from reservation where pnr_no = @pnr_no)
End

How to call this function:
select * from   fun_returning_tab(8161237)

enjoy coding...:)

Post Reference: Vikram Aristocratic Elfin Share