how to create table valued function in sql server .

Total Post:341

 1001  View(s)
Rate this:
Can anyone please help me how to solve this problem.
  1. Post:280

    Re: how to create table valued function in sql server .

    --let’s start querying create a table.

     CREATE TABLE ProductMasters(

           ProductId int IDENTITY(1,1) primary key,

           ProductName nvarchar(max) ,

           Price decimal(18, 2)  ,

           CategoryId int  


     --We will now create a table valued function, which returns the total of price filtered by a given category . Write the following code in your query pad –

     Create function fnGetProductMasters


     @categoryId int


    returns table

    return ( select * from ProductMasters where CategoryId=@categoryId)

    --The above function returns an table. To test this function, we will write some code as shown below – select * from dbo.fnGetProductMasters(2) 



      Modified On Apr-10-2018 04:48:54 AM



Enter your email address here always to be updated. We promise not to spam!