SQL存储过程的功能非常强大,下面就将为您介绍实现分析权限存储与页面对应的SQL存储过程,希望对您学习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 @LENLENFN=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
【编辑推荐】