- Table Valued Functions
Let us have a look a example:
........
ALTER FUNCTION [dbo].[GetDetails]
(
@INPUTSQL VARCHAR(MAX)
)
RETURNS @A TABLE
(
ID INT IDENTITY(1,1),
Details VARCHAR(50)
)
BEGIN
.......
Look at : The “Returns” is ‘Table’ which means this funciton will return a table. This table has 2 column ‘ID’ and ‘Details’. Then we can use below sql to get one of the value of those two.
Select * from [dbo].[GetDetails](@ID) --we can fill with one value of "ID"
Now we must clear that: what in the () must be one of those two column on the other words is : we must not fill all the value of columns.
You can make some correspond changes if we have three or more parameters in the funciton.