一丶
1.利用begin try--end try 、begin catch--end catch来处理是否回滚
1 begin transaction 2 begin try 3 SQL语句1 4 SQL语句2 5 commit transaction 6 end try 7 begin catch 8 rollback transaction 9 end catch
2.判断是否存在存储过程
if (exists (select * from sys.objects where name = '存储过程名')) drop proc 存储过程名
3.
1 CREATE PROCEDURE 存储过程名称( 2 @id VARCHAR(50) 3 ) 4 AS 5 BEGIN 6 IF @id='567' 7 BEGIN 8 SELECT * FROM Student WHERE id=@id 9 END 10 ELSE 11 BEGIN 12 SELECT * FROM Student 13 END 14 END