Home Forums SQL Server 2008 T-SQL (SS2K8) Potentially delusional co-worker, inline vs. multi statement TVF RE: Potentially delusional co-worker, inline vs. multi statement TVF

  • A multi-statement table valued user-defined function looks like this: (example from Books Online)

    CREATE FUNCTION dbo.FindReports (@InEmpID INTEGER)

    RETURNS @retFindReports TABLE

    (

    EmployeeID int primary key NOT NULL,

    FirstName nvarchar(255) NOT NULL,

    LastName nvarchar(255) NOT NULL,

    JobTitle nvarchar(50) NOT NULL,

    RecursionLevel int NOT NULL

    )

    AS

    BEGIN

    INSERT INTO @retFindReports

    SELECT EmployeeID, FirstName, LastName, JobTitle, RecursionLevel

    FROM ....

    RETURN

    END;

    The key things being the definition of the table variable and one or more inserts into that table variable

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass