--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 fnGetUsernamewithProductMasters
(
@categoryId int
)
returns @customerwithproduct
table(
UserName varchar(100),
ProductName varchar(100),
Price decimal(10,2)
)
as
begin
insert @customerwithproduct
selectb.UserName, a.ProductName,a.Pricefrom ProductMasters as a inner join UserMasters as b on a.Userid=b.Userid where CategoryId=@categoryId
return
end
--The above function returns an table.
To test this function, we will write some code as shown below –
select*fromdbo.fnGetUsernamewithProductMasters(1)
Result
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Can you answer this question?
Write Answer1 Answers