How function can return table in sql server?

Whether functions will return table as parameter or not?

For this question answer will be Yes functions will return table as parameter by using table valued parameters.  

Generally SQL Server functions will return only one parameter value if we want to return multiple values from function then we need to send multiple values in table format by using table valued functions.

Sample function which return table as parameter

CREATE FUNCTION testmultiplevalues

(

@UserId INT

)

returns table as

return

(

Select * from UserInformation WHERE UserId=@userId

)

call this fn as::

SELECT * FROM dbo.testmultiplevalues(14)

 

http://pramadha.com/

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s