Friday, December 26, 2014

how pass parameter to function

Hi Tushar,


Your requirement is not clear to me. Please try to explain bit more.


Below is just an example of Table Valued Function.

I pass the Category and I get the products of that category.



CREATE FUNCTION ufn_GetProducts (@Category)
RETURNS TABLE
AS
RETURN (
SELECT ProductID
,ProductName
,RetailPrice
,ProductCategory
FROM CurrentProducts
WHERE ProductCategory = @Category
)
GO
----------------------------------------
SELECT * FROM ufn_GetProducts('Bikes')





-Vaibhav Chaudhari


No comments:

Post a Comment