The following snippet uses a Table variable to create a table and inserts value into it, which the function returns
CREATE FUNCTION ReturnATable() RETURNS @TabVar TABLE ( OrderID int not null, OrderDate datetime, OrderStatus bit, OrderValue decimal, BilledBy varchar(20) ) AS BEGIN DEclare @Date datetime ; Set @Date= GETDATE(); Insert Into @TabVar values (21, @Date , 1, 212.42, 'Jose'); return END
The function can be executed as shown below
Select * from ReturnATable()
No comments:
Post a Comment