用友U8获取指定用户拥有指定权限的账套

DECLARE @userId NVARCHAR(20);
		--用户登录账号
SET @userId = 'a';
DECLARE @cAuth_Id NVARCHAR(100);
	--权限ID,可通过权限管理菜单查看
SET @cAuth_Id = 'ST011903';
DECLARE @cAcc_Id NVARCHAR(3);
		--账套ID
SET @cAcc_Id = '001';

SELECT  CONVERT(BIT, ISNULL(( SELECT    COUNT(*)
                              FROM      UFSystem.dbo.UA_HoldAuth
                              WHERE     ( ( ( cUser_Id = @userId
                                              AND iIsUser = 1
                                            )
                                            OR ( cUser_Id IN (
                                                 SELECT cGroup_Id
                                                 FROM   UFSystem.dbo.UA_Role
                                                 WHERE  cUser_Id = @userId )
                                                 AND iIsUser = 0
                                               )
                                          )
                                          AND (cAuth_Id = @cAuth_Id OR cAuth_Id = 'Admin')
                                          AND cAcc_Id = @cAcc_Id
                                        )
                            ), 0)
        + ISNULL(( SELECT   COUNT(*)
                   FROM     UFSystem.dbo.UA_Role
                   WHERE    cUser_Id = @userId
                            AND cGroup_Id = 'DATA-MANAGER'	--账套主管,拥有所有权限
                 ), 0)) AS HasPower;

你可能感兴趣的:(用友,数据库,用友u8,SQL)