高利军

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go-- =============================================
-- Author:  高利军
-- Create date: 2011-06-08
-- Description: 获取所有存储过程源码
-- =============================================
ALTER PROCEDURE [dbo].[sp_getAllProcText]
 -- Add the parameters for the stored procedure here 
AS

 


SET XACT_ABORT ON
BEGIN TRANSACTION

BEGIN
 -- SET NOCOUNT ON added to prevent extra result sets from
 SET NOCOUNT ON;

    declare @proc_text varchar(max)
DECLARE get_proc_text_cursor CURSOR FOR
SELECT  'IF OBJECT_ID(N'''+ [name] +''') IS NOT NULL '+ CHAR(10) + CHAR(13) +' DROP PROC ' + [name] +  CHAR(10) +  CHAR(13)  +  '  GO '  +  CHAR(10) +  CHAR(13) + definition + CHAR(10)  + CHAR(13) +' GO'
FROM sys.sql_modules
inner join sysobjects  on sys.sql_modules.object_id = sysobjects.id  and type='p'

OPEN get_proc_text_cursor

FETCH NEXT FROM get_proc_text_cursor
INTO @proc_text

WHILE @@FETCH_STATUS = 0
BEGIN

 --UPDATE  tb_HQ_Out_Order SET state = 0 WHERE hoor_code = @hoor_code
print @proc_text
    FETCH NEXT FROM get_proc_text_cursor
    INTO @proc_text
END
CLOSE get_proc_text_cursor
DEALLOCATE get_proc_text_cursor

END

COMMIT TRANSACTION

 

 

 

 

 

 

 

 

 

posted on 2011-08-27 14:32  高利军  阅读(270)  评论(0编辑  收藏  举报