T-SQL存储过程:分析权限存储与页面对应

CREATE   PROCEDURE  w_Function_GetParams
AS
DECLARE
    
@FunctionName_CN   nvarchar ( 64 ),
    
@ActionName   nvarchar ( 32 ),
    
@PageName   nvarchar ( 128 ),
    
@Cache_FN   nvarchar ( 256 ),
    
@LENFN   int ,
    
@Index_A   int ,
    
@index_B   int
BEGIN
    
CREATE   TABLE  #Temp_TAB
    (
        ID 
int   identity ( 1 , 1 ),
        FN 
nvarchar ( 64 ),
        AN 
nvarchar ( 32 ),
        PN 
nvarchar ( 128 )
    )

    
DECLARE  FN_CURSOR  CURSOR   FOR
    
SELECT  FunctionName  FROM  Admin_FunctionList  WHERE  GroupID = 0

    
OPEN  FN_CURSOR;
    
FETCH   NEXT   FROM  FN_CURSOR  INTO   @Cache_FN ;

    
WHILE   @@FETCH_STATUS = 0
    
BEGIN
        
SET   @LENFN = LEN ( @Cache_FN );
        
SET   @Index_A = CHARINDEX ( ' | ' , @Cache_FN );
        
SET   @Index_B = CHARINDEX ( ' : ' , @Cache_FN );

        
SET   @FunctionName_CN = SUBSTRING ( @Cache_FN , 0 , @Index_A );
        
SET   @ActionName = SUBSTRING ( @Cache_FN , @Index_A + 1 , @Index_B - @Index_A - 1 );
        
SET   @PageName = SUBSTRING ( @Cache_FN , @Index_B + 1 , @LENFN - @Index_B );

--         print(@FunctionName_CN);
--
        Print(@ActionName);
--
        print(@PageName);

        
INSERT   INTO  #Temp_TAB  VALUES ( @FunctionName_CN , @ActionName , @PageName )
        
        
FETCH   NEXT   FROM  FN_CURSOR  INTO   @Cache_FN ;
    
END
    
    
CLOSE  FN_CURSOR;
    
DEALLOCATE  FN_CURSOR;

    
SELECT  FN,AN,PN  FROM  #Temp_TAB  GROUP   BY  PN,AN,FN

END

数据格式:

编辑产品信息|EDIT:W_PRODUCT_EDIT.ASPX

你可能感兴趣的:(t-sql)