SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
IF EXISTS (SELECT * FROM tempdb..sysobjects WHERE id=OBJECT_ID('tempdb..#tmpErrors')) DROP TABLE #tmpErrors
GO
CREATE TABLE #tmpErrors (Error int)
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
GO
PRINT N'Altering [dbo].[PE_CommonModel]'
GO
ALTER TABLE [dbo].[PE_CommonModel] ADD
[PreviewCode] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL,
[ValDate] [datetime] NULL
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Creating [dbo].[PE_CommonModel_NotApproveOpinion]'
GO
CREATE TABLE [dbo].[PE_CommonModel_NotApproveOpinion]
(
[OpinionId] [int] NOT NULL,
[GeneralID] [int] NOT NULL,
[Inputer] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
[NotApproveOpinion] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL,
[NotApproveTime] [datetime] NULL
)
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Creating primary key [PK_PE_CommonModel_NotApproveOpinion_OpinionId] on [dbo].[PE_CommonModel_NotApproveOpinion]'
GO
ALTER TABLE [dbo].[PE_CommonModel_NotApproveOpinion] ADD CONSTRAINT [PK_PE_CommonModel_NotApproveOpinion_OpinionId] PRIMARY KEY CLUSTERED  ([OpinionId])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
IF EXISTS (SELECT * FROM #tmpErrors) ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT>0 BEGIN
PRINT 'The database update succeeded'
COMMIT TRANSACTION
END
ELSE PRINT 'The database update failed'
GO
DROP TABLE #tmpErrors
GO
