How to return multiple values from a function in sql server 2012?


In this post, we will discuss how to return multiple values from an SQL server function in SQL server 2012. Here my requirement is I want to return multiple values through function.
You can also check:
In this case, we have to define a Table-valued function. Below is the syntax.
ALTER function [dbo].[fnGetTags]
(
@DiscussionID BigInt
)
RETURNS TABLE
AS
RETURN (SELECT TagID,TagName FROM Tags WHERE TAGID in (Select Top 1 TagID from DiscussionTags where DiscussionID= @DiscussionID))
To call this function you can use like below:
SELECT * FROM [dbo].[fnGetTags](1)
Hope this will be helpful.

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →

Leave a Reply