存儲過程

SQLSERVER

 如何查看之前執行過的存儲過

select [text] from syscomments where id=object_id('存儲過程名字') 

exec sp_helptext parseBranch    查看存儲過程的txt文本

create procedure [dbo].[parseBranch] @_parentid int,@_index int output  
as  
begin  
 declare @_pkid int  
 declare cur CURSOR local FOR SELECT pkid FROM t_branch WHERE fkparent=@_parentid --AND status=0;  
 open cur;     
 fetch cur into @_pkid;  
 while (@@fetch_status=0)  
 begin    
  update t_branch set lft=@_index where pkid= @_pkid;  
  set @_index=@_index+1;  
  exec parseBranch @_pkid,@_index output;  
  update t_branch set rgt=@_index where pkid= @_pkid;  
     set @_index=@_index+1;  
  fetch cur into @_pkid;  
 END  
 close cur         
 deallocate cur     
end;


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章