文件名称:sqlserver2005存储过程例子
文件大小:37KB
文件格式:TXT
更新时间:2012-08-20 07:38:33
游标,动态sql,存储过程调用
直接执行文件中的语句即可创建存储过程。 CREATE PROCEDURE [createReDealCheck] -- Add the parameters for the stored procedure here AS BEGIN declare @Cur_Error as integer set @Cur_Error = 0 BEGIN TRANSACTION Tran_1 -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; CREATE TABLE [dbo].[ReDealCheck]( [AppplyNo] [varchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL, [FileType] [varchar](2) COLLATE Chinese_PRC_CI_AS NOT NULL, [remark] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, CONSTRAINT [PK_ReDealCheck] PRIMARY KEY CLUSTERED ( [AppplyNo] ASC, [FileType] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] set @Cur_Error=@Cur_Error+@@error CREATE NONCLUSTERED INDEX [index_LWMission_MissionProp1_MissionProp2] ON [dbo].[LWMission] ( [MissionProp1] ASC, [MissionProp2] ASC ) INCLUDE ( [MissionID]) WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY] set @Cur_Error=@Cur_Error+@@error IF (@Cur_Error<>0) begin ROLLBACK TRANSACTION Tran_1 end ELSE begin --ROLLBACK TRANSACTION Tran_1 COMMIT TRANSACTION Tran_1 end END