alter procedure [dbo].[Admin_GetMenu]
@GroupID int,
@Roles nvarchart(500)
asdeclare @strSql nvarchar(1000)
set @strSql='select * from  Admin_RightModule where GroupID='+Cast(@GroupID as nvarchar)+' and ModuleID in (select distinct ModuleID from admin_RightFunction where FunctionID in ('+ @Roles+'))'execute(@strSql)execute Admin_GetMenu 30,'100101,100102,100103,100104,100105,200101,200102'
报这个错误 超出了存储过程、函数、触发器或视图的最大嵌套层数(最大层数为 32)。
怎么解决呀,谢谢,求教了。

解决方案 »

  1.   

    SQL SERVER企业管理器 右键 服务器—>属性—>服务器设置,服务器行为—>选中 允许激发会触发其他触发器的触发器。 
      

  2.   

    你把动态字符串打印出来在SQL里执行看看,报什么错!
      

  3.   


    alter procedure [dbo].[Admin_GetMenu]
    @GroupID int,
    @Roles nvarchart(500)
    as
    begin
    declare @strSql nvarchar(1000)
    set @strSql='select * from  Admin_RightModule where GroupID='+Cast(@GroupID as nvarchar)+' and ModuleID in (select distinct ModuleID from admin_RightFunction where FunctionID in ('+ @Roles+'))'execute(@strSql)
    endexecute Admin_GetMenu 30,'100101,100102,100103,100104,100105,200101,200102'--不要再存储过程里面执行当前存储过程,那不死循环了吗!!!!
      

  4.   

    調用時,要用go分隔
    alter procedure [dbo].[Admin_GetMenu]
    @GroupID int,
    @Roles nvarchart(500)
    asdeclare @strSql nvarchar(1000)
    set @strSql='select * from  Admin_RightModule where GroupID='+Cast(@GroupID as nvarchar)+' and ModuleID in (select distinct ModuleID from admin_RightFunction where FunctionID in ('+ @Roles+'))'execute(@strSql)
    go
    execute Admin_GetMenu 30,'100101,100102,100103,100104,100105,200101,200102'