Feeds:
Posts
Comments

Posts Tagged ‘Return table variable as output parameter from User defined function’

Script:

CREATE
FUNCTION dbo.fnReturnTable() RETURNS
@TableOutput TABLE (
A INT ,B INT)

AS

BEGIN

            DECLARE @CNT INT

            DECLARE @INR INT

            SET @CNT=0

            SET @INR=0

            WHILE @CNT <100

            BEGIN

                        INSERT INTO
@TableOutput

                        VALUES (@CNT ,@INR)

                        SET @CNT=@CNT+12

                        SET @INR=@INR+12

            END

            RETURN

END

 

Execute:

SELECT
* FROM dbo.fnReturnTable()

 

 

Output:

A     B

0     0

12    12

24    24

36    36

48    48

60    60

72    72

84    84

96    96

Advertisements

Read Full Post »

%d bloggers like this: