SQLServer 表值函数

-- =============================================
-- Author:		xxzz
-- Create date: 二〇二一年二月二十三日
-- Description: 表值函数的使用
-- =============================================
ALTER FUNCTION [dbo].[f_CORE_ProjectCRAs] ( )
RETURNS @arrData TABLE
    (
      ProposedprojectID INT ,
      ProjectID INT ,
      CRAID INT
    )
    BEGIN
        INSERT  INTO @arrData
                SELECT  ProposedProjectID ,
                        up.ProjectID ,
                        up.UserID
                FROM    dbo.UserProjects up
                        LEFT JOIN dbo.ProposedProjects pps ON up.ProjectID = pps.ProjectID
                        LEFT JOIN dbo.v_Users u ON up.UserID = u.UserID
                WHERE   up.DeletedDate IS NULL
                        AND UsergroupID = 35;
	
        INSERT  INTO @arrData
                SELECT  ProposedProjectID ,
                        ProjectID ,
                        CreatedBy
                FROM    dbo.ProposedProjects
                WHERE   ProjectID IS NULL;
        RETURN;
    END;

GO

posted @ 2021-02-23 15:40  xuxuzhaozhao  阅读(96)  评论(0编辑  收藏  举报