---Name: 创建存储过程模板.sql ---Purpose: 用于创建 数据库中 新的存储过程 ---Author: xx ---Time: 2015-12-18 10:26:06 ---Remark: MyProcedure 为存储过程名; tb_simple 为表;cloumn_simple 为要更新的列,id 为主键 BEGIN TRANSACTION IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'MyProcedure') AND type in (N'P', N'PC')) BEGIN DROP PROCEDURE MyProcedure --注意不要把老的存储过程 的相关的列给 更新掉。 PRINT 'drop MyProcedure' END GO CREATE PROCEDURE MyProcedure AS BEGIN SELECT * FROM tb_simple END GO PRINT 'create MyProcedure' IF @@ERROR<>0 BEGIN PRINT '有错误,回滚' ROLLBACK TRANSACTION END ELSE BEGIN PRINT '成功,提交' COMMIT TRANSACTION END