/****** Object:  StoredProcedure [dbo].[PR_Analytics_StatUpdate]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_StatUpdate]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Analytics_StatUpdate]
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_StatVisit_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_StatVisit_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Analytics_StatVisit_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_StatVisitor_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_StatVisitor_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Analytics_StatVisitor_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_DoInit]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_DoInit]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Analytics_DoInit]
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_GetOnlineByIP]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_GetOnlineByIP]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Analytics_GetOnlineByIP]
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_GetOnlineCount]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_GetOnlineCount]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Analytics_GetOnlineCount]
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_ModiMaxNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_ModiMaxNum]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Analytics_ModiMaxNum]
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_SaveConfig]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_SaveConfig]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Analytics_SaveConfig]
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_StatIPInfo_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_StatIPInfo_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Analytics_StatIPInfo_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_StatIPInfo_Delete]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_StatIPInfo_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Analytics_StatIPInfo_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_StatIPInfo_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_StatIPInfo_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Analytics_StatIPInfo_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_StatOnline_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_StatOnline_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Analytics_StatOnline_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_ModelTemplates_GetField]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_ModelTemplates_GetField]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_ModelTemplates_GetField]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_ModelTemplates_GetInfoById]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_ModelTemplates_GetInfoById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_ModelTemplates_GetInfoById]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_ModelTemplates_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_ModelTemplates_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_ModelTemplates_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Mood_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Mood_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Mood_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_MoodScheme_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_MoodScheme_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_MoodScheme_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_MoodScheme_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_MoodScheme_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_MoodScheme_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Nodes_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Nodes_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Nodes_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Nodes_GetById]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Nodes_GetById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Nodes_GetById]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Nodes_GetUpOrderListByOrderId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Nodes_GetUpOrderListByOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Nodes_GetUpOrderListByOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Nodes_UpDate]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Nodes_UpDate]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Nodes_UpDate]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Nodes_UpdateBasicNodesInfo]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Nodes_UpdateBasicNodesInfo]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Nodes_UpdateBasicNodesInfo]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Nodes_UpdateNextId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Nodes_UpdateNextId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Nodes_UpdateNextId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Nodes_UpdateOrderId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Nodes_UpdateOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Nodes_UpdateOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Tags]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Tags]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Tags]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Address_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Address_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_Address_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Address_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Address_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_Address_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Client_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Client_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_Client_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Client_GetById]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Client_GetById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_Client_GetById]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Client_Merge]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Client_Merge]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_Client_Merge]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Client_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Client_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_Client_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ClientAnnal_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ClientAnnal_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_ClientAnnal_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_RemindItem_GetInfoByTime]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_RemindItem_GetInfoByTime]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_RemindItem_GetInfoByTime]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Service_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Service_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_Service_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Service_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Service_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_Service_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Department_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Department_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Department_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Department_Members_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Department_Members_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Department_Members_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Department_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Department_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Department_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Courier_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Courier_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Courier_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverCharge_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverCharge_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverCharge_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverCharge_Delete]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverCharge_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverCharge_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverCharge_GetById]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverCharge_GetById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverCharge_GetById]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverCharge_GetByTypeId]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverCharge_GetByTypeId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverCharge_GetByTypeId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverCharge_GetChargeParmOfWeight]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverCharge_GetChargeParmOfWeight]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverCharge_GetChargeParmOfWeight]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverCharge_GetListByAreaType]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverCharge_GetListByAreaType]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverCharge_GetListByAreaType]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverCharge_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverCharge_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverCharge_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverItem_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverItem_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverItem_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverItem_GetByOrderId]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverItem_GetByOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverItem_GetByOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverItem_SignIn]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverItem_SignIn]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverItem_SignIn]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverItemDetails_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverItemDetails_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverItemDetails_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverType_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverType_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverType_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverType_Delete]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverType_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverType_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverType_GetById]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverType_GetById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverType_GetById]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverType_GetList]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverType_GetList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverType_GetList]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverType_GetMaxId]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverType_GetMaxId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverType_GetMaxId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverType_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverType_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_DeliverType_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Indent_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Indent_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Indent_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Indent_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Indent_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Indent_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_IndentItem_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_IndentItem_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_IndentItem_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Invoice_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Invoice_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Invoice_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Invoice_GetById]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Invoice_GetById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Invoice_GetById]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Invoice_GetByOrderId]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Invoice_GetByOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Invoice_GetByOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Order_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Order_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Order_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Order_AgentPayment]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Order_AgentPayment]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Order_AgentPayment]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Order_Confirm]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Order_Confirm]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Order_Confirm]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Order_Delete]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Order_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Order_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Order_GetByOrderId]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Order_GetByOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Order_GetByOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Order_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Order_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Order_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_OrderHistory_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_OrderHistory_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_OrderHistory_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_OrderHistoryItem_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_OrderHistoryItem_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_OrderHistoryItem_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_OrderItem_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_OrderItem_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_OrderItem_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_OrderItem_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_OrderItem_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_OrderItem_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_OrderItem_UpdateByProductId]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_OrderItem_UpdateByProductId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_OrderItem_UpdateByProductId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PaymentLog_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PaymentLog_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_PaymentLog_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PaymentType_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PaymentType_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_PaymentType_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PaymentType_Delete]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PaymentType_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_PaymentType_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PaymentType_GetById]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PaymentType_GetById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_PaymentType_GetById]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PaymentType_GetList]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PaymentType_GetList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_PaymentType_GetList]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PaymentType_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PaymentType_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_PaymentType_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PresentProject_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PresentProject_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_PresentProject_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PresentProject_Delete]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PresentProject_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_PresentProject_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PresentProject_List]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PresentProject_List]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_PresentProject_List]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PresentProject_Locked]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PresentProject_Locked]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_PresentProject_Locked]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PresentProject_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PresentProject_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_PresentProject_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Producer_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Choiceset_GetChoicesetFieldValueByName]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Choiceset_GetChoicesetFieldValueByName]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Choiceset_GetChoicesetFieldValueByName]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Choiceset_GetList]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Choiceset_GetList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Choiceset_GetList]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Choiceset_SetFieldValue]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Choiceset_SetFieldValue]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Choiceset_SetFieldValue]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownloadError_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownloadError_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownloadError_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownloadError_Clear]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownloadError_Clear]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownloadError_Clear]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownloadError_Delete]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownloadError_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownloadError_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_Delete]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_GetById]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_GetById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_GetById]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_GetCountOrderId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_GetCountOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_GetCountOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_GetDownOrderId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_GetDownOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_GetDownOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_GetList]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_GetList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_GetList]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_GetMaxOrderId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_GetMaxOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_GetMaxOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_GetServerUrlByServerId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_GetServerUrlByServerId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_GetServerUrlByServerId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_GetUpOrderId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_GetUpOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_GetUpOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_MoveDownOrderId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_MoveDownOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_MoveDownOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_MoveOrderId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_MoveOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_MoveOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_MoveUpOrderId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_MoveUpOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_MoveUpOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_SetShowType]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_SetShowType]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_SetShowType]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_UpdateOrderId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_UpdateOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_DownServer_UpdateOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Keywords_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Keywords_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Keywords_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Author_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Author_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Author_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Author_Delete]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Author_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Author_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Author_GetAuthorInfoByID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Author_GetAuthorInfoByID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Author_GetAuthorInfoByID]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Author_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Author_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Author_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Bank_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_Delete]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Bank_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_GetBankInfoByID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_GetBankInfoByID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Bank_GetBankInfoByID]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_GetList]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_GetList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Bank_GetList]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_SetDefault]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_SetDefault]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Bank_SetDefault]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_SetDisabled]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_SetDisabled]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Bank_SetDisabled]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_SetOrderID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_SetOrderID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Bank_SetOrderID]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Bank_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_BankrollItem_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_BankrollItem_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_BankrollItem_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_BankrollItem_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_BankrollItem_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_BankrollItem_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Keywords_Exists]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Keywords_Exists]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Keywords_Exists]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Keywords_GetById]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Keywords_GetById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Keywords_GetById]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Keywords_SearchKeyword]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Keywords_SearchKeyword]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Keywords_SearchKeyword]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Keywords_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Keywords_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Keywords_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Log_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Log_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Log_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Log_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Log_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Log_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Message_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Message_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Message_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PaymentLog_GetList]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PaymentLog_GetList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_PaymentLog_GetList]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PaymentLog_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PaymentLog_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_PaymentLog_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PaymentLog_Update2]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PaymentLog_Update2]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_PaymentLog_Update2]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_PayPlatform_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_Delete]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_PayPlatform_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_DisablePayPlatform]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_DisablePayPlatform]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_PayPlatform_DisablePayPlatform]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_GetInfoById]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_GetInfoById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_PayPlatform_GetInfoById]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_GetList]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_GetList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_PayPlatform_GetList]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_GetListOfdisabled]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_GetListOfdisabled]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_PayPlatform_GetListOfdisabled]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_SetDefault]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_SetDefault]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_PayPlatform_SetDefault]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_SetOrderId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_SetOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_PayPlatform_SetOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_PayPlatform_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Region_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Region_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Region_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Region_CheckArea]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Region_CheckArea]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Region_CheckArea]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Region_Delete]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Region_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Region_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Region_GetByID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Region_GetByID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Region_GetByID]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Region_GetProvinceList]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Region_GetProvinceList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Region_GetProvinceList]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Region_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Region_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Region_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Source_Delete]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Source_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Source_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Source_GetSourceInfo]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Source_GetSourceInfo]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Source_GetSourceInfo]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Source_GetSourceInfoByID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Source_GetSourceInfoByID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Source_GetSourceInfoByID]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Source_GetSourceInfoByType]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Source_GetSourceInfoByType]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Source_GetSourceInfoByType]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Source_Insert]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Source_Insert]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Source_Insert]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Source_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Source_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Source_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_WordReplace_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_WordReplace_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_WordReplace_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_WordReplace_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_WordReplace_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_WordReplace_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_Advertisement_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_Advertisement_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_AD_Advertisement_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_Advertisement_CancelPassed]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_Advertisement_CancelPassed]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_AD_Advertisement_CancelPassed]
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_Advertisement_Passed]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_Advertisement_Passed]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_AD_Advertisement_Passed]
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_Advertisement_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_Advertisement_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_AD_Advertisement_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_ADZone_Active]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_ADZone_Active]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_AD_ADZone_Active]
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_ADZone_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_ADZone_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_AD_ADZone_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Message_GetById]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Message_GetById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Message_GetById]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_WordReplace_Exists]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_WordReplace_Exists]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_WordReplace_Exists]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_WordReplace_GetById]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_WordReplace_GetById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_WordReplace_GetById]
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_ADZone_Pause]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_ADZone_Pause]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_AD_ADZone_Pause]
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_ADZone_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_ADZone_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_AD_ADZone_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Comment_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Comment_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Comment_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_CommentPK_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_CommentPK_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_CommentPK_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Model_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_AddModelForNodes]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_AddModelForNodes]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Model_AddModelForNodes]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_AddTemplateForNodes]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_AddTemplateForNodes]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Model_AddTemplateForNodes]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_Disabled]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_Disabled]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Model_Disabled]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_GetById]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_GetById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Model_GetById]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_IsModelNameExists]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_IsModelNameExists]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Model_IsModelNameExists]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_IsTableNameExists]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_IsTableNameExists]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Model_IsTableNameExists]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_ModelIdExists]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_ModelIdExists]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Model_ModelIdExists]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_TemplateIdExists]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_TemplateIdExists]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Model_TemplateIdExists]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_Update]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_Model_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_ModelTemplates_Add]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_ModelTemplates_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_ModelTemplates_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ClientAnnal_GetClientAnnalByID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ClientAnnal_GetClientAnnalByID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_ClientAnnal_GetClientAnnalByID]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ClientAnnal_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ClientAnnal_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_ClientAnnal_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ClientHistory_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ClientHistory_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_ClientHistory_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ClientHistoryItem_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ClientHistoryItem_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_ClientHistoryItem_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Company_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Company_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_Company_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Company_GetByClientId]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Company_GetByClientId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_Company_GetByClientId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Company_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Company_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_Company_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ComplainItem_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ComplainItem_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_ComplainItem_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ComplainItem_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ComplainItem_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_ComplainItem_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Contacter_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Contacter_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_Contacter_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Contacter_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Contacter_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_Contacter_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_GetById]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_GetById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Producer_GetById]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_ProducerNameExists]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_ProducerNameExists]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Producer_ProducerNameExists]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_SetElite]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_SetElite]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Producer_SetElite]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_SetOnTop]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_SetOnTop]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Producer_SetOnTop]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_SetPassed]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_SetPassed]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Producer_SetPassed]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Producer_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Product_DeleteAll]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Product_DeleteAll]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Product_DeleteAll]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Product_DeleteModel]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Product_DeleteModel]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Product_DeleteModel]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_ProductPrice_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_ProductPrice_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_ProductPrice_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Provider_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Provider_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Provider_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Provider_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Provider_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Provider_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Refund_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Refund_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Refund_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Refund_GetByOrderId]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Refund_GetByOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Refund_GetByOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Remittance_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Remittance_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Remittance_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Remittance_GetByOrderId]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Remittance_GetByOrderId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Remittance_GetByOrderId]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_GetById]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_GetById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Trademark_GetById]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_SetElite]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_SetElite]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Trademark_SetElite]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_SetOnTop]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_SetOnTop]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Trademark_SetOnTop]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_SetPassed]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_SetPassed]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Trademark_SetPassed]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_TrademarkNameExists]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_TrademarkNameExists]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Trademark_TrademarkNameExists]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Trademark_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_TransferLog_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_TransferLog_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_TransferLog_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_TransferLog_GetList]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_TransferLog_GetList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_TransferLog_GetList]
GO
/****** Object:  StoredProcedure [dbo].[PR_Survey_SurveyManager_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Survey_SurveyManager_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Survey_SurveyManager_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Survey_SurveyManager_SetPassed]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Survey_SurveyManager_SetPassed]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Survey_SurveyManager_SetPassed]
GO
/****** Object:  StoredProcedure [dbo].[PR_Survey_SurveyManager_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Survey_SurveyManager_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Survey_SurveyManager_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Survey_SurveyVote_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Survey_SurveyVote_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Survey_SurveyVote_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Cards_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Cards_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_Cards_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Cards_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Cards_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_Cards_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_User_Exists]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_User_Exists]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_User_Exists]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserGroups_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserGroups_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_UserGroups_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserGroups_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserGroups_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_UserGroups_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserNameIsRepeat]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserNameIsRepeat]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_UserNameIsRepeat]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserPointLog_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserPointLog_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_UserPointLog_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserPointLog_Delete]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserPointLog_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_UserPointLog_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserPointLog_DeleteUser]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserPointLog_DeleteUser]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_UserPointLog_DeleteUser]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserPointLog_Exists]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserPointLog_Exists]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_UserPointLog_Exists]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserPointLog_PointSum]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserPointLog_PointSum]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_UserPointLog_PointSum]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserPointLog_UpdateTimes]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserPointLog_UpdateTimes]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_UserPointLog_UpdateTimes]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserPointLog_UserPointSum]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserPointLog_UserPointSum]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_UserPointLog_UserPointSum]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_Users_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_BatchInquire]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_BatchInquire]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_Users_BatchInquire]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_BatchLock]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_BatchLock]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_Users_BatchLock]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_SendBack_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_SendBack_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_SendBack_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_SendBack_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_SendBack_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_SendBack_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_SendBackItem_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_SendBackItem_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_SendBackItem_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_ShoppingCarts_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_ShoppingCarts_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_ShoppingCarts_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Trademark_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_GetById]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_GetById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_Users_GetById]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_Users_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_UpdateUserStatus]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_UpdateUserStatus]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_Users_UpdateUserStatus]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserValidLog_Add]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserValidLog_Add]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_UserValidLog_Add]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserValidLog_Delete]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserValidLog_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_UserValidLog_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserValidLog_DeleteUser]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserValidLog_DeleteUser]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_UserValidLog_DeleteUser]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserValidLog_Exists]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserValidLog_Exists]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_UserValidLog_Exists]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_BatchUnLock]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_BatchUnLock]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_Users_BatchUnLock]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_Delete]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_Users_Delete]
GO
/****** Object:  UserDefinedFunction [dbo].[SplitID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SplitID]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[SplitID]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_Delete]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Trademark_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Statistics_GetList]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Statistics_GetList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Statistics_GetList]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_ShoppingCart_GetList]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_ShoppingCart_GetList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_ShoppingCart_GetList]
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_BatchMove]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_BatchMove]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_UserManage_Users_BatchMove]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_SaleCount_GetList]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_SaleCount_GetList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_SaleCount_GetList]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Product_Update]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Product_Update]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Product_Update]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_RemindItem_Delete]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_RemindItem_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_RemindItem_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_ModelTemplates_GetExportList]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_ModelTemplates_GetExportList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Contents_ModelTemplates_GetExportList]
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_AddNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_AddNum]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Analytics_AddNum]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_WordReplace_IsEnabled]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_WordReplace_IsEnabled]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_WordReplace_IsEnabled]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PaymentLog_Delete]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PaymentLog_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_PaymentLog_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_ADZone_GetExportList]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_ADZone_GetExportList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_AD_ADZone_GetExportList]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_WordReplace_Delete]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_WordReplace_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_WordReplace_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Message_Delete]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Message_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Message_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_BankroolItem_GetBill]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_BankroolItem_GetBill]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_BankroolItem_GetBill]
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Keywords_Delete]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Keywords_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Accessories_Keywords_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_Delete]    Script Date: 01/19/2017 15:37:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Shop_Producer_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ClientAnnal_Delete]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ClientAnnal_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Crm_ClientAnnal_Delete]
GO
/****** Object:  StoredProcedure [dbo].[PR_Common_GetList]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Common_GetList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Common_GetList]
GO
/****** Object:  StoredProcedure [dbo].[PR_Common_GetListBySortColumn]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Common_GetListBySortColumn]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Common_GetListBySortColumn]
GO
/****** Object:  StoredProcedure [dbo].[PR_Common_PagingLarge]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Common_PagingLarge]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_Common_PagingLarge]
GO
/****** Object:  StoredProcedure [dbo].[PR_CommonPage]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_CommonPage]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PR_CommonPage]
GO
/****** Object:  Table [dbo].[PE_Address]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Address]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Address]
GO
/****** Object:  Table [dbo].[PE_Admin]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Admin]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Admin]
GO
/****** Object:  Table [dbo].[PE_Admin_Roles]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Admin_Roles]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Admin_Roles]
GO
/****** Object:  Table [dbo].[PE_AdminProfile]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_AdminProfile]') AND type in (N'U'))
DROP TABLE [dbo].[PE_AdminProfile]
GO
/****** Object:  Table [dbo].[PE_AdminShortCutContent]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_AdminShortCutContent]') AND type in (N'U'))
DROP TABLE [dbo].[PE_AdminShortCutContent]
GO
/****** Object:  Table [dbo].[PE_Advertisement]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Advertisement]
GO
/****** Object:  Table [dbo].[PE_AdZone]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_AdZone]') AND type in (N'U'))
DROP TABLE [dbo].[PE_AdZone]
GO
/****** Object:  Table [dbo].[PE_Author]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Author]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Author]
GO
/****** Object:  Table [dbo].[PE_Bank]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Bank]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Bank]
GO
/****** Object:  Table [dbo].[PE_BankrollItem]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_BankrollItem]
GO
/****** Object:  Table [dbo].[PE_Cards]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Cards]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Cards]
GO
/****** Object:  Table [dbo].[PE_Client]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Client]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Client]
GO
/****** Object:  Table [dbo].[PE_ClientAnnal]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ClientAnnal]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ClientAnnal]
GO
/****** Object:  Table [dbo].[PE_ClientAssist]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ClientAssist]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ClientAssist]
GO
/****** Object:  Table [dbo].[PE_ClientConfirm]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ClientConfirm]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ClientConfirm]
GO
/****** Object:  Table [dbo].[PE_ClientHistory]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ClientHistory]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ClientHistory]
GO
/****** Object:  Table [dbo].[PE_ClientHistoryItem]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ClientHistoryItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ClientHistoryItem]
GO
/****** Object:  Table [dbo].[PE_ClientItem]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ClientItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ClientItem]
GO
/****** Object:  Table [dbo].[PE_CollectionExclosion]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionExclosion]') AND type in (N'U'))
DROP TABLE [dbo].[PE_CollectionExclosion]
GO
/****** Object:  Table [dbo].[PE_CollectionFieldRules]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionFieldRules]') AND type in (N'U'))
DROP TABLE [dbo].[PE_CollectionFieldRules]
GO
/****** Object:  Table [dbo].[PE_CollectionFilterRules]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionFilterRules]') AND type in (N'U'))
DROP TABLE [dbo].[PE_CollectionFilterRules]
GO
/****** Object:  Table [dbo].[PE_CollectionHistory]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionHistory]') AND type in (N'U'))
DROP TABLE [dbo].[PE_CollectionHistory]
GO
/****** Object:  Table [dbo].[PE_CollectionItem]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_CollectionItem]
GO
/****** Object:  Table [dbo].[PE_CollectionListRules]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionListRules]') AND type in (N'U'))
DROP TABLE [dbo].[PE_CollectionListRules]
GO
/****** Object:  Table [dbo].[PE_CollectionPagingRules]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionPagingRules]') AND type in (N'U'))
DROP TABLE [dbo].[PE_CollectionPagingRules]
GO
/****** Object:  Table [dbo].[PE_Comment]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Comment]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Comment]
GO
/****** Object:  Table [dbo].[PE_CommentPK]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommentPK]') AND type in (N'U'))
DROP TABLE [dbo].[PE_CommentPK]
GO
/****** Object:  Table [dbo].[PE_CommonModel]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]') AND type in (N'U'))
DROP TABLE [dbo].[PE_CommonModel]
GO
/****** Object:  Table [dbo].[PE_CommonProduct]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonProduct]') AND type in (N'U'))
DROP TABLE [dbo].[PE_CommonProduct]
GO
/****** Object:  Table [dbo].[PE_Company]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Company]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Company]
GO
/****** Object:  Table [dbo].[PE_ComplainItem]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ComplainItem]
GO
/****** Object:  Table [dbo].[PE_Contacter]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Contacter]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Contacter]
GO
/****** Object:  Table [dbo].[PE_ContentCharge]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ContentCharge]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ContentCharge]
GO
/****** Object:  Table [dbo].[PE_ContentPermission]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ContentPermission]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ContentPermission]
GO
/****** Object:  Table [dbo].[PE_CorrelativeItems]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CorrelativeItems]') AND type in (N'U'))
DROP TABLE [dbo].[PE_CorrelativeItems]
GO
/****** Object:  Table [dbo].[PE_Coupon]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Coupon]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Coupon]
GO
/****** Object:  Table [dbo].[PE_CouponItem]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CouponItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_CouponItem]
GO
/****** Object:  Table [dbo].[PE_Courier]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Courier]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Courier]
GO
/****** Object:  Table [dbo].[PE_D_ProductSuite]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_D_ProductSuite]') AND type in (N'U'))
DROP TABLE [dbo].[PE_D_ProductSuite]
GO
/****** Object:  Table [dbo].[PE_DeliverCharge]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]') AND type in (N'U'))
DROP TABLE [dbo].[PE_DeliverCharge]
GO
/****** Object:  Table [dbo].[PE_DeliverItem]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_DeliverItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_DeliverItem]
GO
/****** Object:  Table [dbo].[PE_DeliverItemDetails]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_DeliverItemDetails]') AND type in (N'U'))
DROP TABLE [dbo].[PE_DeliverItemDetails]
GO
/****** Object:  Table [dbo].[PE_DeliverType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]') AND type in (N'U'))
DROP TABLE [dbo].[PE_DeliverType]
GO
/****** Object:  Table [dbo].[PE_Department]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Department]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Department]
GO
/****** Object:  Table [dbo].[PE_Department_Members]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Department_Members]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Department_Members]
GO
/****** Object:  Table [dbo].[PE_Dictionary]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Dictionary]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Dictionary]
GO
/****** Object:  Table [dbo].[PE_DownloadError]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_DownloadError]') AND type in (N'U'))
DROP TABLE [dbo].[PE_DownloadError]
GO
/****** Object:  Table [dbo].[PE_DownServer]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_DownServer]') AND type in (N'U'))
DROP TABLE [dbo].[PE_DownServer]
GO
/****** Object:  Table [dbo].[PE_Favorite]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Favorite]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Favorite]
GO
/****** Object:  Table [dbo].[PE_Files]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Files]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Files]
GO
/****** Object:  Table [dbo].[PE_FlowProcess]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_FlowProcess]') AND type in (N'U'))
DROP TABLE [dbo].[PE_FlowProcess]
GO
/****** Object:  Table [dbo].[PE_Friend]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Friend]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Friend]
GO
/****** Object:  Table [dbo].[PE_GroupFieldPermissions]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_GroupFieldPermissions]') AND type in (N'U'))
DROP TABLE [dbo].[PE_GroupFieldPermissions]
GO
/****** Object:  Table [dbo].[PE_GroupNodePermissions]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_GroupNodePermissions]') AND type in (N'U'))
DROP TABLE [dbo].[PE_GroupNodePermissions]
GO
/****** Object:  Table [dbo].[PE_GroupSpecialCategoryPermissions]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_GroupSpecialCategoryPermissions]') AND type in (N'U'))
DROP TABLE [dbo].[PE_GroupSpecialCategoryPermissions]
GO
/****** Object:  Table [dbo].[PE_GroupSpecialPermissions]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_GroupSpecialPermissions]') AND type in (N'U'))
DROP TABLE [dbo].[PE_GroupSpecialPermissions]
GO
/****** Object:  Table [dbo].[PE_IncludeFile]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_IncludeFile]') AND type in (N'U'))
DROP TABLE [dbo].[PE_IncludeFile]
GO
/****** Object:  Table [dbo].[PE_Indent]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Indent]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Indent]
GO
/****** Object:  Table [dbo].[PE_IndentItem]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_IndentItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_IndentItem]
GO
/****** Object:  Table [dbo].[PE_InfoFileRelation]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_InfoFileRelation]') AND type in (N'U'))
DROP TABLE [dbo].[PE_InfoFileRelation]
GO
/****** Object:  Table [dbo].[PE_InfoNextProcessRoles]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_InfoNextProcessRoles]') AND type in (N'U'))
DROP TABLE [dbo].[PE_InfoNextProcessRoles]
GO
/****** Object:  Table [dbo].[PE_InvoiceItem]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_InvoiceItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_InvoiceItem]
GO
/****** Object:  Table [dbo].[PE_KeywordRelationShip]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_KeywordRelationShip]') AND type in (N'U'))
DROP TABLE [dbo].[PE_KeywordRelationShip]
GO
/****** Object:  Table [dbo].[PE_Keywords]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Keywords]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Keywords]
GO
/****** Object:  Table [dbo].[PE_Log]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Log]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Log]
GO
/****** Object:  Table [dbo].[PE_MailList]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_MailList]') AND type in (N'U'))
DROP TABLE [dbo].[PE_MailList]
GO
/****** Object:  Table [dbo].[PE_MailList_SubscriptionItem]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_MailList_SubscriptionItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_MailList_SubscriptionItem]
GO
/****** Object:  Table [dbo].[PE_Message]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Message]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Message]
GO
/****** Object:  Table [dbo].[PE_Model]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Model]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Model]
GO
/****** Object:  Table [dbo].[PE_Model_FilterField]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Model_FilterField]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Model_FilterField]
GO
/****** Object:  Table [dbo].[PE_ModelTemplates]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ModelTemplates]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ModelTemplates]
GO
/****** Object:  Table [dbo].[PE_Mood]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Mood]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Mood]
GO
/****** Object:  Table [dbo].[PE_MoodScheme]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_MoodScheme]') AND type in (N'U'))
DROP TABLE [dbo].[PE_MoodScheme]
GO
/****** Object:  Table [dbo].[PE_Nodes]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Nodes]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Nodes]
GO
/****** Object:  Table [dbo].[PE_Nodes_Model_Template]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Nodes_Model_Template]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Nodes_Model_Template]
GO
/****** Object:  Table [dbo].[PE_Nodes_Template]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Nodes_Template]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Nodes_Template]
GO
/****** Object:  Table [dbo].[PE_OrderFeedback]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_OrderFeedback]') AND type in (N'U'))
DROP TABLE [dbo].[PE_OrderFeedback]
GO
/****** Object:  Table [dbo].[PE_OrderHistory]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_OrderHistory]') AND type in (N'U'))
DROP TABLE [dbo].[PE_OrderHistory]
GO
/****** Object:  Table [dbo].[PE_OrderHistoryItem]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_OrderHistoryItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_OrderHistoryItem]
GO
/****** Object:  Table [dbo].[PE_OrderItem]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_OrderItem]
GO
/****** Object:  Table [dbo].[PE_Orders]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Orders]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Orders]
GO
/****** Object:  Table [dbo].[PE_OutOfStockLog]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_OutOfStockLog]') AND type in (N'U'))
DROP TABLE [dbo].[PE_OutOfStockLog]
GO
/****** Object:  Table [dbo].[PE_Package]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Package]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Package]
GO
/****** Object:  Table [dbo].[PE_PaymentLog]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PaymentLog]') AND type in (N'U'))
DROP TABLE [dbo].[PE_PaymentLog]
GO
/****** Object:  Table [dbo].[PE_PaymentType]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PaymentType]') AND type in (N'U'))
DROP TABLE [dbo].[PE_PaymentType]
GO
/****** Object:  Table [dbo].[PE_PayPlatForm]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PayPlatForm]') AND type in (N'U'))
DROP TABLE [dbo].[PE_PayPlatForm]
GO
/****** Object:  Table [dbo].[PE_PC_PreConsultation]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PC_PreConsultation]') AND type in (N'U'))
DROP TABLE [dbo].[PE_PC_PreConsultation]
GO
/****** Object:  Table [dbo].[PE_PC_PreConsultationReply]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PC_PreConsultationReply]') AND type in (N'U'))
DROP TABLE [dbo].[PE_PC_PreConsultationReply]
GO
/****** Object:  Table [dbo].[PE_PM_CommissionDetail]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PM_CommissionDetail]') AND type in (N'U'))
DROP TABLE [dbo].[PE_PM_CommissionDetail]
GO
/****** Object:  Table [dbo].[PE_PM_GatheringDetail]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PM_GatheringDetail]') AND type in (N'U'))
DROP TABLE [dbo].[PE_PM_GatheringDetail]
GO
/****** Object:  Table [dbo].[PE_PM_Promotion]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PM_Promotion]') AND type in (N'U'))
DROP TABLE [dbo].[PE_PM_Promotion]
GO
/****** Object:  Table [dbo].[PE_PM_PromotionOrder]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PM_PromotionOrder]') AND type in (N'U'))
DROP TABLE [dbo].[PE_PM_PromotionOrder]
GO
/****** Object:  Table [dbo].[PE_PM_RegisterPromotion]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PM_RegisterPromotion]') AND type in (N'U'))
DROP TABLE [dbo].[PE_PM_RegisterPromotion]
GO
/****** Object:  Table [dbo].[PE_PM_UserAccount]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PM_UserAccount]') AND type in (N'U'))
DROP TABLE [dbo].[PE_PM_UserAccount]
GO
/****** Object:  Table [dbo].[PE_PointLog]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PointLog]') AND type in (N'U'))
DROP TABLE [dbo].[PE_PointLog]
GO
/****** Object:  Table [dbo].[PE_Present]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Present]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Present]
GO
/****** Object:  Table [dbo].[PE_PresentProject]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PresentProject]') AND type in (N'U'))
DROP TABLE [dbo].[PE_PresentProject]
GO
/****** Object:  Table [dbo].[PE_Process_Roles]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Process_Roles]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Process_Roles]
GO
/****** Object:  Table [dbo].[PE_ProcessStatusCode]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ProcessStatusCode]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ProcessStatusCode]
GO
/****** Object:  Table [dbo].[PE_Producer]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Producer]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Producer]
GO
/****** Object:  Table [dbo].[PE_ProductData]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ProductData]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ProductData]
GO
/****** Object:  Table [dbo].[PE_ProductPrice]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ProductPrice]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ProductPrice]
GO
/****** Object:  Table [dbo].[PE_Provider]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Provider]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Provider]
GO
/****** Object:  Table [dbo].[PE_RedirectCategory]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_RedirectCategory]') AND type in (N'U'))
DROP TABLE [dbo].[PE_RedirectCategory]
GO
/****** Object:  Table [dbo].[PE_RedirectUrl]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_RedirectUrl]') AND type in (N'U'))
DROP TABLE [dbo].[PE_RedirectUrl]
GO
/****** Object:  Table [dbo].[PE_Region]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Region]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Region]
GO
/****** Object:  Table [dbo].[PE_RemindItem]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_RemindItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_RemindItem]
GO
/****** Object:  Table [dbo].[PE_Role_Field_Permissions]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Role_Field_Permissions]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Role_Field_Permissions]
GO
/****** Object:  Table [dbo].[PE_Role_Node_Permissions]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Role_Node_Permissions]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Role_Node_Permissions]
GO
/****** Object:  Table [dbo].[PE_Role_Special_Permissions]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Role_Special_Permissions]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Role_Special_Permissions]
GO
/****** Object:  Table [dbo].[PE_Roles]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Roles]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Roles]
GO
/****** Object:  Table [dbo].[PE_Roles_Permissions]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Roles_Permissions]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Roles_Permissions]
GO
/****** Object:  Table [dbo].[PE_Roles_ScopePermissions]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Roles_ScopePermissions]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Roles_ScopePermissions]
GO
/****** Object:  Table [dbo].[PE_ScreenShot]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ScreenShot]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ScreenShot]
GO
/****** Object:  Table [dbo].[PE_SendBack]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SendBack]') AND type in (N'U'))
DROP TABLE [dbo].[PE_SendBack]
GO
/****** Object:  Table [dbo].[PE_SendBackItem]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SendBackItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_SendBackItem]
GO
/****** Object:  Table [dbo].[PE_ServiceItem]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ServiceItem]
GO
/****** Object:  Table [dbo].[PE_ShoppingCarts]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ShoppingCarts]
GO
/****** Object:  Table [dbo].[PE_SigninContent]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SigninContent]') AND type in (N'U'))
DROP TABLE [dbo].[PE_SigninContent]
GO
/****** Object:  Table [dbo].[PE_SigninLog]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SigninLog]') AND type in (N'U'))
DROP TABLE [dbo].[PE_SigninLog]
GO
/****** Object:  Table [dbo].[PE_Source]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Source]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Source]
GO
/****** Object:  Table [dbo].[PE_SpecialCategory]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SpecialCategory]') AND type in (N'U'))
DROP TABLE [dbo].[PE_SpecialCategory]
GO
/****** Object:  Table [dbo].[PE_SpecialInfos]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SpecialInfos]') AND type in (N'U'))
DROP TABLE [dbo].[PE_SpecialInfos]
GO
/****** Object:  Table [dbo].[PE_Specials]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Specials]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Specials]
GO
/****** Object:  Table [dbo].[PE_StatAddress]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatAddress]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatAddress]
GO
/****** Object:  Table [dbo].[PE_StatBrowser]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatBrowser]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatBrowser]
GO
/****** Object:  Table [dbo].[PE_StatColor]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatColor]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatColor]
GO
/****** Object:  Table [dbo].[PE_StatDay]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatDay]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatDay]
GO
/****** Object:  Table [dbo].[PE_StatInfoList]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatInfoList]
GO
/****** Object:  Table [dbo].[PE_StatIp]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatIp]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatIp]
GO
/****** Object:  Table [dbo].[PE_StatIpInfo]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatIpInfo]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatIpInfo]
GO
/****** Object:  Table [dbo].[PE_StatKeyword]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatKeyword]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatKeyword]
GO
/****** Object:  Table [dbo].[PE_StatMonth]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatMonth]
GO
/****** Object:  Table [dbo].[PE_StatMozilla]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatMozilla]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatMozilla]
GO
/****** Object:  Table [dbo].[PE_StatOnline]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatOnline]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatOnline]
GO
/****** Object:  Table [dbo].[PE_StatRefer]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatRefer]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatRefer]
GO
/****** Object:  Table [dbo].[PE_StatScreen]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatScreen]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatScreen]
GO
/****** Object:  Table [dbo].[PE_StatSystem]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatSystem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatSystem]
GO
/****** Object:  Table [dbo].[PE_StatTimezone]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatTimezone]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatTimezone]
GO
/****** Object:  Table [dbo].[PE_Status]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Status]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Status]
GO
/****** Object:  Table [dbo].[PE_StatVisit]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatVisit]
GO
/****** Object:  Table [dbo].[PE_StatVisitor]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatVisitor]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatVisitor]
GO
/****** Object:  Table [dbo].[PE_StatWeburl]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatWeburl]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatWeburl]
GO
/****** Object:  Table [dbo].[PE_StatWeek]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatWeek]
GO
/****** Object:  Table [dbo].[PE_StatYear]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatYear]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StatYear]
GO
/****** Object:  Table [dbo].[PE_Stock]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Stock]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Stock]
GO
/****** Object:  Table [dbo].[PE_StockItem]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StockItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_StockItem]
GO
/****** Object:  Table [dbo].[PE_SubscriptionItems]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SubscriptionItems]') AND type in (N'U'))
DROP TABLE [dbo].[PE_SubscriptionItems]
GO
/****** Object:  Table [dbo].[PE_Survey]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Survey]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Survey]
GO
/****** Object:  Table [dbo].[PE_SurveyVote]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SurveyVote]') AND type in (N'U'))
DROP TABLE [dbo].[PE_SurveyVote]
GO
/****** Object:  Table [dbo].[PE_Trademark]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Trademark]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Trademark]
GO
/****** Object:  Table [dbo].[PE_TransferLog]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_TransferLog]') AND type in (N'U'))
DROP TABLE [dbo].[PE_TransferLog]
GO
/****** Object:  Table [dbo].[PE_UserExpLog]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_UserExpLog]') AND type in (N'U'))
DROP TABLE [dbo].[PE_UserExpLog]
GO
/****** Object:  Table [dbo].[PE_UserGroups]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_UserGroups]') AND type in (N'U'))
DROP TABLE [dbo].[PE_UserGroups]
GO
/****** Object:  Table [dbo].[PE_UserHitHistory]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_UserHitHistory]') AND type in (N'U'))
DROP TABLE [dbo].[PE_UserHitHistory]
GO
/****** Object:  Table [dbo].[PE_Users]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Users]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Users]
GO
/****** Object:  Table [dbo].[PE_ValidLog]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ValidLog]') AND type in (N'U'))
DROP TABLE [dbo].[PE_ValidLog]
GO
/****** Object:  Table [dbo].[PE_Version]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Version]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Version]
GO
/****** Object:  Table [dbo].[PE_Vote]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Vote]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Vote]
GO
/****** Object:  Table [dbo].[PE_VT_UserVoteTotal]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_VT_UserVoteTotal]') AND type in (N'U'))
DROP TABLE [dbo].[PE_VT_UserVoteTotal]
GO
/****** Object:  Table [dbo].[PE_VT_Vote]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_VT_Vote]') AND type in (N'U'))
DROP TABLE [dbo].[PE_VT_Vote]
GO
/****** Object:  Table [dbo].[PE_VT_VoteItem]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_VT_VoteItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_VT_VoteItem]
GO
/****** Object:  Table [dbo].[PE_Wap_Article]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Wap_Article]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Wap_Article]
GO
/****** Object:  Table [dbo].[PE_Wap_Category]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Wap_Category]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Wap_Category]
GO
/****** Object:  Table [dbo].[PE_Wap_Token]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Wap_Token]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Wap_Token]
GO
/****** Object:  Table [dbo].[PE_WordReplaceItem]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_WordReplaceItem]') AND type in (N'U'))
DROP TABLE [dbo].[PE_WordReplaceItem]
GO
/****** Object:  Table [dbo].[PE_Work]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Work]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Work]
GO
/****** Object:  Table [dbo].[PE_WorkCategory]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_WorkCategory]') AND type in (N'U'))
DROP TABLE [dbo].[PE_WorkCategory]
GO
/****** Object:  Table [dbo].[PE_WorkCategoryCustomForm]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_WorkCategoryCustomForm]') AND type in (N'U'))
DROP TABLE [dbo].[PE_WorkCategoryCustomForm]
GO
/****** Object:  Table [dbo].[PE_WorkFlows]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_WorkFlows]') AND type in (N'U'))
DROP TABLE [dbo].[PE_WorkFlows]
GO
/****** Object:  Table [dbo].[PE_WorkNextProcessRoles]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_WorkNextProcessRoles]') AND type in (N'U'))
DROP TABLE [dbo].[PE_WorkNextProcessRoles]
GO
/****** Object:  Table [dbo].[PE_Zone_Advertisement]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Zone_Advertisement]') AND type in (N'U'))
DROP TABLE [dbo].[PE_Zone_Advertisement]
GO
/****** Object:  Default [DF_PE_Address_IsDefalult]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Address_IsDefalult]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Address]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Address_IsDefalult]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Address] DROP CONSTRAINT [DF_PE_Address_IsDefalult]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_ADType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_ADType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_ADType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] DROP CONSTRAINT [DF_PE_Advertisement_ADType]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_FlashWmode]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_FlashWmode]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_FlashWmode]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] DROP CONSTRAINT [DF_PE_Advertisement_FlashWmode]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_LinkTarget]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_LinkTarget]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_LinkTarget]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] DROP CONSTRAINT [DF_PE_Advertisement_LinkTarget]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_CountView]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_CountView]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_CountView]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] DROP CONSTRAINT [DF_PE_Advertisement_CountView]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_Views]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_Views]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_Views]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] DROP CONSTRAINT [DF_PE_Advertisement_Views]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_CountClick]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_CountClick]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_CountClick]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] DROP CONSTRAINT [DF_PE_Advertisement_CountClick]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_Clicks]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_Clicks]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_Clicks]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] DROP CONSTRAINT [DF_PE_Advertisement_Clicks]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_AbsolutePath]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_AbsolutePath]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_AbsolutePath]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] DROP CONSTRAINT [DF_PE_Advertisement_AbsolutePath]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_Passed]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_Passed]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_Passed]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] DROP CONSTRAINT [DF_PE_Advertisement_Passed]
END


End
GO
/****** Object:  Default [DF_PE_AdZone_ZoneType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_AdZone_ZoneType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_AdZone]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_AdZone_ZoneType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_AdZone] DROP CONSTRAINT [DF_PE_AdZone_ZoneType]
END


End
GO
/****** Object:  Default [DF_PE_AdZone_DefaultSetting]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_AdZone_DefaultSetting]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_AdZone]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_AdZone_DefaultSetting]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_AdZone] DROP CONSTRAINT [DF_PE_AdZone_DefaultSetting]
END


End
GO
/****** Object:  Default [DF_PE_AdZone_ZoneWidth]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_AdZone_ZoneWidth]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_AdZone]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_AdZone_ZoneWidth]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_AdZone] DROP CONSTRAINT [DF_PE_AdZone_ZoneWidth]
END


End
GO
/****** Object:  Default [DF_PE_AdZone_ZoneHeight]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_AdZone_ZoneHeight]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_AdZone]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_AdZone_ZoneHeight]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_AdZone] DROP CONSTRAINT [DF_PE_AdZone_ZoneHeight]
END


End
GO
/****** Object:  Default [DF_PE_AdZone_Active]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_AdZone_Active]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_AdZone]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_AdZone_Active]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_AdZone] DROP CONSTRAINT [DF_PE_AdZone_Active]
END


End
GO
/****** Object:  Default [DF_PE_AdZone_ShowType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_AdZone_ShowType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_AdZone]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_AdZone_ShowType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_AdZone] DROP CONSTRAINT [DF_PE_AdZone_ShowType]
END


End
GO
/****** Object:  Default [DF_PE_Author_UserID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_UserID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_UserID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] DROP CONSTRAINT [DF_PE_Author_UserID]
END


End
GO
/****** Object:  Default [DF_PE_Author_Passed]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_Passed]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_Passed]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] DROP CONSTRAINT [DF_PE_Author_Passed]
END


End
GO
/****** Object:  Default [DF_PE_Author_onTop]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_onTop]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_onTop]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] DROP CONSTRAINT [DF_PE_Author_onTop]
END


End
GO
/****** Object:  Default [DF_PE_Author_IsElite]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_IsElite]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_IsElite]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] DROP CONSTRAINT [DF_PE_Author_IsElite]
END


End
GO
/****** Object:  Default [DF_PE_Author_Hits]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_Hits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_Hits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] DROP CONSTRAINT [DF_PE_Author_Hits]
END


End
GO
/****** Object:  Default [DF_PE_Author_TemplateID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_TemplateID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_TemplateID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] DROP CONSTRAINT [DF_PE_Author_TemplateID]
END


End
GO
/****** Object:  Default [DF_PE_Author_ZipCode]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_ZipCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_ZipCode]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] DROP CONSTRAINT [DF_PE_Author_ZipCode]
END


End
GO
/****** Object:  Default [DF_PE_Author_Sex]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_Sex]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_Sex]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] DROP CONSTRAINT [DF_PE_Author_Sex]
END


End
GO
/****** Object:  Default [DF_PE_Bank_OrderID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Bank_OrderID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Bank]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Bank_OrderID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Bank] DROP CONSTRAINT [DF_PE_Bank_OrderID]
END


End
GO
/****** Object:  Default [DF_PE_Bank_IsDefault]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Bank_IsDefault]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Bank]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Bank_IsDefault]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Bank] DROP CONSTRAINT [DF_PE_Bank_IsDefault]
END


End
GO
/****** Object:  Default [DF_PE_Bank_IsDisabled]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Bank_IsDisabled]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Bank]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Bank_IsDisabled]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Bank] DROP CONSTRAINT [DF_PE_Bank_IsDisabled]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_ClientID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] DROP CONSTRAINT [DF_PE_BankrollItem_ClientID]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_Money]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_Money]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_Money]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] DROP CONSTRAINT [DF_PE_BankrollItem_Money]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_MoneyType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_MoneyType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_MoneyType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] DROP CONSTRAINT [DF_PE_BankrollItem_MoneyType]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_CurrencyType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_CurrencyType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_CurrencyType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] DROP CONSTRAINT [DF_PE_BankrollItem_CurrencyType]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_eBankID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_eBankID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_eBankID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] DROP CONSTRAINT [DF_PE_BankrollItem_eBankID]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_OrderFormID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_OrderFormID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_OrderFormID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] DROP CONSTRAINT [DF_PE_BankrollItem_OrderFormID]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_PaymentID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_PaymentID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_PaymentID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] DROP CONSTRAINT [DF_PE_BankrollItem_PaymentID]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_Status]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_Status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] DROP CONSTRAINT [DF_PE_BankrollItem_Status]
END


End
GO
/****** Object:  Default [DF_PE_Cards_CardType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Cards_CardType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Cards]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Cards_CardType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Cards] DROP CONSTRAINT [DF_PE_Cards_CardType]
END


End
GO
/****** Object:  Default [DF_PE_Cards_ProductID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Cards_ProductID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Cards]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Cards_ProductID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Cards] DROP CONSTRAINT [DF_PE_Cards_ProductID]
END


End
GO
/****** Object:  Default [DF_PE_Card_Money]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Card_Money]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Cards]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Card_Money]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Cards] DROP CONSTRAINT [DF_PE_Card_Money]
END


End
GO
/****** Object:  Default [DF_PE_Card_ValidNum]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Card_ValidNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Cards]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Card_ValidNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Cards] DROP CONSTRAINT [DF_PE_Card_ValidNum]
END


End
GO
/****** Object:  Default [DF_PE_Card_ValidUnit]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Card_ValidUnit]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Cards]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Card_ValidUnit]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Cards] DROP CONSTRAINT [DF_PE_Card_ValidUnit]
END


End
GO
/****** Object:  Default [DF_PE_Card_OrderItemID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Card_OrderItemID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Cards]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Card_OrderItemID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Cards] DROP CONSTRAINT [DF_PE_Card_OrderItemID]
END


End
GO
/****** Object:  Default [DF_PE_Client_ClientID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_ClientID]
END


End
GO
/****** Object:  Default [DF_PE_Client_ParentID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ParentID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ParentID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_ParentID]
END


End
GO
/****** Object:  Default [DF_PE_Client_ClientType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ClientType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ClientType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_ClientType]
END


End
GO
/****** Object:  Default [DF_PE_Client_Area]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_Area]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_Area]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_Area]
END


End
GO
/****** Object:  Default [DF_PE_Client_ClientField]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ClientField]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ClientField]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_ClientField]
END


End
GO
/****** Object:  Default [DF_PE_Client_ValueLevel]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ValueLevel]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ValueLevel]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_ValueLevel]
END


End
GO
/****** Object:  Default [DF_PE_Client_CreditLevel]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_CreditLevel]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_CreditLevel]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_CreditLevel]
END


End
GO
/****** Object:  Default [DF_PE_Client_Importance]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_Importance]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_Importance]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_Importance]
END


End
GO
/****** Object:  Default [DF_PE_Client_ConnectionLevel]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ConnectionLevel]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ConnectionLevel]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_ConnectionLevel]
END


End
GO
/****** Object:  Default [DF_PE_Client_GroupID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_GroupID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_GroupID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_GroupID]
END


End
GO
/****** Object:  Default [DF_PE_Client_SourceType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_SourceType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_SourceType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_SourceType]
END


End
GO
/****** Object:  Default [DF_PE_Client_PhaseType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_PhaseType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_PhaseType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_PhaseType]
END


End
GO
/****** Object:  Default [DF_PE_Client_VisitTimes]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_VisitTimes]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_VisitTimes]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_VisitTimes]
END


End
GO
/****** Object:  Default [DF_PE_Client_ServiceTimes]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ServiceTimes]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ServiceTimes]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_ServiceTimes]
END


End
GO
/****** Object:  Default [DF_PE_Client_ComplainTimes]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ComplainTimes]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ComplainTimes]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_ComplainTimes]
END


End
GO
/****** Object:  Default [DF_PE_Client_Balance]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_Balance]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_Balance]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] DROP CONSTRAINT [DF_PE_Client_Balance]
END


End
GO
/****** Object:  Default [DF_PE_CollectionExclosion_ExclosionStringType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionExclosion_ExclosionStringType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionExclosion]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionExclosion_ExclosionStringType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionExclosion] DROP CONSTRAINT [DF_PE_CollectionExclosion_ExclosionStringType]
END


End
GO
/****** Object:  Default [DF_PE_CollectionFieldRules_RuleType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionFieldRules_RuleType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionFieldRules]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionFieldRules_RuleType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionFieldRules] DROP CONSTRAINT [DF_PE_CollectionFieldRules_RuleType]
END


End
GO
/****** Object:  Default [DF_PE_CollectionFieldRules_UsePaging]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionFieldRules_UsePaging]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionFieldRules]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionFieldRules_UsePaging]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionFieldRules] DROP CONSTRAINT [DF_PE_CollectionFieldRules_UsePaging]
END


End
GO
/****** Object:  Default [DF_PE_CollectionFilterRules_FilterType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionFilterRules_FilterType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionFilterRules]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionFilterRules_FilterType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionFilterRules] DROP CONSTRAINT [DF_PE_CollectionFilterRules_FilterType]
END


End
GO
/****** Object:  Default [DF_PE_CollectionItem_MaxNum]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionItem_MaxNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionItem_MaxNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionItem] DROP CONSTRAINT [DF_PE_CollectionItem_MaxNum]
END


End
GO
/****** Object:  Default [DF_PE_CollectionItem_Detection]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionItem_Detection]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionItem_Detection]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionItem] DROP CONSTRAINT [DF_PE_CollectionItem_Detection]
END


End
GO
/****** Object:  Default [DF_PE_CollectionListRules_UsePaging]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionListRules_UsePaging]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionListRules]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionListRules_UsePaging]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionListRules] DROP CONSTRAINT [DF_PE_CollectionListRules_UsePaging]
END


End
GO
/****** Object:  Default [DF_PE_CollectionPagingRules_CorrelationRuleId]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionPagingRules_CorrelationRuleId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionPagingRules]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionPagingRules_CorrelationRuleId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionPagingRules] DROP CONSTRAINT [DF_PE_CollectionPagingRules_CorrelationRuleId]
END


End
GO
/****** Object:  Default [DF_PE_CollectionPagingRules_RuleType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionPagingRules_RuleType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionPagingRules]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionPagingRules_RuleType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionPagingRules] DROP CONSTRAINT [DF_PE_CollectionPagingRules_RuleType]
END


End
GO
/****** Object:  Default [DF_PE_CollectionPagingRules_PagingType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionPagingRules_PagingType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionPagingRules]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionPagingRules_PagingType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionPagingRules] DROP CONSTRAINT [DF_PE_CollectionPagingRules_PagingType]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_Hits]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_Hits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_Hits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] DROP CONSTRAINT [DF_PE_CommonModel_Hits]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_DayHits]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_DayHits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_DayHits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] DROP CONSTRAINT [DF_PE_CommonModel_DayHits]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_WeekHits]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_WeekHits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_WeekHits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] DROP CONSTRAINT [DF_PE_CommonModel_WeekHits]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_MonthHits]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_MonthHits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_MonthHits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] DROP CONSTRAINT [DF_PE_CommonModel_MonthHits]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_LinkType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_LinkType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_LinkType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] DROP CONSTRAINT [DF_PE_CommonModel_LinkType]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_CommentAudited]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_CommentAudited]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_CommentAudited]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] DROP CONSTRAINT [DF_PE_CommonModel_CommentAudited]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_CommentUnAudited]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_CommentUnAudited]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_CommentUnAudited]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] DROP CONSTRAINT [DF_PE_CommonModel_CommentUnAudited]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_SigninType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_SigninType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_SigninType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] DROP CONSTRAINT [DF_PE_CommonModel_SigninType]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_SGType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_SGType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_SGType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] DROP CONSTRAINT [DF_PE_CommonModel_SGType]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_SGDataId]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_SGDataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_SGDataId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] DROP CONSTRAINT [DF_PE_CommonModel_SGDataId]
END


End
GO
/****** Object:  Default [DF_PE_CommonProduct_ProductCharacter]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonProduct_ProductCharacter]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonProduct]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonProduct_ProductCharacter]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonProduct] DROP CONSTRAINT [DF_PE_CommonProduct_ProductCharacter]
END


End
GO
/****** Object:  Default [DF_PE_Company_CompanyID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Company_CompanyID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Company]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Company_CompanyID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Company] DROP CONSTRAINT [DF_PE_Company_CompanyID]
END


End
GO
/****** Object:  Default [DF_PE_Company_ClientID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Company_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Company]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Company_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Company] DROP CONSTRAINT [DF_PE_Company_ClientID]
END


End
GO
/****** Object:  Default [DF_PE_Company_StatusInField]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Company_StatusInField]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Company]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Company_StatusInField]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Company] DROP CONSTRAINT [DF_PE_Company_StatusInField]
END


End
GO
/****** Object:  Default [DF_PE_Company_CompanySize]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Company_CompanySize]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Company]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Company_CompanySize]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Company] DROP CONSTRAINT [DF_PE_Company_CompanySize]
END


End
GO
/****** Object:  Default [DF_PE_Company_ManagementForms]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Company_ManagementForms]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Company]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Company_ManagementForms]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Company] DROP CONSTRAINT [DF_PE_Company_ManagementForms]
END


End
GO
/****** Object:  Default [DF_PE_ComplainItem_ClientID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ComplainItem_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ComplainItem_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ComplainItem] DROP CONSTRAINT [DF_PE_ComplainItem_ClientID]
END


End
GO
/****** Object:  Default [DF_PE_ComplainItem_ContacterID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ComplainItem_ContacterID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ComplainItem_ContacterID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ComplainItem] DROP CONSTRAINT [DF_PE_ComplainItem_ContacterID]
END


End
GO
/****** Object:  Default [DF_PE_ComplainItem_ComplainType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ComplainItem_ComplainType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ComplainItem_ComplainType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ComplainItem] DROP CONSTRAINT [DF_PE_ComplainItem_ComplainType]
END


End
GO
/****** Object:  Default [DF_PE_ComplainItem_ComplainMode]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ComplainItem_ComplainMode]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ComplainItem_ComplainMode]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ComplainItem] DROP CONSTRAINT [DF_PE_ComplainItem_ComplainMode]
END


End
GO
/****** Object:  Default [DF_PE_ComplainItem_MagnitudeOfExigence]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ComplainItem_MagnitudeOfExigence]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ComplainItem_MagnitudeOfExigence]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ComplainItem] DROP CONSTRAINT [DF_PE_ComplainItem_MagnitudeOfExigence]
END


End
GO
/****** Object:  Default [DF_PE_ComplainItem_ConfirmScore]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ComplainItem_ConfirmScore]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ComplainItem_ConfirmScore]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ComplainItem] DROP CONSTRAINT [DF_PE_ComplainItem_ConfirmScore]
END


End
GO
/****** Object:  Default [DF_PE_ComplainItem_Status]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ComplainItem_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ComplainItem_Status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ComplainItem] DROP CONSTRAINT [DF_PE_ComplainItem_Status]
END


End
GO
/****** Object:  Default [DF_PE_Contacter_ContacterID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Contacter_ContacterID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Contacter]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Contacter_ContacterID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Contacter] DROP CONSTRAINT [DF_PE_Contacter_ContacterID]
END


End
GO
/****** Object:  Default [DF_PE_Contacter_ClientID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Contacter_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Contacter]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Contacter_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Contacter] DROP CONSTRAINT [DF_PE_Contacter_ClientID]
END


End
GO
/****** Object:  Default [DF_PE_Contacter_ParentID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Contacter_ParentID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Contacter]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Contacter_ParentID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Contacter] DROP CONSTRAINT [DF_PE_Contacter_ParentID]
END


End
GO
/****** Object:  Default [DF_PE_Contacter_Education]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Contacter_Education]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Contacter]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Contacter_Education]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Contacter] DROP CONSTRAINT [DF_PE_Contacter_Education]
END


End
GO
/****** Object:  Default [DF_PE_ContentCharge_ChargeType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentCharge_ChargeType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ContentCharge]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentCharge_ChargeType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ContentCharge] DROP CONSTRAINT [DF_PE_ContentCharge_ChargeType]
END


End
GO
/****** Object:  Default [DF_PE_ContentCharge_InfoPoint]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentCharge_InfoPoint]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ContentCharge]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentCharge_InfoPoint]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ContentCharge] DROP CONSTRAINT [DF_PE_ContentCharge_InfoPoint]
END


End
GO
/****** Object:  Default [DF_PE_ContentCharge_DividePercent]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentCharge_DividePercent]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ContentCharge]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentCharge_DividePercent]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ContentCharge] DROP CONSTRAINT [DF_PE_ContentCharge_DividePercent]
END


End
GO
/****** Object:  Default [DF_PE_ContentPermission_GeneralId]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentPermission_GeneralId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ContentPermission]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentPermission_GeneralId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ContentPermission] DROP CONSTRAINT [DF_PE_ContentPermission_GeneralId]
END


End
GO
/****** Object:  Default [DF_PE_ContentPermission_PermissionType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentPermission_PermissionType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ContentPermission]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentPermission_PermissionType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ContentPermission] DROP CONSTRAINT [DF_PE_ContentPermission_PermissionType]
END


End
GO
/****** Object:  Default [DF_PE_CouponItem_OrderID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CouponItem_OrderID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CouponItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CouponItem_OrderID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CouponItem] DROP CONSTRAINT [DF_PE_CouponItem_OrderID]
END


End
GO
/****** Object:  Default [DF_PE_DeliverCharge_DeliverTypeID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverCharge_DeliverTypeID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverCharge_DeliverTypeID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverCharge] DROP CONSTRAINT [DF_PE_DeliverCharge_DeliverTypeID]
END


End
GO
/****** Object:  Default [DF_PE_DeliverCharge_AreaType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverCharge_AreaType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverCharge_AreaType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverCharge] DROP CONSTRAINT [DF_PE_DeliverCharge_AreaType]
END


End
GO
/****** Object:  Default [DF_PE_DeliverCharge_Charge_Min]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverCharge_Charge_Min]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverCharge_Charge_Min]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverCharge] DROP CONSTRAINT [DF_PE_DeliverCharge_Charge_Min]
END


End
GO
/****** Object:  Default [DF_PE_DeliverCharge_Weight_Min]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverCharge_Weight_Min]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverCharge_Weight_Min]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverCharge] DROP CONSTRAINT [DF_PE_DeliverCharge_Weight_Min]
END


End
GO
/****** Object:  Default [DF_PE_DeliverCharge_ChargePerUnit]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverCharge_ChargePerUnit]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverCharge_ChargePerUnit]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverCharge] DROP CONSTRAINT [DF_PE_DeliverCharge_ChargePerUnit]
END


End
GO
/****** Object:  Default [DF_PE_DeliverCharge_WeightPerUnit]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverCharge_WeightPerUnit]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverCharge_WeightPerUnit]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverCharge] DROP CONSTRAINT [DF_PE_DeliverCharge_WeightPerUnit]
END


End
GO
/****** Object:  Default [DF_PE_DeliverCharge_Charge_Max]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverCharge_Charge_Max]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverCharge_Charge_Max]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverCharge] DROP CONSTRAINT [DF_PE_DeliverCharge_Charge_Max]
END


End
GO
/****** Object:  Default [DF_PE_DeliverItem_OrderID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverItem_OrderID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverItem_OrderID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverItem] DROP CONSTRAINT [DF_PE_DeliverItem_OrderID]
END


End
GO
/****** Object:  Default [DF_PE_DeliverItem_DeliverDirection]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverItem_DeliverDirection]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverItem_DeliverDirection]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverItem] DROP CONSTRAINT [DF_PE_DeliverItem_DeliverDirection]
END


End
GO
/****** Object:  Default [DF_PE_DeliverItem_Received]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverItem_Received]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverItem_Received]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverItem] DROP CONSTRAINT [DF_PE_DeliverItem_Received]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_ChargeType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_ChargeType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_ChargeType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_ChargeType]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_IsDefault]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_IsDefault]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_IsDefault]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_IsDefault]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_IsDisabled]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_IsDisabled]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_IsDisabled]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_IsDisabled]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_OrderID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_OrderID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_OrderID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_OrderID]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_ReleaseType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_ReleaseType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_ReleaseType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_ReleaseType]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_MinMoney1]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_MinMoney1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_MinMoney1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_MinMoney1]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_ReleaseCharge]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_ReleaseCharge]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_ReleaseCharge]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_ReleaseCharge]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_Minmoney2]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_Minmoney2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_Minmoney2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_Minmoney2]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_MaxCharge]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_MaxCharge]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_MaxCharge]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_MaxCharge]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_MinMoney3]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_MinMoney3]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_MinMoney3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_MinMoney3]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_Charge_Min]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_Charge_Min]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_Charge_Min]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_Charge_Min]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_Charge_Max]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_Charge_Max]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_Charge_Max]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_Charge_Max]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_Charge_Percent]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_Charge_Percent]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_Charge_Percent]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_Charge_Percent]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_IncludeTax]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_IncludeTax]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_IncludeTax]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_IncludeTax]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_TaxRate]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_TaxRate]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_TaxRate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] DROP CONSTRAINT [DF_PE_DeliverType_TaxRate]
END


End
GO
/****** Object:  Default [DF_PE_Indent_Status]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Indent_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Indent]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Indent_Status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Indent] DROP CONSTRAINT [DF_PE_Indent_Status]
END


End
GO
/****** Object:  Default [DF_PE_InfoFileRelation_InfoID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_InfoFileRelation_InfoID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_InfoFileRelation]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_InfoFileRelation_InfoID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_InfoFileRelation] DROP CONSTRAINT [DF_PE_InfoFileRelation_InfoID]
END


End
GO
/****** Object:  Default [DF_PE_InvoiceItem_ClientID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_InvoiceItem_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_InvoiceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_InvoiceItem_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_InvoiceItem] DROP CONSTRAINT [DF_PE_InvoiceItem_ClientID]
END


End
GO
/****** Object:  Default [DF_PE_InvoiceItem_OrderFormID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_InvoiceItem_OrderFormID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_InvoiceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_InvoiceItem_OrderFormID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_InvoiceItem] DROP CONSTRAINT [DF_PE_InvoiceItem_OrderFormID]
END


End
GO
/****** Object:  Default [DF_PE_InvoiceItem_InvoiceType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_InvoiceItem_InvoiceType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_InvoiceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_InvoiceItem_InvoiceType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_InvoiceItem] DROP CONSTRAINT [DF_PE_InvoiceItem_InvoiceType]
END


End
GO
/****** Object:  Default [DF_PE_Keywords_Priority]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Keywords_Priority]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Keywords]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Keywords_Priority]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Keywords] DROP CONSTRAINT [DF_PE_Keywords_Priority]
END


End
GO
/****** Object:  Default [DF_PE_Keywords_Hits]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Keywords_Hits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Keywords]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Keywords_Hits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Keywords] DROP CONSTRAINT [DF_PE_Keywords_Hits]
END


End
GO
/****** Object:  Default [DF_PE_Keywords_LastUseTime]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Keywords_LastUseTime]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Keywords]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Keywords_LastUseTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Keywords] DROP CONSTRAINT [DF_PE_Keywords_LastUseTime]
END


End
GO
/****** Object:  Default [DF_PE_Log_Priority]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Log_Priority]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Log]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Log_Priority]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Log] DROP CONSTRAINT [DF_PE_Log_Priority]
END


End
GO
/****** Object:  Default [DF_PE_ContentModel_Disabled]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentModel_Disabled]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Model]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentModel_Disabled]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Model] DROP CONSTRAINT [DF_PE_ContentModel_Disabled]
END


End
GO
/****** Object:  Default [DF_PE_ContentModel_EnableCharge]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentModel_EnableCharge]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Model]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentModel_EnableCharge]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Model] DROP CONSTRAINT [DF_PE_ContentModel_EnableCharge]
END


End
GO
/****** Object:  Default [DF_PE_ContentModel_EnableSignin]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentModel_EnableSignin]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Model]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentModel_EnableSignin]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Model] DROP CONSTRAINT [DF_PE_ContentModel_EnableSignin]
END


End
GO
/****** Object:  Default [DF_PE_Model_MaxPerUser]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Model_MaxPerUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Model]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Model_MaxPerUser]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Model] DROP CONSTRAINT [DF_PE_Model_MaxPerUser]
END


End
GO
/****** Object:  Default [DF_PE_ModelTemplates_IsEshop]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ModelTemplates_IsEshop]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ModelTemplates]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ModelTemplates_IsEshop]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ModelTemplates] DROP CONSTRAINT [DF_PE_ModelTemplates_IsEshop]
END


End
GO
/****** Object:  Default [DF_Mood_M0]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M0]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M0]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M0]
END


End
GO
/****** Object:  Default [DF_Mood_M1]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M1]
END


End
GO
/****** Object:  Default [DF_Mood_M2]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M2]
END


End
GO
/****** Object:  Default [DF_Mood_M3]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M3]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M3]
END


End
GO
/****** Object:  Default [DF_Mood_M4]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M4]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M4]
END


End
GO
/****** Object:  Default [DF_Mood_M5]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M5]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M5]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M5]
END


End
GO
/****** Object:  Default [DF_Mood_M6]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M6]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M6]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M6]
END


End
GO
/****** Object:  Default [DF_Mood_M7]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M7]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M7]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M7]
END


End
GO
/****** Object:  Default [DF_Mood_M8]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M8]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M8]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M8]
END


End
GO
/****** Object:  Default [DF_Mood_M9]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M9]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M9]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M9]
END


End
GO
/****** Object:  Default [DF_Mood_M10]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M10]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M10]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M10]
END


End
GO
/****** Object:  Default [DF_Mood_M11]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M11]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M11]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M11]
END


End
GO
/****** Object:  Default [DF_Mood_M12]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M12]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M12]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M12]
END


End
GO
/****** Object:  Default [DF_Mood_M13]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M13]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M13]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M13]
END


End
GO
/****** Object:  Default [DF_Mood_M14]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M14]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M14]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M14]
END


End
GO
/****** Object:  Default [DF_Mood_M15]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M15]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M15]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M15]
END


End
GO
/****** Object:  Default [DF_Mood_M16]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M16]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M16]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M16]
END


End
GO
/****** Object:  Default [DF_Mood_M17]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M17]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M17]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M17]
END


End
GO
/****** Object:  Default [DF_Mood_M18]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M18]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M18]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M18]
END


End
GO
/****** Object:  Default [DF_Mood_M19]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M19]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M19]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] DROP CONSTRAINT [DF_Mood_M19]
END


End
GO
/****** Object:  Default [DF_PE_Nodes_IncrementalUpdatePages]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Nodes_IncrementalUpdatePages]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Nodes]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Nodes_IncrementalUpdatePages]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Nodes] DROP CONSTRAINT [DF_PE_Nodes_IncrementalUpdatePages]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_ItemID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_ItemID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_ItemID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderFormItem_ItemID]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_OrderFormID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_OrderFormID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_OrderFormID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderFormItem_OrderFormID]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_ProductID]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_ProductID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_ProductID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderFormItem_ProductID]
END


End
GO
/****** Object:  Default [DF_PE_OrderItem_TableName]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderItem_TableName]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderItem_TableName]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderItem_TableName]
END


End
GO
/****** Object:  Default [DF_PE_OrderItem_Property]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderItem_Property]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderItem_Property]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderItem_Property]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_SaleType]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_SaleType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_SaleType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderFormItem_SaleType]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_Price_Original]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_Price_Original]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_Price_Original]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderFormItem_Price_Original]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_Price]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_Price]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_Price]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderFormItem_Price]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_TruePrice]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_TruePrice]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_TruePrice]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderFormItem_TruePrice]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_Amount]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_Amount]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_Amount]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderFormItem_Amount]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_SubTotal]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_SubTotal]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_SubTotal]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderFormItem_SubTotal]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_ServiceTerm]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_ServiceTerm]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_ServiceTerm]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderFormItem_ServiceTerm]
END


End
GO
/****** Object:  Default [DF_PE_OrderItem_ServiceTermUnit]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderItem_ServiceTermUnit]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderItem_ServiceTermUnit]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderItem_ServiceTermUnit]
END


End
GO
/****** Object:  Default [DF_PE_OrderItem_Remark]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderItem_Remark]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderItem_Remark]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderItem_Remark]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_PresentMoney]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_PresentMoney]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_PresentMoney]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderFormItem_PresentMoney]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_PresentPoint]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_PresentPoint]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_PresentPoint]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderFormItem_PresentPoint]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_PresentExp]    Script Date: 01/19/2017 15:37:17 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_PresentExp]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_PresentExp]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] DROP CONSTRAINT [DF_PE_OrderFormItem_PresentExp]
END


End
GO
/****** Object:  Default [DF_PE_Orders_OrderNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_OrderNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_OrderNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] DROP CONSTRAINT [DF_PE_Orders_OrderNum]
END


End
GO
/****** Object:  Default [DF_PE_Orders_UserName]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_UserName]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_UserName]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] DROP CONSTRAINT [DF_PE_Orders_UserName]
END


End
GO
/****** Object:  Default [DF_PE_Orders_AgentName]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_AgentName]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_AgentName]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] DROP CONSTRAINT [DF_PE_Orders_AgentName]
END


End
GO
/****** Object:  Default [DF_PE_Orders_InvoiceContent]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_InvoiceContent]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_InvoiceContent]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] DROP CONSTRAINT [DF_PE_Orders_InvoiceContent]
END


End
GO
/****** Object:  Default [DF_PE_Orders_Status]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_Status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] DROP CONSTRAINT [DF_PE_Orders_Status]
END


End
GO
/****** Object:  Default [DF_PE_Orders_OrderType]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_OrderType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_OrderType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] DROP CONSTRAINT [DF_PE_Orders_OrderType]
END


End
GO
/****** Object:  Default [DF_PE_Orders_CouponID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_CouponID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_CouponID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] DROP CONSTRAINT [DF_PE_Orders_CouponID]
END


End
GO
/****** Object:  Default [DF_PE_Orders_OrderKind]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_OrderKind]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_OrderKind]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] DROP CONSTRAINT [DF_PE_Orders_OrderKind]
END


End
GO
/****** Object:  Default [DF_PE_Package_PackageWeight]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Package_PackageWeight]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Package]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Package_PackageWeight]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Package] DROP CONSTRAINT [DF_PE_Package_PackageWeight]
END


End
GO
/****** Object:  Default [DF_PE_Package_GoodsWeightMax]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Package_GoodsWeightMax]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Package]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Package_GoodsWeightMax]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Package] DROP CONSTRAINT [DF_PE_Package_GoodsWeightMax]
END


End
GO
/****** Object:  Default [DF_PE_Package_GoodsWeightMax_1]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Package_GoodsWeightMax_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Package]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Package_GoodsWeightMax_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Package] DROP CONSTRAINT [DF_PE_Package_GoodsWeightMax_1]
END


End
GO
/****** Object:  Default [DF_PE_PaymentType_Discount]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PaymentType_Discount]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PaymentType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PaymentType_Discount]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PaymentType] DROP CONSTRAINT [DF_PE_PaymentType_Discount]
END


End
GO
/****** Object:  Default [DF_PE_PaymentType_IsDefault]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PaymentType_IsDefault]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PaymentType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PaymentType_IsDefault]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PaymentType] DROP CONSTRAINT [DF_PE_PaymentType_IsDefault]
END


End
GO
/****** Object:  Default [DF_PE_PaymentType_IsDisabled]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PaymentType_IsDisabled]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PaymentType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PaymentType_IsDisabled]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PaymentType] DROP CONSTRAINT [DF_PE_PaymentType_IsDisabled]
END


End
GO
/****** Object:  Default [DF_PE_PaymentType_Category]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PaymentType_Category]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PaymentType]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PaymentType_Category]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PaymentType] DROP CONSTRAINT [DF_PE_PaymentType_Category]
END


End
GO
/****** Object:  Default [DF_PE_PM_CommissionDetail_GatheringID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_CommissionDetail_GatheringID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_CommissionDetail]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_CommissionDetail_GatheringID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_CommissionDetail] DROP CONSTRAINT [DF_PE_PM_CommissionDetail_GatheringID]
END


End
GO
/****** Object:  Default [DF_PE_PM_CommissionDetail_CommissionType]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_CommissionDetail_CommissionType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_CommissionDetail]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_CommissionDetail_CommissionType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_CommissionDetail] DROP CONSTRAINT [DF_PE_PM_CommissionDetail_CommissionType]
END


End
GO
/****** Object:  Default [DF_PE_PM_CommissionDetail_Rate]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_CommissionDetail_Rate]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_CommissionDetail]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_CommissionDetail_Rate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_CommissionDetail] DROP CONSTRAINT [DF_PE_PM_CommissionDetail_Rate]
END


End
GO
/****** Object:  Default [DF_PE_PM_CommissionDetail_Property]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_CommissionDetail_Property]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_CommissionDetail]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_CommissionDetail_Property]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_CommissionDetail] DROP CONSTRAINT [DF_PE_PM_CommissionDetail_Property]
END


End
GO
/****** Object:  Default [DF_PE_PM_GatheringDetail_State]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_GatheringDetail_State]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_GatheringDetail]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_GatheringDetail_State]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_GatheringDetail] DROP CONSTRAINT [DF_PE_PM_GatheringDetail_State]
END


End
GO
/****** Object:  Default [DF_PE_PM_Promotion_CommissionType]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_Promotion_CommissionType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_Promotion]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_Promotion_CommissionType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_Promotion] DROP CONSTRAINT [DF_PE_PM_Promotion_CommissionType]
END


End
GO
/****** Object:  Default [DF_PE_PM_Promotion_Rate]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_Promotion_Rate]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_Promotion]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_Promotion_Rate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_Promotion] DROP CONSTRAINT [DF_PE_PM_Promotion_Rate]
END


End
GO
/****** Object:  Default [DF_PE_PM_RegisterPromotion_GatheringID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_RegisterPromotion_GatheringID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_RegisterPromotion]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_RegisterPromotion_GatheringID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_RegisterPromotion] DROP CONSTRAINT [DF_PE_PM_RegisterPromotion_GatheringID]
END


End
GO
/****** Object:  Default [DF_PE_PointLog_InfoId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PointLog_InfoId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PointLog]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PointLog_InfoId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PointLog] DROP CONSTRAINT [DF_PE_PointLog_InfoId]
END


End
GO
/****** Object:  Default [DF_PE_PointLog_Point]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PointLog_Point]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PointLog]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PointLog_Point]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PointLog] DROP CONSTRAINT [DF_PE_PointLog_Point]
END


End
GO
/****** Object:  Default [DF_PE_PointLog_LogTime]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PointLog_LogTime]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PointLog]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PointLog_LogTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PointLog] DROP CONSTRAINT [DF_PE_PointLog_LogTime]
END


End
GO
/****** Object:  Default [DF_PE_PointLog_Times]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PointLog_Times]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PointLog]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PointLog_Times]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PointLog] DROP CONSTRAINT [DF_PE_PointLog_Times]
END


End
GO
/****** Object:  Default [DF_PE_PointLog_IncomePayOut]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PointLog_IncomePayOut]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PointLog]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PointLog_IncomePayOut]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PointLog] DROP CONSTRAINT [DF_PE_PointLog_IncomePayOut]
END


End
GO
/****** Object:  Default [DF_PE_Present_OrderNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Present_OrderNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Present]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Present_OrderNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Present] DROP CONSTRAINT [DF_PE_Present_OrderNum]
END


End
GO
/****** Object:  Default [DF_PE_Producer_ProducerType_1]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Producer_ProducerType_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Producer]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Producer_ProducerType_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Producer] DROP CONSTRAINT [DF_PE_Producer_ProducerType_1]
END


End
GO
/****** Object:  Default [DF_PE_Producer_Passed]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Producer_Passed]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Producer]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Producer_Passed]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Producer] DROP CONSTRAINT [DF_PE_Producer_Passed]
END


End
GO
/****** Object:  Default [DF_PE_Producer_onTop]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Producer_onTop]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Producer]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Producer_onTop]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Producer] DROP CONSTRAINT [DF_PE_Producer_onTop]
END


End
GO
/****** Object:  Default [DF_PE_Producer_IsElite]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Producer_IsElite]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Producer]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Producer_IsElite]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Producer] DROP CONSTRAINT [DF_PE_Producer_IsElite]
END


End
GO
/****** Object:  Default [DF_PE_Producer_Hits]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Producer_Hits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Producer]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Producer_Hits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Producer] DROP CONSTRAINT [DF_PE_Producer_Hits]
END


End
GO
/****** Object:  Default [DF_PE_ProductData_ProductID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ProductData_ProductID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ProductData]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ProductData_ProductID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ProductData] DROP CONSTRAINT [DF_PE_ProductData_ProductID]
END


End
GO
/****** Object:  Default [DF_PE_ProductData_Stocks]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ProductData_Stocks]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ProductData]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ProductData_Stocks]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ProductData] DROP CONSTRAINT [DF_PE_ProductData_Stocks]
END


End
GO
/****** Object:  Default [DF_PE_ProductData_OrderNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ProductData_OrderNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ProductData]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ProductData_OrderNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ProductData] DROP CONSTRAINT [DF_PE_ProductData_OrderNum]
END


End
GO
/****** Object:  Default [DF_PE_ProductData_AlarmNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ProductData_AlarmNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ProductData]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ProductData_AlarmNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ProductData] DROP CONSTRAINT [DF_PE_ProductData_AlarmNum]
END


End
GO
/****** Object:  Default [DF_PE_ProductData_BuyTimes]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ProductData_BuyTimes]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ProductData]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ProductData_BuyTimes]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ProductData] DROP CONSTRAINT [DF_PE_ProductData_BuyTimes]
END


End
GO
/****** Object:  Default [DF_PE_Provider_ProviderID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Provider_ProviderID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Provider]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Provider_ProviderID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Provider] DROP CONSTRAINT [DF_PE_Provider_ProviderID]
END


End
GO
/****** Object:  Default [DF_PE_Region_Country]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Region_Country]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Region]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Region_Country]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Region] DROP CONSTRAINT [DF_PE_Region_Country]
END


End
GO
/****** Object:  Default [DF_PE_Region_Province]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Region_Province]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Region]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Region_Province]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Region] DROP CONSTRAINT [DF_PE_Region_Province]
END


End
GO
/****** Object:  Default [DF_PE_Region_City]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Region_City]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Region]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Region_City]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Region] DROP CONSTRAINT [DF_PE_Region_City]
END


End
GO
/****** Object:  Default [DF_PE_Region_Area]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Region_Area]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Region]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Region_Area]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Region] DROP CONSTRAINT [DF_PE_Region_Area]
END


End
GO
/****** Object:  Default [DF_PE_Region_PostCode]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Region_PostCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Region]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Region_PostCode]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Region] DROP CONSTRAINT [DF_PE_Region_PostCode]
END


End
GO
/****** Object:  Default [DF_PE_Region_AreaCode]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Region_AreaCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Region]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Region_AreaCode]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Region] DROP CONSTRAINT [DF_PE_Region_AreaCode]
END


End
GO
/****** Object:  Default [DF_PE_ServiceItem_ClientID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ServiceItem_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ServiceItem_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ServiceItem] DROP CONSTRAINT [DF_PE_ServiceItem_ClientID]
END


End
GO
/****** Object:  Default [DF_PE_ServiceItem_ContacterID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ServiceItem_ContacterID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ServiceItem_ContacterID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ServiceItem] DROP CONSTRAINT [DF_PE_ServiceItem_ContacterID]
END


End
GO
/****** Object:  Default [DF_PE_ServiceItem_OrderID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ServiceItem_OrderID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ServiceItem_OrderID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ServiceItem] DROP CONSTRAINT [DF_PE_ServiceItem_OrderID]
END


End
GO
/****** Object:  Default [DF_PE_ServiceItem_ServiceResult]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ServiceItem_ServiceResult]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ServiceItem_ServiceResult]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ServiceItem] DROP CONSTRAINT [DF_PE_ServiceItem_ServiceResult]
END


End
GO
/****** Object:  Default [DF_PE_ServiceItem_TakeTime]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ServiceItem_TakeTime]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ServiceItem_TakeTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ServiceItem] DROP CONSTRAINT [DF_PE_ServiceItem_TakeTime]
END


End
GO
/****** Object:  Default [DF_PE_ServiceItem_ServicePoint]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ServiceItem_ServicePoint]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ServiceItem_ServicePoint]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ServiceItem] DROP CONSTRAINT [DF_PE_ServiceItem_ServicePoint]
END


End
GO
/****** Object:  Default [DF_PE_ServiceItem_ConfirmScore]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ServiceItem_ConfirmScore]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ServiceItem_ConfirmScore]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ServiceItem] DROP CONSTRAINT [DF_PE_ServiceItem_ConfirmScore]
END


End
GO
/****** Object:  Default [DF_PE_ShoppingCarts_ProductID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ShoppingCarts_ProductID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ShoppingCarts_ProductID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ShoppingCarts] DROP CONSTRAINT [DF_PE_ShoppingCarts_ProductID]
END


End
GO
/****** Object:  Default [DF_PE_ShoppingCarts_Quantity]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ShoppingCarts_Quantity]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ShoppingCarts_Quantity]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ShoppingCarts] DROP CONSTRAINT [DF_PE_ShoppingCarts_Quantity]
END


End
GO
/****** Object:  Default [DF_PE_ShoppingCarts_PresentID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ShoppingCarts_PresentID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ShoppingCarts_PresentID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ShoppingCarts] DROP CONSTRAINT [DF_PE_ShoppingCarts_PresentID]
END


End
GO
/****** Object:  Default [DF_PE_ShoppingCarts_InformResult]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ShoppingCarts_InformResult]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ShoppingCarts_InformResult]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ShoppingCarts] DROP CONSTRAINT [DF_PE_ShoppingCarts_InformResult]
END


End
GO
/****** Object:  Default [DF_PE_ShoppingCarts_BelongsToProductID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ShoppingCarts_BelongsToProductID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ShoppingCarts_BelongsToProductID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ShoppingCarts] DROP CONSTRAINT [DF_PE_ShoppingCarts_BelongsToProductID]
END


End
GO
/****** Object:  Default [DF_PE_Source_Type]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Source_Type]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Source]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Source_Type]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Source] DROP CONSTRAINT [DF_PE_Source_Type]
END


End
GO
/****** Object:  Default [DF_PE_Source_Passed]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Source_Passed]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Source]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Source_Passed]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Source] DROP CONSTRAINT [DF_PE_Source_Passed]
END


End
GO
/****** Object:  Default [DF_PE_Source_onTop]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Source_onTop]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Source]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Source_onTop]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Source] DROP CONSTRAINT [DF_PE_Source_onTop]
END


End
GO
/****** Object:  Default [DF_PE_Source_IsElite]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Source_IsElite]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Source]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Source_IsElite]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Source] DROP CONSTRAINT [DF_PE_Source_IsElite]
END


End
GO
/****** Object:  Default [DF_PE_Source_Hits]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Source_Hits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Source]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Source_Hits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Source] DROP CONSTRAINT [DF_PE_Source_Hits]
END


End
GO
/****** Object:  Default [DF_PE_StatAddress_TAddNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatAddress_TAddNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatAddress]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatAddress_TAddNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatAddress] DROP CONSTRAINT [DF_PE_StatAddress_TAddNum]
END


End
GO
/****** Object:  Default [DF_PE_StatBrowser_TBrwNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatBrowser_TBrwNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatBrowser]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatBrowser_TBrwNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatBrowser] DROP CONSTRAINT [DF_PE_StatBrowser_TBrwNum]
END


End
GO
/****** Object:  Default [DF_PE_StatColor_TColNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatColor_TColNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatColor]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatColor_TColNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatColor] DROP CONSTRAINT [DF_PE_StatColor_TColNum]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_0]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_0]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_0]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_0]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_1]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_1]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_2]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_2]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_3]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_3]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_3]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_4]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_4]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_4]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_5]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_5]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_5]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_5]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_6]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_6]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_6]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_6]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_7]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_7]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_7]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_7]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_8]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_8]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_8]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_8]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_9]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_9]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_9]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_9]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_10]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_10]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_10]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_10]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_11]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_11]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_11]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_11]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_12]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_12]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_12]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_12]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_13]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_13]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_13]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_13]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_14]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_14]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_14]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_14]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_15]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_15]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_15]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_15]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_16]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_16]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_16]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_16]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_17]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_17]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_17]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_17]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_18]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_18]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_18]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_18]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_19]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_19]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_19]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_19]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_20]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_20]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_20]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_20]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_21]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_21]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_21]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_21]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_22]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_22]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_22]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_22]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_23]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_23]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_23]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] DROP CONSTRAINT [DF_PE_StatDay_23]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_TotalNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_TotalNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_TotalNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_TotalNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_TotalView]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_TotalView]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_TotalView]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_TotalView]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_MonthNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_MonthNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_MonthNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_MonthNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_MonthMaxNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_MonthMaxNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_MonthMaxNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_MonthMaxNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_DayNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_DayNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_DayNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_DayNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_DayMaxNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_DayMaxNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_DayMaxNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_DayMaxNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_HourNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_HourNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_HourNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_HourNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_HourMaxNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_HourMaxNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_HourMaxNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_HourMaxNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_ChinaNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_ChinaNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_ChinaNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_ChinaNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_OtherNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_OtherNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_OtherNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_OtherNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_MasterTimeZone]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_MasterTimeZone]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_MasterTimeZone]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_MasterTimeZone]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_IntervalNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_IntervalNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_IntervalNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_IntervalNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_OnlineTime]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_OnlineTime]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_OnlineTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_OnlineTime]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_VisitRecord]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_VisitRecord]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_VisitRecord]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_VisitRecord]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_KillRefresh]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_KillRefresh]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_KillRefresh]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_KillRefresh]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_OldTotalNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_OldTotalNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_OldTotalNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_OldTotalNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_OldTotalView]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_OldTotalView]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_OldTotalView]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] DROP CONSTRAINT [DF_PE_StatInfoList_OldTotalView]
END


End
GO
/****** Object:  Default [DF_PE_StatIp_TIpNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatIp_TIpNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatIp]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatIp_TIpNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatIp] DROP CONSTRAINT [DF_PE_StatIp_TIpNum]
END


End
GO
/****** Object:  Default [DF_PE_StatKeyword_TKeywordNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatKeyword_TKeywordNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatKeyword]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatKeyword_TKeywordNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatKeyword] DROP CONSTRAINT [DF_PE_StatKeyword_TKeywordNum]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_1]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_1]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_2]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_2]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_3]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_3]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_3]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_4]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_4]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_4]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_5]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_5]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_5]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_5]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_6]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_6]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_6]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_6]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_7]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_7]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_7]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_7]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_8]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_8]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_8]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_8]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_9]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_9]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_9]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_9]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_10]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_10]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_10]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_10]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_11]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_11]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_11]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_11]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_12]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_12]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_12]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_12]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_13]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_13]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_13]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_13]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_14]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_14]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_14]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_14]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_15]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_15]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_15]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_15]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_16]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_16]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_16]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_16]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_17]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_17]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_17]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_17]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_18]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_18]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_18]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_18]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_19]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_19]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_19]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_19]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_20]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_20]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_20]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_20]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_21]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_21]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_21]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_21]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_22]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_22]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_22]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_22]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_23]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_23]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_23]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_23]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_24]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_24]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_24]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_24]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_25]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_25]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_25]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_25]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_26]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_26]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_26]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_26]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_27]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_27]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_27]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_27]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_28]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_28]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_28]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_28]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_29]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_29]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_29]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_29]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_30]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_30]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_30]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_30]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_31]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_31]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_31]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] DROP CONSTRAINT [DF_PE_StatMonth_31]
END


End
GO
/****** Object:  Default [DF_PE_StatMozilla_TMozNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMozilla_TMozNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMozilla]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMozilla_TMozNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMozilla] DROP CONSTRAINT [DF_PE_StatMozilla_TMozNum]
END


End
GO
/****** Object:  Default [DF_PE_StatRefer_TRefNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatRefer_TRefNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatRefer]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatRefer_TRefNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatRefer] DROP CONSTRAINT [DF_PE_StatRefer_TRefNum]
END


End
GO
/****** Object:  Default [DF_PE_StatScreen_TScrNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatScreen_TScrNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatScreen]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatScreen_TScrNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatScreen] DROP CONSTRAINT [DF_PE_StatScreen_TScrNum]
END


End
GO
/****** Object:  Default [DF_PE_StatSystem_TSysNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatSystem_TSysNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatSystem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatSystem_TSysNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatSystem] DROP CONSTRAINT [DF_PE_StatSystem_TSysNum]
END


End
GO
/****** Object:  Default [DF_PE_StatTimezone_TTimNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatTimezone_TTimNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatTimezone]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatTimezone_TTimNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatTimezone] DROP CONSTRAINT [DF_PE_StatTimezone_TTimNum]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_1]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] DROP CONSTRAINT [DF_PE_StatVisit_1]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_2]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] DROP CONSTRAINT [DF_PE_StatVisit_2]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_3]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_3]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] DROP CONSTRAINT [DF_PE_StatVisit_3]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_4]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_4]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] DROP CONSTRAINT [DF_PE_StatVisit_4]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_5]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_5]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_5]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] DROP CONSTRAINT [DF_PE_StatVisit_5]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_6]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_6]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_6]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] DROP CONSTRAINT [DF_PE_StatVisit_6]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_7]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_7]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_7]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] DROP CONSTRAINT [DF_PE_StatVisit_7]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_8]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_8]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_8]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] DROP CONSTRAINT [DF_PE_StatVisit_8]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_9]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_9]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_9]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] DROP CONSTRAINT [DF_PE_StatVisit_9]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_10]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_10]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_10]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] DROP CONSTRAINT [DF_PE_StatVisit_10]
END


End
GO
/****** Object:  Default [DF_PE_StatVisitor_Timezone]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisitor_Timezone]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisitor]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisitor_Timezone]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisitor] DROP CONSTRAINT [DF_PE_StatVisitor_Timezone]
END


End
GO
/****** Object:  Default [DF_PE_StatWeburl_TWebNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeburl_TWebNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeburl]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeburl_TWebNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeburl] DROP CONSTRAINT [DF_PE_StatWeburl_TWebNum]
END


End
GO
/****** Object:  Default [DF_PE_StatWeek_1]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeek_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeek_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeek] DROP CONSTRAINT [DF_PE_StatWeek_1]
END


End
GO
/****** Object:  Default [DF_PE_StatWeek_2]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeek_2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeek_2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeek] DROP CONSTRAINT [DF_PE_StatWeek_2]
END


End
GO
/****** Object:  Default [DF_PE_StatWeek_3]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeek_3]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeek_3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeek] DROP CONSTRAINT [DF_PE_StatWeek_3]
END


End
GO
/****** Object:  Default [DF_PE_StatWeek_4]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeek_4]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeek_4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeek] DROP CONSTRAINT [DF_PE_StatWeek_4]
END


End
GO
/****** Object:  Default [DF_PE_StatWeek_5]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeek_5]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeek_5]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeek] DROP CONSTRAINT [DF_PE_StatWeek_5]
END


End
GO
/****** Object:  Default [DF_PE_StatWeek_6]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeek_6]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeek_6]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeek] DROP CONSTRAINT [DF_PE_StatWeek_6]
END


End
GO
/****** Object:  Default [DF_PE_StatWeek_7]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeek_7]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeek_7]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeek] DROP CONSTRAINT [DF_PE_StatWeek_7]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_1]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] DROP CONSTRAINT [DF_PE_StatYear_1]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_2]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] DROP CONSTRAINT [DF_PE_StatYear_2]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_3]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_3]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] DROP CONSTRAINT [DF_PE_StatYear_3]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_4]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_4]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] DROP CONSTRAINT [DF_PE_StatYear_4]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_5]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_5]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_5]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] DROP CONSTRAINT [DF_PE_StatYear_5]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_6]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_6]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_6]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] DROP CONSTRAINT [DF_PE_StatYear_6]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_7]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_7]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_7]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] DROP CONSTRAINT [DF_PE_StatYear_7]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_8]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_8]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_8]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] DROP CONSTRAINT [DF_PE_StatYear_8]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_9]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_9]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_9]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] DROP CONSTRAINT [DF_PE_StatYear_9]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_10]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_10]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_10]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] DROP CONSTRAINT [DF_PE_StatYear_10]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_11]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_11]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_11]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] DROP CONSTRAINT [DF_PE_StatYear_11]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_12]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_12]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_12]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] DROP CONSTRAINT [DF_PE_StatYear_12]
END


End
GO
/****** Object:  Default [DF_PE_Stock_ID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Stock_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Stock]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Stock_ID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Stock] DROP CONSTRAINT [DF_PE_Stock_ID]
END


End
GO
/****** Object:  Default [DF_PE_Stock_StockType]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Stock_StockType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Stock]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Stock_StockType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Stock] DROP CONSTRAINT [DF_PE_Stock_StockType]
END


End
GO
/****** Object:  Default [DF_PE_Stock_Status]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Stock_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Stock]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Stock_Status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Stock] DROP CONSTRAINT [DF_PE_Stock_Status]
END


End
GO
/****** Object:  Default [DF_PE_StockItem_Amount]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StockItem_Amount]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StockItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StockItem_Amount]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StockItem] DROP CONSTRAINT [DF_PE_StockItem_Amount]
END


End
GO
/****** Object:  Default [DF_PE_StockItem_Price]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StockItem_Price]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StockItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StockItem_Price]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StockItem] DROP CONSTRAINT [DF_PE_StockItem_Price]
END


End
GO
/****** Object:  Default [DF_PE_Survey_IPRepeat]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Survey_IPRepeat]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Survey]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Survey_IPRepeat]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Survey] DROP CONSTRAINT [DF_PE_Survey_IPRepeat]
END


End
GO
/****** Object:  Default [DF_PE_Survey_IsOpen]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Survey_IsOpen]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Survey]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Survey_IsOpen]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Survey] DROP CONSTRAINT [DF_PE_Survey_IsOpen]
END


End
GO
/****** Object:  Default [DF_PE_Survey_NeedLogin]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Survey_NeedLogin]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Survey]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Survey_NeedLogin]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Survey] DROP CONSTRAINT [DF_PE_Survey_NeedLogin]
END


End
GO
/****** Object:  Default [DF_PE_Survey_LockIPType]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Survey_LockIPType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Survey]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Survey_LockIPType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Survey] DROP CONSTRAINT [DF_PE_Survey_LockIPType]
END


End
GO
/****** Object:  Default [DF_PE_Survey_TemplateID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Survey_TemplateID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Survey]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Survey_TemplateID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Survey] DROP CONSTRAINT [DF_PE_Survey_TemplateID]
END


End
GO
/****** Object:  Default [DF_PE_Survey_QuestionMaxId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Survey_QuestionMaxId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Survey]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Survey_QuestionMaxId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Survey] DROP CONSTRAINT [DF_PE_Survey_QuestionMaxId]
END


End
GO
/****** Object:  Default [DF_PE_Survey_IsResultPublic]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Survey_IsResultPublic]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Survey]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Survey_IsResultPublic]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Survey] DROP CONSTRAINT [DF_PE_Survey_IsResultPublic]
END


End
GO
/****** Object:  Default [DF_PE_SurveyVote_SurveyId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_SurveyVote_SurveyId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_SurveyVote]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_SurveyVote_SurveyId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_SurveyVote] DROP CONSTRAINT [DF_PE_SurveyVote_SurveyId]
END


End
GO
/****** Object:  Default [DF_PE_SurveyVote_QuestionId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_SurveyVote_QuestionId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_SurveyVote]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_SurveyVote_QuestionId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_SurveyVote] DROP CONSTRAINT [DF_PE_SurveyVote_QuestionId]
END


End
GO
/****** Object:  Default [DF_PE_SurveyVote_OptionId]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_SurveyVote_OptionId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_SurveyVote]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_SurveyVote_OptionId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_SurveyVote] DROP CONSTRAINT [DF_PE_SurveyVote_OptionId]
END


End
GO
/****** Object:  Default [DF_PE_SurveyVote_VoteAmount]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_SurveyVote_VoteAmount]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_SurveyVote]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_SurveyVote_VoteAmount]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_SurveyVote] DROP CONSTRAINT [DF_PE_SurveyVote_VoteAmount]
END


End
GO
/****** Object:  Default [DF_PE_Trademark_TrademarkType]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Trademark_TrademarkType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Trademark]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Trademark_TrademarkType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Trademark] DROP CONSTRAINT [DF_PE_Trademark_TrademarkType]
END


End
GO
/****** Object:  Default [DF_PE_Trademark_ProducerID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Trademark_ProducerID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Trademark]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Trademark_ProducerID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Trademark] DROP CONSTRAINT [DF_PE_Trademark_ProducerID]
END


End
GO
/****** Object:  Default [DF_PE_Trademark_Passed]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Trademark_Passed]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Trademark]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Trademark_Passed]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Trademark] DROP CONSTRAINT [DF_PE_Trademark_Passed]
END


End
GO
/****** Object:  Default [DF_PE_Trademark_onTop]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Trademark_onTop]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Trademark]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Trademark_onTop]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Trademark] DROP CONSTRAINT [DF_PE_Trademark_onTop]
END


End
GO
/****** Object:  Default [DF_PE_Trademark_IsElite]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Trademark_IsElite]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Trademark]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Trademark_IsElite]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Trademark] DROP CONSTRAINT [DF_PE_Trademark_IsElite]
END


End
GO
/****** Object:  Default [DF_PE_Trademark_Hits]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Trademark_Hits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Trademark]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Trademark_Hits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Trademark] DROP CONSTRAINT [DF_PE_Trademark_Hits]
END


End
GO
/****** Object:  Default [DF_PE_UserExpLog_ExpNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_UserExpLog_ExpNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_UserExpLog]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_UserExpLog_ExpNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_UserExpLog] DROP CONSTRAINT [DF_PE_UserExpLog_ExpNum]
END


End
GO
/****** Object:  Default [DF_PE_UserExpLog_IncomePayout]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_UserExpLog_IncomePayout]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_UserExpLog]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_UserExpLog_IncomePayout]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_UserExpLog] DROP CONSTRAINT [DF_PE_UserExpLog_IncomePayout]
END


End
GO
/****** Object:  Default [DF_PE_UserExpLog_LogTime]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_UserExpLog_LogTime]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_UserExpLog]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_UserExpLog_LogTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_UserExpLog] DROP CONSTRAINT [DF_PE_UserExpLog_LogTime]
END


End
GO
/****** Object:  Default [DF_PE_Users_ClientID]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Users_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Users]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Users_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Users] DROP CONSTRAINT [DF_PE_Users_ClientID]
END


End
GO
/****** Object:  Default [DF_PE_Users_QAPoint]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Users_QAPoint]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Users]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Users_QAPoint]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Users] DROP CONSTRAINT [DF_PE_Users_QAPoint]
END


End
GO
/****** Object:  Default [DF_PE_ValidLog_ValidNum]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ValidLog_ValidNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ValidLog]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ValidLog_ValidNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ValidLog] DROP CONSTRAINT [DF_PE_ValidLog_ValidNum]
END


End
GO
/****** Object:  Default [DF_PE_ValidLog_IncomePayout]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ValidLog_IncomePayout]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ValidLog]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ValidLog_IncomePayout]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ValidLog] DROP CONSTRAINT [DF_PE_ValidLog_IncomePayout]
END


End
GO
/****** Object:  Default [DF_PE_ValidLog_LogTime]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ValidLog_LogTime]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ValidLog]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ValidLog_LogTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ValidLog] DROP CONSTRAINT [DF_PE_ValidLog_LogTime]
END


End
GO
/****** Object:  Default [DF_PE_WordFilter_ReplaceType]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_WordFilter_ReplaceType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_WordReplaceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_WordFilter_ReplaceType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_WordReplaceItem] DROP CONSTRAINT [DF_PE_WordFilter_ReplaceType]
END


End
GO
/****** Object:  Default [DF_PE_WordFilter_ScopesType]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_WordFilter_ScopesType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_WordReplaceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_WordFilter_ScopesType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_WordReplaceItem] DROP CONSTRAINT [DF_PE_WordFilter_ScopesType]
END


End
GO
/****** Object:  Default [DF_PE_WordFilter_ReplaceTimes]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_WordFilter_ReplaceTimes]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_WordReplaceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_WordFilter_ReplaceTimes]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_WordReplaceItem] DROP CONSTRAINT [DF_PE_WordFilter_ReplaceTimes]
END


End
GO
/****** Object:  Default [DF_PE_WordFilter_Priority]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_WordFilter_Priority]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_WordReplaceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_WordFilter_Priority]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_WordReplaceItem] DROP CONSTRAINT [DF_PE_WordFilter_Priority]
END


End
GO
/****** Object:  Default [DF_PE_WordFilter_OpenType]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_WordFilter_OpenType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_WordReplaceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_WordFilter_OpenType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_WordReplaceItem] DROP CONSTRAINT [DF_PE_WordFilter_OpenType]
END


End
GO
/****** Object:  Default [DF_PE_WordFilter_IsEnabled]    Script Date: 01/19/2017 15:37:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_WordFilter_IsEnabled]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_WordReplaceItem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_WordFilter_IsEnabled]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_WordReplaceItem] DROP CONSTRAINT [DF_PE_WordFilter_IsEnabled]
END


End
GO
/****** Object:  Table [dbo].[PE_Zone_Advertisement]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Zone_Advertisement]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Zone_Advertisement](
	[ZoneID] [int] NOT NULL,
	[ADID] [int] NOT NULL,
 CONSTRAINT [PK_PE_Zone_Advertisement] PRIMARY KEY CLUSTERED 
(
	[ZoneID] ASC,
	[ADID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Zone_Advertisement', N'COLUMN',N'ZoneID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'版位ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Zone_Advertisement', @level2type=N'COLUMN',@level2name=N'ZoneID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Zone_Advertisement', N'COLUMN',N'ADID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'广告ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Zone_Advertisement', @level2type=N'COLUMN',@level2name=N'ADID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Zone_Advertisement', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'版位广告关联表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Zone_Advertisement'
GO
/****** Object:  Table [dbo].[PE_WorkNextProcessRoles]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_WorkNextProcessRoles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_WorkNextProcessRoles](
	[WorkID] [int] NOT NULL,
	[RoleID] [int] NOT NULL,
 CONSTRAINT [PK_PE_WorkNextProcessRoles] PRIMARY KEY CLUSTERED 
(
	[WorkID] ASC,
	[RoleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkNextProcessRoles', N'COLUMN',N'WorkID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自定义表单数据ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkNextProcessRoles', @level2type=N'COLUMN',@level2name=N'WorkID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkNextProcessRoles', N'COLUMN',N'RoleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkNextProcessRoles', @level2type=N'COLUMN',@level2name=N'RoleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkNextProcessRoles', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自定义表单数据角色审核状态更新表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkNextProcessRoles'
GO
/****** Object:  Table [dbo].[PE_WorkFlows]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_WorkFlows]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_WorkFlows](
	[FlowID] [int] NOT NULL,
	[FlowName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Description] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_WorkFlows_FlowID] PRIMARY KEY CLUSTERED 
(
	[FlowID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkFlows', N'COLUMN',N'FlowID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'流程ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkFlows', @level2type=N'COLUMN',@level2name=N'FlowID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkFlows', N'COLUMN',N'FlowName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'流程名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkFlows', @level2type=N'COLUMN',@level2name=N'FlowName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkFlows', N'COLUMN',N'Description'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'步骤说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkFlows', @level2type=N'COLUMN',@level2name=N'Description'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkFlows', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'工作流程表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkFlows'
GO
/****** Object:  Table [dbo].[PE_WorkCategoryCustomForm]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_WorkCategoryCustomForm]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_WorkCategoryCustomForm](
	[ID] [int] NOT NULL,
	[WorkCategoryID] [int] NULL,
	[CustomFormID] [int] NULL,
	[TemplateOfAdmin] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[TemplateOfUser] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[TemplateOfAdminView] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_WorkCategoryCustomForm] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkCategoryCustomForm', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkCategoryCustomForm', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkCategoryCustomForm', N'COLUMN',N'WorkCategoryID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'类别ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkCategoryCustomForm', @level2type=N'COLUMN',@level2name=N'WorkCategoryID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkCategoryCustomForm', N'COLUMN',N'CustomFormID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自定义表单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkCategoryCustomForm', @level2type=N'COLUMN',@level2name=N'CustomFormID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkCategoryCustomForm', N'COLUMN',N'TemplateOfAdmin'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'后台表单提交页布局模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkCategoryCustomForm', @level2type=N'COLUMN',@level2name=N'TemplateOfAdmin'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkCategoryCustomForm', N'COLUMN',N'TemplateOfUser'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'前台表单提交页布局模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkCategoryCustomForm', @level2type=N'COLUMN',@level2name=N'TemplateOfUser'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkCategoryCustomForm', N'COLUMN',N'TemplateOfAdminView'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'后台表单查看页布局模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkCategoryCustomForm', @level2type=N'COLUMN',@level2name=N'TemplateOfAdminView'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkCategoryCustomForm', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自定义表单类别与自定义表单绑定表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkCategoryCustomForm'
GO
/****** Object:  Table [dbo].[PE_WorkCategory]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_WorkCategory]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_WorkCategory](
	[ID] [int] NOT NULL,
	[ParentID] [int] NULL,
	[Name] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Description] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[OrderID] [int] NULL,
	[FlowID] [int] NULL,
 CONSTRAINT [PK_PE_WorkCategory] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkCategory', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkCategory', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkCategory', N'COLUMN',N'ParentID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'父类别ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkCategory', @level2type=N'COLUMN',@level2name=N'ParentID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkCategory', N'COLUMN',N'Name'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'类别名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkCategory', @level2type=N'COLUMN',@level2name=N'Name'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkCategory', N'COLUMN',N'Description'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkCategory', @level2type=N'COLUMN',@level2name=N'Description'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkCategory', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkCategory', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkCategory', N'COLUMN',N'FlowID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'流程ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkCategory', @level2type=N'COLUMN',@level2name=N'FlowID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WorkCategory', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自定义表单类别表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WorkCategory'
GO
/****** Object:  Table [dbo].[PE_Work]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Work]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Work](
	[WorkID] [int] NOT NULL,
	[WorkName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[WorkCategoryID] [int] NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[IP] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[InputTime] [datetime] NULL,
	[FormID] [int] NULL,
	[FormTable] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[FlowID] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Status] [int] NULL,
 CONSTRAINT [PK_PE_Work] PRIMARY KEY CLUSTERED 
(
	[WorkID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Work', N'COLUMN',N'WorkID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Work', @level2type=N'COLUMN',@level2name=N'WorkID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Work', N'COLUMN',N'WorkName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Work', @level2type=N'COLUMN',@level2name=N'WorkName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Work', N'COLUMN',N'WorkCategoryID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'类别ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Work', @level2type=N'COLUMN',@level2name=N'WorkCategoryID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Work', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Work', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Work', N'COLUMN',N'IP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Work', @level2type=N'COLUMN',@level2name=N'IP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Work', N'COLUMN',N'InputTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'提交时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Work', @level2type=N'COLUMN',@level2name=N'InputTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Work', N'COLUMN',N'FormID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自定义表单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Work', @level2type=N'COLUMN',@level2name=N'FormID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Work', N'COLUMN',N'FormTable'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自定义表单表名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Work', @level2type=N'COLUMN',@level2name=N'FormTable'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Work', N'COLUMN',N'FlowID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'流程ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Work', @level2type=N'COLUMN',@level2name=N'FlowID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Work', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Work', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Work', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自定义表单数据表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Work'
GO
/****** Object:  Table [dbo].[PE_WordReplaceItem]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_WordReplaceItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_WordReplaceItem](
	[ItemID] [int] NOT NULL,
	[SourceWord] [nvarchar](250) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[TargetWord] [nvarchar](250) COLLATE Chinese_PRC_CI_AS NULL,
	[ReplaceType] [int] NOT NULL,
	[ScopesType] [int] NOT NULL,
	[ReplaceTimes] [int] NOT NULL,
	[Priority] [int] NOT NULL,
	[OpenType] [bit] NULL,
	[IsEnabled] [bit] NULL,
	[Title] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_WordReplaceItem_ItemID] PRIMARY KEY CLUSTERED 
(
	[ItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WordReplaceItem', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字符替换Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WordReplaceItem', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WordReplaceItem', N'COLUMN',N'SourceWord'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字符替换目标' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WordReplaceItem', @level2type=N'COLUMN',@level2name=N'SourceWord'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WordReplaceItem', N'COLUMN',N'TargetWord'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字符替换替换后地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WordReplaceItem', @level2type=N'COLUMN',@level2name=N'TargetWord'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WordReplaceItem', N'COLUMN',N'ReplaceType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字符替换类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WordReplaceItem', @level2type=N'COLUMN',@level2name=N'ReplaceType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WordReplaceItem', N'COLUMN',N'ScopesType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'过滤字符替换类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WordReplaceItem', @level2type=N'COLUMN',@level2name=N'ScopesType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WordReplaceItem', N'COLUMN',N'ReplaceTimes'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字符替换替换次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WordReplaceItem', @level2type=N'COLUMN',@level2name=N'ReplaceTimes'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WordReplaceItem', N'COLUMN',N'Priority'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字符替换优先级' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WordReplaceItem', @level2type=N'COLUMN',@level2name=N'Priority'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WordReplaceItem', N'COLUMN',N'OpenType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字符替换打开模式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WordReplaceItem', @level2type=N'COLUMN',@level2name=N'OpenType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WordReplaceItem', N'COLUMN',N'IsEnabled'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字符替换是否启用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WordReplaceItem', @level2type=N'COLUMN',@level2name=N'IsEnabled'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WordReplaceItem', N'COLUMN',N'Title'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字符替换后元素的Title属性' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WordReplaceItem', @level2type=N'COLUMN',@level2name=N'Title'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_WordReplaceItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字符替换表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_WordReplaceItem'
GO
/****** Object:  Table [dbo].[PE_Wap_Token]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Wap_Token]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Wap_Token](
	[LoginID] [int] NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[LoginTime] [datetime] NULL,
	[Identification] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
	[UserCookie] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Wap_ Token] PRIMARY KEY CLUSTERED 
(
	[LoginID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Token', N'COLUMN',N'LoginID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'登录信息ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Token', @level2type=N'COLUMN',@level2name=N'LoginID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Token', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Token', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Token', N'COLUMN',N'LoginTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'登录时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Token', @level2type=N'COLUMN',@level2name=N'LoginTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Token', N'COLUMN',N'Identification'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'身份证明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Token', @level2type=N'COLUMN',@level2name=N'Identification'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Token', N'COLUMN',N'UserCookie'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户信息' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Token', @level2type=N'COLUMN',@level2name=N'UserCookie'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Token', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'登录信息表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Token'
GO
/****** Object:  Table [dbo].[PE_Wap_Category]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Wap_Category]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Wap_Category](
	[WapCategoryId] [int] NOT NULL,
	[WapCategoryName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[TemplatePath] [nvarchar](500) COLLATE Chinese_PRC_CI_AS NULL,
	[OrderID] [int] NULL,
	[CommentPurviewType] [int] NULL,
	[CommentNeedCheck] [bit] NULL,
 CONSTRAINT [PK_PE_Wap_Categroy] PRIMARY KEY CLUSTERED 
(
	[WapCategoryId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Category', N'COLUMN',N'WapCategoryId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'类别ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Category', @level2type=N'COLUMN',@level2name=N'WapCategoryId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Category', N'COLUMN',N'WapCategoryName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'类别名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Category', @level2type=N'COLUMN',@level2name=N'WapCategoryName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Category', N'COLUMN',N'TemplatePath'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列表页模板路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Category', @level2type=N'COLUMN',@level2name=N'TemplatePath'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Category', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Category', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Category', N'COLUMN',N'CommentPurviewType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论权限' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Category', @level2type=N'COLUMN',@level2name=N'CommentPurviewType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Category', N'COLUMN',N'CommentNeedCheck'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论是否需要审核0-不允许评论 1-允许登录评论 2-允许游客评论' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Category', @level2type=N'COLUMN',@level2name=N'CommentNeedCheck'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Category', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'WAP类别表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Category'
GO
/****** Object:  Table [dbo].[PE_Wap_Article]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Wap_Article]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Wap_Article](
	[WapArticleId] [int] NOT NULL,
	[WapCategoryID] [int] NULL,
	[GeneralId] [int] NULL,
	[Title] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Inputer] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[UpdateTime] [datetime] NULL,
	[Status] [int] NULL,
	[Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[InputTime] [datetime] NULL,
	[Author] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Wap_Article] PRIMARY KEY CLUSTERED 
(
	[WapArticleId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Article', N'COLUMN',N'WapArticleId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Article', @level2type=N'COLUMN',@level2name=N'WapArticleId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Article', N'COLUMN',N'WapCategoryID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'类别ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Article', @level2type=N'COLUMN',@level2name=N'WapCategoryID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Article', N'COLUMN',N'GeneralId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'通用信息ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Article', @level2type=N'COLUMN',@level2name=N'GeneralId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Article', N'COLUMN',N'Title'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Article', @level2type=N'COLUMN',@level2name=N'Title'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Article', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Article', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Article', N'COLUMN',N'UpdateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Article', @level2type=N'COLUMN',@level2name=N'UpdateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Article', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态-3为删除，-2为退稿，-1为草稿，0为待审核，99为终审通过，其它为自定义' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Article', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Article', N'COLUMN',N'Content'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Article', @level2type=N'COLUMN',@level2name=N'Content'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Article', N'COLUMN',N'InputTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Article', @level2type=N'COLUMN',@level2name=N'InputTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Article', N'COLUMN',N'Author'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'作者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Article', @level2type=N'COLUMN',@level2name=N'Author'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Wap_Article', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'WAP内容信息表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Wap_Article'
GO
/****** Object:  Table [dbo].[PE_VT_VoteItem]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_VT_VoteItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_VT_VoteItem](
	[Id] [int] NOT NULL,
	[GeneralId] [int] NULL,
	[Title] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[VoteId] [int] NOT NULL,
	[TotalNumber] [int] NULL,
 CONSTRAINT [PK_PE_VT_VoteItem] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_VoteItem', N'COLUMN',N'Id'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票项目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_VoteItem', @level2type=N'COLUMN',@level2name=N'Id'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_VoteItem', N'COLUMN',N'GeneralId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_VoteItem', @level2type=N'COLUMN',@level2name=N'GeneralId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_VoteItem', N'COLUMN',N'Title'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_VoteItem', @level2type=N'COLUMN',@level2name=N'Title'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_VoteItem', N'COLUMN',N'VoteId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票主题ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_VoteItem', @level2type=N'COLUMN',@level2name=N'VoteId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_VoteItem', N'COLUMN',N'TotalNumber'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'统计数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_VoteItem', @level2type=N'COLUMN',@level2name=N'TotalNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_VoteItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票项目表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_VoteItem'
GO
/****** Object:  Table [dbo].[PE_VT_Vote]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_VT_Vote]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_VT_Vote](
	[Id] [int] NOT NULL,
	[Title] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[AllowVoteNumber] [int] NULL,
	[IsCheck] [bit] NULL,
	[EndTime] [datetime] NULL,
	[State] [int] NULL,
	[VoteLimit] [int] NULL,
 CONSTRAINT [PK_PE_VT_Vote] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_Vote', N'COLUMN',N'Id'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_Vote', @level2type=N'COLUMN',@level2name=N'Id'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_Vote', N'COLUMN',N'Title'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_Vote', @level2type=N'COLUMN',@level2name=N'Title'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_Vote', N'COLUMN',N'AllowVoteNumber'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'允许投票次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_Vote', @level2type=N'COLUMN',@level2name=N'AllowVoteNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_Vote', N'COLUMN',N'IsCheck'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否复选' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_Vote', @level2type=N'COLUMN',@level2name=N'IsCheck'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_Vote', N'COLUMN',N'EndTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'截止日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_Vote', @level2type=N'COLUMN',@level2name=N'EndTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_Vote', N'COLUMN',N'State'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_Vote', @level2type=N'COLUMN',@level2name=N'State'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_Vote', N'COLUMN',N'VoteLimit'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目投票限制类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_Vote', @level2type=N'COLUMN',@level2name=N'VoteLimit'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_Vote', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_Vote'
GO
/****** Object:  Table [dbo].[PE_VT_UserVoteTotal]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_VT_UserVoteTotal]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_VT_UserVoteTotal](
	[Id] [int] NOT NULL,
	[VoteId] [int] NOT NULL,
	[VoteItemId] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[IP] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_VT_UserVoteTotal] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_UserVoteTotal', N'COLUMN',N'Id'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票项目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_UserVoteTotal', @level2type=N'COLUMN',@level2name=N'Id'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_UserVoteTotal', N'COLUMN',N'VoteId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票主题ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_UserVoteTotal', @level2type=N'COLUMN',@level2name=N'VoteId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_UserVoteTotal', N'COLUMN',N'VoteItemId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票项目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_UserVoteTotal', @level2type=N'COLUMN',@level2name=N'VoteItemId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_UserVoteTotal', N'COLUMN',N'IP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_UserVoteTotal', @level2type=N'COLUMN',@level2name=N'IP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_UserVoteTotal', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_UserVoteTotal', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_VT_UserVoteTotal', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户投票统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_VT_UserVoteTotal'
GO
/****** Object:  Table [dbo].[PE_Vote]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Vote]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Vote](
	[VoteTitle] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[GeneralId] [int] NOT NULL,
	[IsAlive] [bit] NULL,
	[VoteItem] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[StartTime] [datetime] NULL,
	[EndTime] [datetime] NULL,
	[VoteTotalNumber] [int] NULL,
	[ItemType] [int] NULL,
 CONSTRAINT [PK_PE_Vote] PRIMARY KEY CLUSTERED 
(
	[GeneralId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Vote', N'COLUMN',N'VoteTitle'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票的标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Vote', @level2type=N'COLUMN',@level2name=N'VoteTitle'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Vote', N'COLUMN',N'GeneralId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Vote', @level2type=N'COLUMN',@level2name=N'GeneralId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Vote', N'COLUMN',N'IsAlive'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否启用投票' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Vote', @level2type=N'COLUMN',@level2name=N'IsAlive'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Vote', N'COLUMN',N'VoteItem'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'调查选项' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Vote', @level2type=N'COLUMN',@level2name=N'VoteItem'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Vote', N'COLUMN',N'StartTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票开始时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Vote', @level2type=N'COLUMN',@level2name=N'StartTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Vote', N'COLUMN',N'EndTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票结束时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Vote', @level2type=N'COLUMN',@level2name=N'EndTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Vote', N'COLUMN',N'VoteTotalNumber'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票总数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Vote', @level2type=N'COLUMN',@level2name=N'VoteTotalNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Vote', N'COLUMN',N'ItemType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票选项类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Vote', @level2type=N'COLUMN',@level2name=N'ItemType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Vote', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文章投票表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Vote'
GO
/****** Object:  Table [dbo].[PE_Version]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Version]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Version](
	[VersionID] [int] IDENTITY(1,1) NOT NULL,
	[Major] [int] NULL,
	[Minor] [int] NULL,
	[Build] [int] NULL,
	[Revision] [int] NULL,
	[CreatedDate] [datetime] NULL,
 CONSTRAINT [PK_PE_Version] PRIMARY KEY CLUSTERED 
(
	[VersionID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON),
 CONSTRAINT [IX_PE_Version] UNIQUE NONCLUSTERED 
(
	[Major] ASC,
	[Minor] ASC,
	[Build] ASC,
	[Revision] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Version', N'COLUMN',N'VersionID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'版本ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Version', @level2type=N'COLUMN',@level2name=N'VersionID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Version', N'COLUMN',N'Major'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主版本号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Version', @level2type=N'COLUMN',@level2name=N'Major'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Version', N'COLUMN',N'Minor'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'次版本号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Version', @level2type=N'COLUMN',@level2name=N'Minor'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Version', N'COLUMN',N'Build'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内部版本号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Version', @level2type=N'COLUMN',@level2name=N'Build'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Version', N'COLUMN',N'Revision'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'修订版本号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Version', @level2type=N'COLUMN',@level2name=N'Revision'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Version', N'COLUMN',N'CreatedDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Version', @level2type=N'COLUMN',@level2name=N'CreatedDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Version', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据库版本控制表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Version'
GO
/****** Object:  Table [dbo].[PE_ValidLog]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ValidLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ValidLog](
	[LogID] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[ValidNum] [int] NULL,
	[IncomePayout] [int] NULL,
	[LogTime] [datetime] NULL,
	[Remark] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IP] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Inputer] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Memo] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_ValidLog_LogID] PRIMARY KEY CLUSTERED 
(
	[LogID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ValidLog', N'COLUMN',N'LogID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'有效期明细记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ValidLog', @level2type=N'COLUMN',@level2name=N'LogID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ValidLog', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ValidLog', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ValidLog', N'COLUMN',N'ValidNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'有效期数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ValidLog', @level2type=N'COLUMN',@level2name=N'ValidNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ValidLog', N'COLUMN',N'IncomePayout'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'有效期类型  1--收入  2--支出' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ValidLog', @level2type=N'COLUMN',@level2name=N'IncomePayout'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ValidLog', N'COLUMN',N'LogTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'记录时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ValidLog', @level2type=N'COLUMN',@level2name=N'LogTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ValidLog', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注/说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ValidLog', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ValidLog', N'COLUMN',N'IP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ValidLog', @level2type=N'COLUMN',@level2name=N'IP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ValidLog', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ValidLog', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ValidLog', N'COLUMN',N'Memo'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内部记录' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ValidLog', @level2type=N'COLUMN',@level2name=N'Memo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ValidLog', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'有效期日志表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ValidLog'
GO
/****** Object:  Table [dbo].[PE_Users]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Users]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Users](
	[UserID] [int] NOT NULL,
	[GroupID] [int] NOT NULL,
	[CompanyID] [int] NULL,
	[ClientID] [int] NULL,
	[UserType] [int] NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[TrueName] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[UserPassword] [nvarchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[LastPassword] [nvarchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Question] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Answer] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Sex] [int] NULL,
	[RegTime] [datetime] NULL,
	[JoinTime] [datetime] NULL,
	[LoginTimes] [int] NULL,
	[LastLoginTime] [datetime] NULL,
	[LastPresentTime] [datetime] NULL,
	[LastLoginIP] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[LastPasswordChangedTime] [datetime] NULL,
	[LastLockoutTime] [datetime] NULL,
	[FailedPasswordAttemptCount] [int] NULL,
	[FirstFailedPasswordAttempTime] [datetime] NULL,
	[FailedPasswordAnswerAttempCount] [int] NULL,
	[FirstFailedPasswordAnswerAttempTime] [datetime] NULL,
	[Status] [int] NULL,
	[CheckNum] [char](10) COLLATE Chinese_PRC_CI_AS NULL,
	[EnableResetPassword] [bit] NULL,
	[UserCultureName] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[UserFace] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[FaceWidth] [int] NULL,
	[FaceHeight] [int] NULL,
	[Sign] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[PrivacySetting] [int] NULL,
	[Balance] [money] NULL,
	[UserPoint] [int] NULL,
	[UserExp] [int] NULL,
	[ConsumeMoney] [money] NULL,
	[ConsumePoint] [int] NULL,
	[ConsumeExp] [int] NULL,
	[PostItems] [int] NULL,
	[PassedItems] [int] NULL,
	[RejectItems] [int] NULL,
	[DelItems] [int] NULL,
	[EndTime] [datetime] NULL,
	[IsInheritGroupRole] [bit] NULL,
	[UserSetting] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[UserFriendGroup] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[PayPassword] [nvarchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[IsShowUpgradeTipsFalse] [bit] NULL,
	[LastAddPointTime] [datetime] NULL,
	[Alipay_UserID] [nvarchar](16) COLLATE Chinese_PRC_CI_AS NULL,
	[QAPoint] [int] NULL,
	[GetPasswordSid] [nvarchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[GetPasswordTime] [datetime] NULL,
	[HonorType] [int] NULL,
	[WidgetSetting] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[WidgetPara] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Users_UserID] PRIMARY KEY CLUSTERED 
(
	[UserID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Users]') AND name = N'IX_PE_Users_UserName')
CREATE NONCLUSTERED INDEX [IX_PE_Users_UserName] ON [dbo].[PE_Users] 
(
	[UserName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'UserID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'UserID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'GroupID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户组ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'GroupID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'CompanyID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'对应企业ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'CompanyID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'ClientID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户信息Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'ClientID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'UserType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员类别，0－个人会员 1企业会员(创建者) 2企业会员(管理员) 3企业会员(普通成员) 4 企业会员(待审核成员)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'UserType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'TrueName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户真实姓名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'TrueName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'UserPassword'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'UserPassword'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'LastPassword'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'LastPassword'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'Question'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'提示问题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'Question'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'Answer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'提示答案' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'Answer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'Email'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'电子邮件' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'Email'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'Sex'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'性别' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'Sex'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'RegTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'注册时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'RegTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'JoinTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'加入某用户组的时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'JoinTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'LoginTimes'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'登录次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'LoginTimes'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'LastLoginTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后登录时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'LastLoginTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'LastPresentTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后赠送积分时间，用于每次登录赠送积分的设置' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'LastPresentTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'LastLoginIP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后登录IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'LastLoginIP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'LastPasswordChangedTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上次修改密码的时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'LastPasswordChangedTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'LastLockoutTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上次被锁定的时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'LastLockoutTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'FailedPasswordAttemptCount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'使用无效密码登录的次数，正确登录后置为0' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'FailedPasswordAttemptCount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'FirstFailedPasswordAttempTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第一次使用无效密码登录的时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'FirstFailedPasswordAttempTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'FailedPasswordAnswerAttempCount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'使用无效答案找回密码的次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'FailedPasswordAnswerAttempCount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'FirstFailedPasswordAnswerAttempTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第一次使用无效答案找回密码的时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'FirstFailedPasswordAnswerAttempTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N' 用户状态。0－－正常，1－－锁定，2－－未通过邮件验证，4－－未通过管理员认证 8－－未通过手机验证' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'CheckNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'验证码。用于邮件验证' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'CheckNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'EnableResetPassword'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否允许用户修改密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'EnableResetPassword'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'UserCultureName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户语言' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'UserCultureName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'UserFace'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户头像' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'UserFace'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'FaceWidth'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'头像宽度' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'FaceWidth'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'FaceHeight'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'头像高度' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'FaceHeight'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'Sign'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户签名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'Sign'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'PrivacySetting'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'隐私设置' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'PrivacySetting'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'Balance'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'资金余额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'Balance'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'UserPoint'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户点券数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'UserPoint'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'UserExp'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户积分' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'UserExp'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'ConsumeMoney'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'消费的金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'ConsumeMoney'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'ConsumePoint'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'消费的点券数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'ConsumePoint'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'ConsumeExp'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'消费的积分数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'ConsumeExp'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'PostItems'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'添加的信息数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'PostItems'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'PassedItems'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'审核通过的信息数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'PassedItems'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'RejectItems'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'被退稿的信息数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'RejectItems'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'DelItems'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'被删除的信息数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'DelItems'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'EndTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'有效期开始计算时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'EndTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'IsInheritGroupRole'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否继承用户组权限，默认为true' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'IsInheritGroupRole'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'UserSetting'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户权限' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'UserSetting'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'UserFriendGroup'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户好友组' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'UserFriendGroup'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'PayPassword'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'支付密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'PayPassword'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'IsShowUpgradeTipsFalse'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否不再显示用户升级提示信息，默认为false' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'IsShowUpgradeTipsFalse'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'LastAddPointTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上次添加点券的时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'LastAddPointTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'Alipay_UserID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'支付宝用户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'Alipay_UserID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'QAPoint'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'问答积分' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'QAPoint'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'GetPasswordSid'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'取回密码随机串' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'GetPasswordSid'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'GetPasswordTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上次取回密码时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'GetPasswordTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'HonorType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户问答头衔' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'HonorType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'WidgetSetting'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Widget配置数据' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'WidgetSetting'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', N'COLUMN',N'WidgetPara'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Widget参数配置数据' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users', @level2type=N'COLUMN',@level2name=N'WidgetPara'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Users', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Users'
GO
/****** Object:  Table [dbo].[PE_UserHitHistory]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_UserHitHistory]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_UserHitHistory](
	[ID] [int] NOT NULL,
	[GeneralID] [int] NULL,
	[ScanIP] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Hits] [int] NULL,
	[HitTime] [datetime] NULL,
	[LastHitTime] [datetime] NULL,
 CONSTRAINT [PK_PE_UserHitHistory] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserHitHistory', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'浏览记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserHitHistory', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserHitHistory', N'COLUMN',N'GeneralID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容信息ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserHitHistory', @level2type=N'COLUMN',@level2name=N'GeneralID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserHitHistory', N'COLUMN',N'ScanIP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserHitHistory', @level2type=N'COLUMN',@level2name=N'ScanIP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserHitHistory', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserHitHistory', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserHitHistory', N'COLUMN',N'Hits'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'浏览次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserHitHistory', @level2type=N'COLUMN',@level2name=N'Hits'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserHitHistory', N'COLUMN',N'HitTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'浏览时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserHitHistory', @level2type=N'COLUMN',@level2name=N'HitTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserHitHistory', N'COLUMN',N'LastHitTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后浏览时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserHitHistory', @level2type=N'COLUMN',@level2name=N'LastHitTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserHitHistory', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户浏览内容信息历史记录表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserHitHistory'
GO
/****** Object:  Table [dbo].[PE_UserGroups]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_UserGroups]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_UserGroups](
	[GroupID] [int] NOT NULL,
	[GroupName] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[Description] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Settings] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[GroupType] [int] NULL,
	[GroupSetting] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[UpgradeSetting] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_UserGroups_GroupID] PRIMARY KEY CLUSTERED 
(
	[GroupID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserGroups', N'COLUMN',N'GroupID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户组ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserGroups', @level2type=N'COLUMN',@level2name=N'GroupID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserGroups', N'COLUMN',N'GroupName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户组名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserGroups', @level2type=N'COLUMN',@level2name=N'GroupName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserGroups', N'COLUMN',N'Description'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户组说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserGroups', @level2type=N'COLUMN',@level2name=N'Description'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserGroups', N'COLUMN',N'Settings'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户组设置，用XML保存如下配置。' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserGroups', @level2type=N'COLUMN',@level2name=N'Settings'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserGroups', N'COLUMN',N'GroupType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserGroups', @level2type=N'COLUMN',@level2name=N'GroupType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserGroups', N'COLUMN',N'GroupSetting'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户权限' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserGroups', @level2type=N'COLUMN',@level2name=N'GroupSetting'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserGroups', N'COLUMN',N'UpgradeSetting'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户升级参数设置' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserGroups', @level2type=N'COLUMN',@level2name=N'UpgradeSetting'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserGroups', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户组表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserGroups'
GO
/****** Object:  Table [dbo].[PE_UserExpLog]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_UserExpLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_UserExpLog](
	[LogID] [int] NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[ExpNum] [int] NULL,
	[IncomePayout] [int] NULL,
	[LogTime] [datetime] NULL,
	[Remark] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IP] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[OrderID] [int] NULL,
	[Inputer] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Memo] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IsConsume] [bit] NULL,
 CONSTRAINT [PK_PE_UserExpLog_LogID] PRIMARY KEY CLUSTERED 
(
	[LogID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_UserExpLog]') AND name = N'IX_PE_UserExpLog_OrderID')
CREATE NONCLUSTERED INDEX [IX_PE_UserExpLog_OrderID] ON [dbo].[PE_UserExpLog] 
(
	[OrderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_UserExpLog]') AND name = N'IX_PE_UserExpLog_UserName')
CREATE NONCLUSTERED INDEX [IX_PE_UserExpLog_UserName] ON [dbo].[PE_UserExpLog] 
(
	[UserName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserExpLog', N'COLUMN',N'LogID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'积分明细记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserExpLog', @level2type=N'COLUMN',@level2name=N'LogID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserExpLog', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserExpLog', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserExpLog', N'COLUMN',N'ExpNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'积分数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserExpLog', @level2type=N'COLUMN',@level2name=N'ExpNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserExpLog', N'COLUMN',N'IncomePayout'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'积分类型  1--收入  2--支出' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserExpLog', @level2type=N'COLUMN',@level2name=N'IncomePayout'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserExpLog', N'COLUMN',N'LogTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'记录时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserExpLog', @level2type=N'COLUMN',@level2name=N'LogTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserExpLog', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注/说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserExpLog', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserExpLog', N'COLUMN',N'IP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserExpLog', @level2type=N'COLUMN',@level2name=N'IP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserExpLog', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserExpLog', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserExpLog', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserExpLog', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserExpLog', N'COLUMN',N'Memo'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内部记录' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserExpLog', @level2type=N'COLUMN',@level2name=N'Memo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserExpLog', N'COLUMN',N'IsConsume'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否消费' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserExpLog', @level2type=N'COLUMN',@level2name=N'IsConsume'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_UserExpLog', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'积分日志表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_UserExpLog'
GO
/****** Object:  Table [dbo].[PE_TransferLog]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_TransferLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_TransferLog](
	[TransferLogID] [int] IDENTITY(1,1) NOT NULL,
	[OrderID] [int] NULL,
	[TransferTime] [datetime] NULL,
	[OwnerUserName] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[PayerUserName] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[TargetUserName] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[Poundage] [money] NULL,
	[Inputer] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_TransferLog_TransferLogID] PRIMARY KEY CLUSTERED 
(
	[TransferLogID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_TransferLog]') AND name = N'IX_PE_TransferLog_OrderID')
CREATE NONCLUSTERED INDEX [IX_PE_TransferLog_OrderID] ON [dbo].[PE_TransferLog] 
(
	[OrderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_TransferLog', N'COLUMN',N'TransferLogID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单过户记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_TransferLog', @level2type=N'COLUMN',@level2name=N'TransferLogID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_TransferLog', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_TransferLog', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_TransferLog', N'COLUMN',N'TransferTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'过户时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_TransferLog', @level2type=N'COLUMN',@level2name=N'TransferTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_TransferLog', N'COLUMN',N'OwnerUserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'过户人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_TransferLog', @level2type=N'COLUMN',@level2name=N'OwnerUserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_TransferLog', N'COLUMN',N'PayerUserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'付款人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_TransferLog', @level2type=N'COLUMN',@level2name=N'PayerUserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_TransferLog', N'COLUMN',N'TargetUserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'过户给' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_TransferLog', @level2type=N'COLUMN',@level2name=N'TargetUserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_TransferLog', N'COLUMN',N'Poundage'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'过户费' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_TransferLog', @level2type=N'COLUMN',@level2name=N'Poundage'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_TransferLog', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'经手人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_TransferLog', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_TransferLog', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_TransferLog', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_TransferLog', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单过户表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_TransferLog'
GO
/****** Object:  Table [dbo].[PE_Trademark]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Trademark]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Trademark](
	[TrademarkID] [int] IDENTITY(1,1) NOT NULL,
	[TrademarkType] [int] NOT NULL,
	[ProducerID] [int] NOT NULL,
	[TrademarkName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[TrademarkPhoto] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[TrademarkIntro] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Passed] [bit] NOT NULL,
	[onTop] [bit] NOT NULL,
	[IsElite] [bit] NOT NULL,
	[Hits] [int] NOT NULL,
	[SearchIndex] [char](1) COLLATE Chinese_PRC_CI_AS NULL,
	[TrademarkShortIntro] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
	[TrademarkBeginDate] [datetime] NULL,
	[TrademarkAdBannerPhoto] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[TrademarkAdMultiPhoto] [nvarchar](500) COLLATE Chinese_PRC_CI_AS NULL,
	[TrademarkAdMiddlePhoto] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Trademark_TrademarkID] PRIMARY KEY CLUSTERED 
(
	[TrademarkID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Trademark]') AND name = N'IX_PE_Trademark_ProducerID')
CREATE NONCLUSTERED INDEX [IX_PE_Trademark_ProducerID] ON [dbo].[PE_Trademark] 
(
	[ProducerID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'TrademarkID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商标ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'TrademarkID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'TrademarkType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商标分类' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'TrademarkType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'ProducerID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商标持有人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'ProducerID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'TrademarkName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'品牌或商标' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'TrademarkName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'TrademarkPhoto'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'品牌LOGO' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'TrademarkPhoto'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'TrademarkIntro'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商标简介' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'TrademarkIntro'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'Passed'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否通过' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'Passed'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'onTop'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否固顶' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'onTop'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'IsElite'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否推荐' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'IsElite'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'Hits'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'点击数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'Hits'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'SearchIndex'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'索引字母' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'SearchIndex'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'TrademarkShortIntro'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'品牌简介' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'TrademarkShortIntro'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'TrademarkBeginDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'进驻日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'TrademarkBeginDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'TrademarkAdBannerPhoto'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'顶部广告图' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'TrademarkAdBannerPhoto'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'TrademarkAdMultiPhoto'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'广告多图' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'TrademarkAdMultiPhoto'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', N'COLUMN',N'TrademarkAdMiddlePhoto'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'中部广告图' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark', @level2type=N'COLUMN',@level2name=N'TrademarkAdMiddlePhoto'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Trademark', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'品牌表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Trademark'
GO
/****** Object:  Table [dbo].[PE_SurveyVote]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SurveyVote]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_SurveyVote](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[SurveyID] [int] NULL,
	[QuestionID] [int] NULL,
	[OptionID] [int] NULL,
	[VoteAmount] [int] NULL,
 CONSTRAINT [PK_PE_SurveyVote_ID] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_SurveyVote]') AND name = N'IX_PE_SurveyVote_SurveyID')
CREATE NONCLUSTERED INDEX [IX_PE_SurveyVote_SurveyID] ON [dbo].[PE_SurveyVote] 
(
	[SurveyID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SurveyVote', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SurveyVote', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SurveyVote', N'COLUMN',N'SurveyID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'问卷ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SurveyVote', @level2type=N'COLUMN',@level2name=N'SurveyID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SurveyVote', N'COLUMN',N'QuestionID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'问题ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SurveyVote', @level2type=N'COLUMN',@level2name=N'QuestionID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SurveyVote', N'COLUMN',N'OptionID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SurveyVote', @level2type=N'COLUMN',@level2name=N'OptionID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SurveyVote', N'COLUMN',N'VoteAmount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投票数目' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SurveyVote', @level2type=N'COLUMN',@level2name=N'VoteAmount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SurveyVote', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'问卷投票结果数据表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SurveyVote'
GO
/****** Object:  Table [dbo].[PE_Survey]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Survey]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Survey](
	[SurveyID] [int] NOT NULL,
	[SurveyName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Description] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[FileName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[IPRepeat] [int] NULL,
	[CreateDate] [datetime] NULL,
	[EndTime] [datetime] NULL,
	[IsOpen] [int] NULL,
	[NeedLogin] [int] NULL,
	[PresentPoint] [int] NULL,
	[LockIPType] [int] NULL,
	[SetIPLock] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[LockUrl] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[SetPassword] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Template] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[QuestionField] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[QuestionMaxID] [int] NULL,
	[IsResultPublic] [bit] NULL,
 CONSTRAINT [PK_PE_Survey_SurveyID] PRIMARY KEY CLUSTERED 
(
	[SurveyID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Survey]') AND name = N'IX_PE_Survey_TemplateID')
CREATE NONCLUSTERED INDEX [IX_PE_Survey_TemplateID] ON [dbo].[PE_Survey] 
(
	[Template] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'SurveyID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'调查问卷ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'SurveyID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'SurveyName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'调查问卷名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'SurveyName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'Description'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'调查问卷描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'Description'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'FileName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文件名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'FileName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'IPRepeat'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'同一IP允许重复提交次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'IPRepeat'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'CreateDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'CreateDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'EndTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'结束日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'EndTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'IsOpen'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1--启用，0---没起用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'IsOpen'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'NeedLogin'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'登录后才能投票 (1--需要，0---不需要)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'NeedLogin'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'PresentPoint'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'注册会员参与者奖励点数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'PresentPoint'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'LockIPType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'限定IP段类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'LockIPType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'SetIPLock'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'设置IP限制,为空时，表示不启用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'SetIPLock'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'LockUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'限定地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'LockUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'SetPassword'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'设置密码限制，为空时，表示不启用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'SetPassword'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'Template'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'问卷模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'Template'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'QuestionField'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'题目字段' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'QuestionField'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'QuestionMaxID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'题目最大ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'QuestionMaxID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', N'COLUMN',N'IsResultPublic'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'调查结果是否公开，1是0否' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey', @level2type=N'COLUMN',@level2name=N'IsResultPublic'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Survey', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'调查表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Survey'
GO
/****** Object:  Table [dbo].[PE_SubscriptionItems]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SubscriptionItems]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_SubscriptionItems](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Content] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Inputer] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[CreateTime] [datetime] NULL,
 CONSTRAINT [PK_PE_SubscriptionItems] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SubscriptionItems', N'COLUMN',N'Id'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订阅项ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SubscriptionItems', @level2type=N'COLUMN',@level2name=N'Id'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SubscriptionItems', N'COLUMN',N'Name'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订阅项名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SubscriptionItems', @level2type=N'COLUMN',@level2name=N'Name'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SubscriptionItems', N'COLUMN',N'Content'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订阅项描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SubscriptionItems', @level2type=N'COLUMN',@level2name=N'Content'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SubscriptionItems', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SubscriptionItems', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SubscriptionItems', N'COLUMN',N'CreateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SubscriptionItems', @level2type=N'COLUMN',@level2name=N'CreateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SubscriptionItems', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订阅项表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SubscriptionItems'
GO
/****** Object:  Table [dbo].[PE_StockItem]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StockItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StockItem](
	[ItemID] [int] NOT NULL,
	[StockID] [int] NOT NULL,
	[ProductID] [int] NOT NULL,
	[Property] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Amount] [int] NOT NULL,
	[Price] [money] NULL,
	[TableName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_StockItem] PRIMARY KEY CLUSTERED 
(
	[ItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StockItem', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StockItem', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StockItem', N'COLUMN',N'StockID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'库存记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StockItem', @level2type=N'COLUMN',@level2name=N'StockID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StockItem', N'COLUMN',N'ProductID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品ID ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StockItem', @level2type=N'COLUMN',@level2name=N'ProductID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StockItem', N'COLUMN',N'Property'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品属性' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StockItem', @level2type=N'COLUMN',@level2name=N'Property'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StockItem', N'COLUMN',N'Amount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StockItem', @level2type=N'COLUMN',@level2name=N'Amount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StockItem', N'COLUMN',N'Price'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'价钱(成本价/售货价)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StockItem', @level2type=N'COLUMN',@level2name=N'Price'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StockItem', N'COLUMN',N'TableName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'表名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StockItem', @level2type=N'COLUMN',@level2name=N'TableName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StockItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'库存明细表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StockItem'
GO
/****** Object:  Table [dbo].[PE_Stock]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Stock]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Stock](
	[StockID] [int] NOT NULL,
	[StockNum] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[InputTime] [datetime] NOT NULL,
	[Inputer] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[StockType] [int] NOT NULL,
	[Remark] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Status] [int] NULL,
 CONSTRAINT [PK_PE_Stock] PRIMARY KEY CLUSTERED 
(
	[StockID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Stock', N'COLUMN',N'StockID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Stock', @level2type=N'COLUMN',@level2name=N'StockID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Stock', N'COLUMN',N'StockNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'库单编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Stock', @level2type=N'COLUMN',@level2name=N'StockNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Stock', N'COLUMN',N'InputTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Stock', @level2type=N'COLUMN',@level2name=N'InputTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Stock', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Stock', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Stock', N'COLUMN',N'StockType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'库单类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Stock', @level2type=N'COLUMN',@level2name=N'StockType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Stock', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Stock', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Stock', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Stock', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Stock', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'库存表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Stock'
GO
/****** Object:  Table [dbo].[PE_StatYear]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatYear]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatYear](
	[1] [int] NULL,
	[2] [int] NULL,
	[3] [int] NULL,
	[4] [int] NULL,
	[5] [int] NULL,
	[6] [int] NULL,
	[7] [int] NULL,
	[8] [int] NULL,
	[9] [int] NULL,
	[10] [int] NULL,
	[11] [int] NULL,
	[12] [int] NULL,
	[TYear] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK_PE_StatYear] PRIMARY KEY CLUSTERED 
(
	[TYear] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatYear', N'COLUMN',N'1'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'一月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatYear', @level2type=N'COLUMN',@level2name=N'1'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatYear', N'COLUMN',N'2'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'二月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatYear', @level2type=N'COLUMN',@level2name=N'2'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatYear', N'COLUMN',N'3'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'三月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatYear', @level2type=N'COLUMN',@level2name=N'3'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatYear', N'COLUMN',N'4'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'四月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatYear', @level2type=N'COLUMN',@level2name=N'4'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatYear', N'COLUMN',N'5'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'五月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatYear', @level2type=N'COLUMN',@level2name=N'5'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatYear', N'COLUMN',N'6'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'六月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatYear', @level2type=N'COLUMN',@level2name=N'6'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatYear', N'COLUMN',N'7'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'七月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatYear', @level2type=N'COLUMN',@level2name=N'7'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatYear', N'COLUMN',N'8'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'八月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatYear', @level2type=N'COLUMN',@level2name=N'8'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatYear', N'COLUMN',N'9'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'九月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatYear', @level2type=N'COLUMN',@level2name=N'9'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatYear', N'COLUMN',N'10'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'十月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatYear', @level2type=N'COLUMN',@level2name=N'10'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatYear', N'COLUMN',N'11'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'十一月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatYear', @level2type=N'COLUMN',@level2name=N'11'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatYear', N'COLUMN',N'12'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'十二月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatYear', @level2type=N'COLUMN',@level2name=N'12'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatYear', N'COLUMN',N'TYear'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'年度分类' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatYear', @level2type=N'COLUMN',@level2name=N'TYear'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatYear', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'年统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatYear'
GO
/****** Object:  Table [dbo].[PE_StatWeek]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatWeek](
	[1] [int] NULL,
	[2] [int] NULL,
	[3] [int] NULL,
	[4] [int] NULL,
	[5] [int] NULL,
	[6] [int] NULL,
	[7] [int] NULL,
	[TWeek] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK_PE_StatWeek] PRIMARY KEY CLUSTERED 
(
	[TWeek] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatWeek', N'COLUMN',N'1'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'周一' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatWeek', @level2type=N'COLUMN',@level2name=N'1'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatWeek', N'COLUMN',N'2'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'周二' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatWeek', @level2type=N'COLUMN',@level2name=N'2'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatWeek', N'COLUMN',N'3'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'周三' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatWeek', @level2type=N'COLUMN',@level2name=N'3'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatWeek', N'COLUMN',N'4'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'周四' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatWeek', @level2type=N'COLUMN',@level2name=N'4'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatWeek', N'COLUMN',N'5'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'周五' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatWeek', @level2type=N'COLUMN',@level2name=N'5'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatWeek', N'COLUMN',N'6'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'周六' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatWeek', @level2type=N'COLUMN',@level2name=N'6'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatWeek', N'COLUMN',N'7'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'周日' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatWeek', @level2type=N'COLUMN',@level2name=N'7'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatWeek', N'COLUMN',N'TWeek'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'周分类' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatWeek', @level2type=N'COLUMN',@level2name=N'TWeek'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatWeek', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'周统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatWeek'
GO
/****** Object:  Table [dbo].[PE_StatWeburl]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatWeburl]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatWeburl](
	[TWeburl] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[TWebNum] [int] NULL,
 CONSTRAINT [PK_PE_StatWeburl] PRIMARY KEY CLUSTERED 
(
	[TWeburl] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatWeburl', N'COLUMN',N'TWeburl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户来自何网址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatWeburl', @level2type=N'COLUMN',@level2name=N'TWeburl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatWeburl', N'COLUMN',N'TWebNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatWeburl', @level2type=N'COLUMN',@level2name=N'TWebNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatWeburl', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'来访网站统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatWeburl'
GO
/****** Object:  Table [dbo].[PE_StatVisitor]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatVisitor]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatVisitor](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[VTime] [datetime] NULL,
	[Ip] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Address] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[System] [varchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[Browser] [varchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[Screen] [varchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[Color] [varchar](16) COLLATE Chinese_PRC_CI_AS NULL,
	[Referer] [varchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Timezone] [int] NULL,
 CONSTRAINT [PK_PE_StatVisitor] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisitor', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisitor', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisitor', N'COLUMN',N'VTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'访问时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisitor', @level2type=N'COLUMN',@level2name=N'VTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisitor', N'COLUMN',N'Ip'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ip地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisitor', @level2type=N'COLUMN',@level2name=N'Ip'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisitor', N'COLUMN',N'Address'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'地理位置' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisitor', @level2type=N'COLUMN',@level2name=N'Address'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisitor', N'COLUMN',N'System'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作系统' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisitor', @level2type=N'COLUMN',@level2name=N'System'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisitor', N'COLUMN',N'Browser'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'浏览器' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisitor', @level2type=N'COLUMN',@level2name=N'Browser'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisitor', N'COLUMN',N'Screen'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'显示器分辨率' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisitor', @level2type=N'COLUMN',@level2name=N'Screen'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisitor', N'COLUMN',N'Color'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'显示器色彩' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisitor', @level2type=N'COLUMN',@level2name=N'Color'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisitor', N'COLUMN',N'Referer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'来路' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisitor', @level2type=N'COLUMN',@level2name=N'Referer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisitor', N'COLUMN',N'Timezone'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'时区' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisitor', @level2type=N'COLUMN',@level2name=N'Timezone'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisitor', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最近访问者表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisitor'
GO
/****** Object:  Table [dbo].[PE_StatVisit]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatVisit](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[1] [int] NULL,
	[2] [int] NULL,
	[3] [int] NULL,
	[4] [int] NULL,
	[5] [int] NULL,
	[6] [int] NULL,
	[7] [int] NULL,
	[8] [int] NULL,
	[9] [int] NULL,
	[10] [int] NULL,
 CONSTRAINT [PK_PE_StatVisit] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisit', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'次数ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisit', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisit', N'COLUMN',N'1'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'访问1次' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisit', @level2type=N'COLUMN',@level2name=N'1'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisit', N'COLUMN',N'2'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'访问2次' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisit', @level2type=N'COLUMN',@level2name=N'2'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisit', N'COLUMN',N'3'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'访问3次' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisit', @level2type=N'COLUMN',@level2name=N'3'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisit', N'COLUMN',N'4'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'访问4次' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisit', @level2type=N'COLUMN',@level2name=N'4'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisit', N'COLUMN',N'5'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'访问5次' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisit', @level2type=N'COLUMN',@level2name=N'5'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisit', N'COLUMN',N'6'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'访问6次' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisit', @level2type=N'COLUMN',@level2name=N'6'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisit', N'COLUMN',N'7'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'访问7次' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisit', @level2type=N'COLUMN',@level2name=N'7'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisit', N'COLUMN',N'8'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'访问8次' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisit', @level2type=N'COLUMN',@level2name=N'8'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisit', N'COLUMN',N'9'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'访问9次' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisit', @level2type=N'COLUMN',@level2name=N'9'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisit', N'COLUMN',N'10'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'访问10次或以上' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisit', @level2type=N'COLUMN',@level2name=N'10'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatVisit', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'访问次数统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatVisit'
GO
/****** Object:  Table [dbo].[PE_Status]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Status]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Status](
	[StatusID] [int] NOT NULL,
	[StatusCode] [int] NOT NULL,
	[StatusName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[StatusType] [int] NOT NULL,
 CONSTRAINT [PK_PE_Status_StatusID] PRIMARY KEY CLUSTERED 
(
	[StatusID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Status', N'COLUMN',N'StatusID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态码ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Status', @level2type=N'COLUMN',@level2name=N'StatusID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Status', N'COLUMN',N'StatusCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Status', @level2type=N'COLUMN',@level2name=N'StatusCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Status', N'COLUMN',N'StatusName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态码名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Status', @level2type=N'COLUMN',@level2name=N'StatusName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Status', N'COLUMN',N'StatusType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'系统状态码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Status', @level2type=N'COLUMN',@level2name=N'StatusType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Status', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'流程状态码表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Status'
GO
/****** Object:  Table [dbo].[PE_StatTimezone]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatTimezone]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatTimezone](
	[TTimezone] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[TTimNum] [int] NULL,
 CONSTRAINT [PK_PE_StatTimezone] PRIMARY KEY CLUSTERED 
(
	[TTimezone] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatTimezone', N'COLUMN',N'TTimezone'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'时区' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatTimezone', @level2type=N'COLUMN',@level2name=N'TTimezone'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatTimezone', N'COLUMN',N'TTimNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatTimezone', @level2type=N'COLUMN',@level2name=N'TTimNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatTimezone', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'时区统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatTimezone'
GO
/****** Object:  Table [dbo].[PE_StatSystem]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatSystem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatSystem](
	[TSystem] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[TSysNum] [int] NULL,
 CONSTRAINT [PK_PE_StatSystem] PRIMARY KEY CLUSTERED 
(
	[TSystem] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatSystem', N'COLUMN',N'TSystem'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作系统' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatSystem', @level2type=N'COLUMN',@level2name=N'TSystem'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatSystem', N'COLUMN',N'TSysNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatSystem', @level2type=N'COLUMN',@level2name=N'TSysNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatSystem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作系统统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatSystem'
GO
/****** Object:  Table [dbo].[PE_StatScreen]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatScreen]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatScreen](
	[TScreen] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[TScrNum] [int] NULL,
 CONSTRAINT [PK_PE_StatScreen] PRIMARY KEY CLUSTERED 
(
	[TScreen] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatScreen', N'COLUMN',N'TScreen'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分辨率' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatScreen', @level2type=N'COLUMN',@level2name=N'TScreen'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatScreen', N'COLUMN',N'TScrNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatScreen', @level2type=N'COLUMN',@level2name=N'TScrNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatScreen', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'屏幕分辨率统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatScreen'
GO
/****** Object:  Table [dbo].[PE_StatRefer]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatRefer]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatRefer](
	[TRefer] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[TRefNum] [int] NULL,
 CONSTRAINT [PK_PE_StatRefer] PRIMARY KEY CLUSTERED 
(
	[TRefer] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatRefer', N'COLUMN',N'TRefer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'引用地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatRefer', @level2type=N'COLUMN',@level2name=N'TRefer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatRefer', N'COLUMN',N'TRefNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatRefer', @level2type=N'COLUMN',@level2name=N'TRefNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatRefer', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'来访页统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatRefer'
GO
/****** Object:  Table [dbo].[PE_StatOnline]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatOnline]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatOnline](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[UserIP] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[UserAgent] [varchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[UserPage] [varchar](4000) COLLATE Chinese_PRC_CI_AS NULL,
	[OnTime] [datetime] NULL,
	[LastTime] [datetime] NULL,
 CONSTRAINT [PK_PE_StatOnline] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatOnline', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatOnline', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatOnline', N'COLUMN',N'UserIP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'访问者IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatOnline', @level2type=N'COLUMN',@level2name=N'UserIP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatOnline', N'COLUMN',N'UserAgent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户端信息' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatOnline', @level2type=N'COLUMN',@level2name=N'UserAgent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatOnline', N'COLUMN',N'UserPage'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所在页面' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatOnline', @level2type=N'COLUMN',@level2name=N'UserPage'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatOnline', N'COLUMN',N'OnTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上站时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatOnline', @level2type=N'COLUMN',@level2name=N'OnTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatOnline', N'COLUMN',N'LastTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后刷新时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatOnline', @level2type=N'COLUMN',@level2name=N'LastTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatOnline', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'在线访问统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatOnline'
GO
/****** Object:  Table [dbo].[PE_StatMozilla]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatMozilla]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatMozilla](
	[TMozilla] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[TMozNum] [int] NULL,
 CONSTRAINT [PK_PE_StatMozilla] PRIMARY KEY CLUSTERED 
(
	[TMozilla] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMozilla', N'COLUMN',N'TMozilla'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'URL字段' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMozilla', @level2type=N'COLUMN',@level2name=N'TMozilla'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMozilla', N'COLUMN',N'TMozNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMozilla', @level2type=N'COLUMN',@level2name=N'TMozNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMozilla', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Mozilla统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMozilla'
GO
/****** Object:  Table [dbo].[PE_StatMonth]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatMonth](
	[1] [int] NULL,
	[2] [int] NULL,
	[3] [int] NULL,
	[4] [int] NULL,
	[5] [int] NULL,
	[6] [int] NULL,
	[7] [int] NULL,
	[8] [int] NULL,
	[9] [int] NULL,
	[10] [int] NULL,
	[11] [int] NULL,
	[12] [int] NULL,
	[13] [int] NULL,
	[14] [int] NULL,
	[15] [int] NULL,
	[16] [int] NULL,
	[17] [int] NULL,
	[18] [int] NULL,
	[19] [int] NULL,
	[20] [int] NULL,
	[21] [int] NULL,
	[22] [int] NULL,
	[23] [int] NULL,
	[24] [int] NULL,
	[25] [int] NULL,
	[26] [int] NULL,
	[27] [int] NULL,
	[28] [int] NULL,
	[29] [int] NULL,
	[30] [int] NULL,
	[31] [int] NULL,
	[TMonth] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK_PE_StatMonth] PRIMARY KEY CLUSTERED 
(
	[TMonth] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'1'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第1天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'1'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'2'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第2天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'2'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'3'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第3天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'3'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'4'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第4天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'4'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'5'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第5天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'5'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'6'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第6天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'6'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'7'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第7天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'7'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'8'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第8天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'8'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'9'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第9天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'9'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'10'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第10天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'10'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'11'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第11天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'11'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'12'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第12天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'12'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'13'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第13天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'13'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'14'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第14天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'14'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'15'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第15天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'15'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'16'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第16天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'16'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'17'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第17天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'17'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'18'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第18天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'18'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'19'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第19天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'19'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'20'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第20天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'20'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'21'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第21天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'21'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'22'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第22天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'22'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'23'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第23天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'23'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'24'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第24天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'24'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'25'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第25天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'25'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'26'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第26天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'26'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'27'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第27天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'27'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'28'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第28天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'28'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'29'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第29天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'29'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'30'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第30天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'30'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'31'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第31天' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'31'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', N'COLUMN',N'TMonth'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'月份' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth', @level2type=N'COLUMN',@level2name=N'TMonth'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatMonth', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'月统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatMonth'
GO
/****** Object:  Table [dbo].[PE_StatKeyword]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatKeyword]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatKeyword](
	[TKeyword] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[TKeywordNum] [int] NULL,
 CONSTRAINT [PK_PE_StatKeyword] PRIMARY KEY CLUSTERED 
(
	[TKeyword] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatKeyword', N'COLUMN',N'TKeyword'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatKeyword', @level2type=N'COLUMN',@level2name=N'TKeyword'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatKeyword', N'COLUMN',N'TKeywordNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatKeyword', @level2type=N'COLUMN',@level2name=N'TKeywordNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatKeyword', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatKeyword'
GO
/****** Object:  Table [dbo].[PE_StatIpInfo]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatIpInfo]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatIpInfo](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[StartIp] [float] NOT NULL,
	[EndIp] [float] NOT NULL,
	[Address] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK_PE_StatIpInfo] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatIpInfo', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatIpInfo', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatIpInfo', N'COLUMN',N'StartIp'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'起始IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatIpInfo', @level2type=N'COLUMN',@level2name=N'StartIp'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatIpInfo', N'COLUMN',N'EndIp'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'结束IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatIpInfo', @level2type=N'COLUMN',@level2name=N'EndIp'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatIpInfo', N'COLUMN',N'Address'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'来源详细地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatIpInfo', @level2type=N'COLUMN',@level2name=N'Address'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatIpInfo', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP地址信息表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatIpInfo'
GO
/****** Object:  Table [dbo].[PE_StatIp]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatIp]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatIp](
	[TIp] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[TIpNum] [int] NULL,
 CONSTRAINT [PK_PE_StatIp] PRIMARY KEY CLUSTERED 
(
	[TIp] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatIp]') AND name = N'TIp')
CREATE NONCLUSTERED INDEX [TIp] ON [dbo].[PE_StatIp] 
(
	[TIp] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatIp', N'COLUMN',N'TIp'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ip地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatIp', @level2type=N'COLUMN',@level2name=N'TIp'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatIp', N'COLUMN',N'TIpNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatIp', @level2type=N'COLUMN',@level2name=N'TIpNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatIp', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP地址统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatIp'
GO
/****** Object:  Table [dbo].[PE_StatInfoList]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatInfoList](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[StartDate] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[TotalNum] [int] NOT NULL,
	[TotalView] [int] NULL,
	[MonthNum] [int] NULL,
	[MonthMaxNum] [int] NULL,
	[OldMonth] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[MonthMaxDate] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[DayNum] [int] NULL,
	[DayMaxNum] [int] NULL,
	[OldDay] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[DayMaxDate] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[HourNum] [int] NULL,
	[HourMaxNum] [int] NULL,
	[OldHour] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[HourMaxTime] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[ChinaNum] [int] NULL,
	[OtherNum] [int] NULL,
	[MasterTimeZone] [int] NULL,
	[Interval] [int] NULL,
	[IntervalNum] [int] NULL,
	[OnlineTime] [int] NULL,
	[VisitRecord] [int] NULL,
	[KillRefresh] [int] NULL,
	[RegFields_Fill] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[OldTotalNum] [int] NULL,
	[OldTotalView] [int] NULL,
 CONSTRAINT [PK_PE_StatInfoList] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'StartDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'开始统计日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'StartDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'TotalNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'总访问量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'TotalNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'TotalView'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'总浏览量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'TotalView'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'MonthNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'月访量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'MonthNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'MonthMaxNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最高月访量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'MonthMaxNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'OldMonth'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'使用系统前的月访量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'OldMonth'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'MonthMaxDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最高月访量月份' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'MonthMaxDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'DayNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'今日访问量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'DayNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'DayMaxNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最高日访量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'DayMaxNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'OldDay'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'使用系统前的日访量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'OldDay'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'DayMaxDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最高日访量日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'DayMaxDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'HourNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'时访量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'HourNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'HourMaxNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最高时访量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'HourMaxNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'OldHour'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'使用系统前的时访问量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'OldHour'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'HourMaxTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最高时访量时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'HourMaxTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'ChinaNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'国内访问人数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'ChinaNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'OtherNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'国外访问人数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'OtherNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'MasterTimeZone'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务器所在时区' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'MasterTimeZone'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'Interval'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自动标记在线间隔' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'Interval'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'IntervalNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自动标记在线间隔循环次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'IntervalNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'OnlineTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'在线用户的保留时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'OnlineTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'VisitRecord'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'保留访问记录数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'VisitRecord'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'KillRefresh'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'保留访问IP数(大于20小于800的数字)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'KillRefresh'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'RegFields_Fill'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'启用的要进行统计的功能项目' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'RegFields_Fill'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'OldTotalNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'使用本系统前的访问量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'OldTotalNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', N'COLUMN',N'OldTotalView'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'使用本系统前的浏览量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList', @level2type=N'COLUMN',@level2name=N'OldTotalView'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatInfoList', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'统计信息表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatInfoList'
GO
/****** Object:  Table [dbo].[PE_StatDay]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatDay]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatDay](
	[0] [int] NULL,
	[1] [int] NULL,
	[2] [int] NULL,
	[3] [int] NULL,
	[4] [int] NULL,
	[5] [int] NULL,
	[6] [int] NULL,
	[7] [int] NULL,
	[8] [int] NULL,
	[9] [int] NULL,
	[10] [int] NULL,
	[11] [int] NULL,
	[12] [int] NULL,
	[13] [int] NULL,
	[14] [int] NULL,
	[15] [int] NULL,
	[16] [int] NULL,
	[17] [int] NULL,
	[18] [int] NULL,
	[19] [int] NULL,
	[20] [int] NULL,
	[21] [int] NULL,
	[22] [int] NULL,
	[23] [int] NULL,
	[TDay] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK_PE_StatDay] PRIMARY KEY CLUSTERED 
(
	[TDay] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'0'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'0'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'1'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'1'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'2'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'2点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'2'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'3'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'3点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'3'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'4'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'4点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'4'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'5'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'5点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'5'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'6'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'6点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'6'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'7'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'7点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'7'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'8'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'8点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'8'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'9'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'9点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'9'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'10'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'10点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'10'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'11'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'11点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'11'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'12'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'12点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'12'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'13'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'13点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'13'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'14'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'14点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'14'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'15'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'15点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'15'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'16'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'16点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'16'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'17'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'17点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'17'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'18'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'18点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'18'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'19'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'19点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'19'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'20'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'20点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'20'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'21'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'21点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'21'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'22'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'22点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'22'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'23'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'23点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'23'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', N'COLUMN',N'TDay'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay', @level2type=N'COLUMN',@level2name=N'TDay'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatDay', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'日统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatDay'
GO
/****** Object:  Table [dbo].[PE_StatColor]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatColor]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatColor](
	[TColor] [nvarchar](16) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[TColNum] [int] NULL,
 CONSTRAINT [PK_PE_StatColor] PRIMARY KEY CLUSTERED 
(
	[TColor] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatColor', N'COLUMN',N'TColor'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'颜色' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatColor', @level2type=N'COLUMN',@level2name=N'TColor'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatColor', N'COLUMN',N'TColNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatColor', @level2type=N'COLUMN',@level2name=N'TColNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatColor', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'屏幕颜色统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatColor'
GO
/****** Object:  Table [dbo].[PE_StatBrowser]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatBrowser]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatBrowser](
	[TBrowser] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[TBrwNum] [int] NULL,
 CONSTRAINT [PK_PE_StatBrowser] PRIMARY KEY CLUSTERED 
(
	[TBrowser] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatBrowser', N'COLUMN',N'TBrowser'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'浏览器' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatBrowser', @level2type=N'COLUMN',@level2name=N'TBrowser'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatBrowser', N'COLUMN',N'TBrwNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatBrowser', @level2type=N'COLUMN',@level2name=N'TBrwNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatBrowser', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'浏览器统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatBrowser'
GO
/****** Object:  Table [dbo].[PE_StatAddress]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_StatAddress]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_StatAddress](
	[TAddress] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[TAddNum] [int] NULL,
 CONSTRAINT [PK_PE_StatAddress] PRIMARY KEY CLUSTERED 
(
	[TAddress] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatAddress', N'COLUMN',N'TAddress'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'地区名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatAddress', @level2type=N'COLUMN',@level2name=N'TAddress'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatAddress', N'COLUMN',N'TAddNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatAddress', @level2type=N'COLUMN',@level2name=N'TAddNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_StatAddress', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'来访地址统计表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_StatAddress'
GO
/****** Object:  Table [dbo].[PE_Specials]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Specials]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Specials](
	[SpecialID] [int] NOT NULL,
	[SpecialName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecialCategoryID] [int] NOT NULL,
	[SpecialDir] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecialIdentifier] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[SpecialPic] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecialTips] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecialTemplatePath] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[IsElite] [bit] NULL,
	[OrderID] [int] NULL,
	[OpenType] [int] NULL,
	[Description] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IsCreateListPage] [bit] NULL,
	[ListPageSavePathType] [int] NULL,
	[ListPagePostfix] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Custom_Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[SearchTemplatePath] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[NeedCreateHtml] [bit] NULL,
	[MetaKeywords] [nvarchar](4000) COLLATE Chinese_PRC_CI_AS NULL,
	[MetaDescription] [nvarchar](4000) COLLATE Chinese_PRC_CI_AS NULL,
	[CreateTime] [datetime] NULL,
	[IsPigeonhole] [bit] NULL,
 CONSTRAINT [PK_PE_Specials_SpecialID] PRIMARY KEY CLUSTERED 
(
	[SpecialID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Specials]') AND name = N'IX_PE_Specials_SpecialCategoryID')
CREATE NONCLUSTERED INDEX [IX_PE_Specials_SpecialCategoryID] ON [dbo].[PE_Specials] 
(
	[SpecialCategoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Specials]') AND name = N'IX_PE_Specials_SpecialIdentifier')
CREATE NONCLUSTERED INDEX [IX_PE_Specials_SpecialIdentifier] ON [dbo].[PE_Specials] 
(
	[SpecialIdentifier] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'SpecialID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'SpecialID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'SpecialName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'SpecialName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'SpecialCategoryID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属专题类别ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'SpecialCategoryID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'SpecialDir'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题目录' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'SpecialDir'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'SpecialIdentifier'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题标识符' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'SpecialIdentifier'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'SpecialPic'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题图片地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'SpecialPic'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'SpecialTips'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题提示' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'SpecialTips'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'SpecialTemplatePath'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题页模板路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'SpecialTemplatePath'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'IsElite'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否推荐' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'IsElite'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题排序ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'OpenType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题打开方式 0-原窗口 1-新窗口' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'OpenType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'Description'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'Description'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'IsCreateListPage'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列表页是否生成HTML' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'IsCreateListPage'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'ListPageSavePathType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列表页生成规则' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'ListPageSavePathType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'ListPagePostfix'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列表页生成HTML后缀' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'ListPagePostfix'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'Custom_Content'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自设内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'Custom_Content'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'SearchTemplatePath'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题搜索页模板路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'SearchTemplatePath'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'NeedCreateHtml'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否有需要生成HTML的专题内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'NeedCreateHtml'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'MetaKeywords'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Meta关键词' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'MetaKeywords'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'MetaDescription'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Meta描述语' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'MetaDescription'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'CreateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'CreateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', N'COLUMN',N'IsPigeonhole'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题是否已归档' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials', @level2type=N'COLUMN',@level2name=N'IsPigeonhole'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Specials', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Specials'
GO
/****** Object:  Table [dbo].[PE_SpecialInfos]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SpecialInfos]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_SpecialInfos](
	[SpecialInfoID] [int] NOT NULL,
	[SpecialID] [int] NOT NULL,
	[GeneralID] [int] NOT NULL,
 CONSTRAINT [PK_PE_SpecialInfos] PRIMARY KEY CLUSTERED 
(
	[SpecialInfoID] ASC,
	[SpecialID] ASC,
	[GeneralID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialInfos', N'COLUMN',N'SpecialInfoID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题信息ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialInfos', @level2type=N'COLUMN',@level2name=N'SpecialInfoID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialInfos', N'COLUMN',N'SpecialID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属专题ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialInfos', @level2type=N'COLUMN',@level2name=N'SpecialID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialInfos', N'COLUMN',N'GeneralID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属实链接ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialInfos', @level2type=N'COLUMN',@level2name=N'GeneralID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialInfos', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题信息表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialInfos'
GO
/****** Object:  Table [dbo].[PE_SpecialCategory]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SpecialCategory]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_SpecialCategory](
	[SpecialCategoryID] [int] NOT NULL,
	[SpecialCategoryName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecialCategoryDir] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecialTemplatePath] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[OrderID] [int] NULL,
	[OpenType] [bit] NULL,
	[Description] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IsCreateHtml] [bit] NULL,
	[PagePostfix] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[SearchTemplatePath] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[NeedCreateHtml] [bit] NULL,
 CONSTRAINT [PK_PE_SpecialCategory] PRIMARY KEY CLUSTERED 
(
	[SpecialCategoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialCategory', N'COLUMN',N'SpecialCategoryID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题类别ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialCategory', @level2type=N'COLUMN',@level2name=N'SpecialCategoryID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialCategory', N'COLUMN',N'SpecialCategoryName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题类别名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialCategory', @level2type=N'COLUMN',@level2name=N'SpecialCategoryName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialCategory', N'COLUMN',N'SpecialCategoryDir'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题类别目录名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialCategory', @level2type=N'COLUMN',@level2name=N'SpecialCategoryDir'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialCategory', N'COLUMN',N'SpecialTemplatePath'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题列表页模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialCategory', @level2type=N'COLUMN',@level2name=N'SpecialTemplatePath'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialCategory', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题类别排序ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialCategory', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialCategory', N'COLUMN',N'OpenType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题类别打开方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialCategory', @level2type=N'COLUMN',@level2name=N'OpenType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialCategory', N'COLUMN',N'Description'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题类别描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialCategory', @level2type=N'COLUMN',@level2name=N'Description'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialCategory', N'COLUMN',N'IsCreateHtml'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否生成HTML' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialCategory', @level2type=N'COLUMN',@level2name=N'IsCreateHtml'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialCategory', N'COLUMN',N'PagePostfix'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生成专题列表页扩展名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialCategory', @level2type=N'COLUMN',@level2name=N'PagePostfix'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialCategory', N'COLUMN',N'SearchTemplatePath'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题搜索页模板路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialCategory', @level2type=N'COLUMN',@level2name=N'SearchTemplatePath'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialCategory', N'COLUMN',N'NeedCreateHtml'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否有需要生成HTML的专题内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialCategory', @level2type=N'COLUMN',@level2name=N'NeedCreateHtml'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SpecialCategory', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题类别表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SpecialCategory'
GO
/****** Object:  Table [dbo].[PE_Source]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Source]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Source](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Type] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Name] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Passed] [bit] NULL,
	[onTop] [bit] NULL,
	[IsElite] [bit] NULL,
	[Hits] [int] NULL,
	[LastUseTime] [datetime] NULL,
	[Photo] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Intro] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Address] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Tel] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Fax] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Mail] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ZipCode] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[HomePage] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Im] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Contacter] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PE_CopyFrom_PK] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'来源Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'Type'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'来源类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'Type'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'Name'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'来源名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'Name'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'Passed'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否通过审核' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'Passed'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'onTop'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否置顶' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'onTop'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'IsElite'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否推荐' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'IsElite'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'Hits'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'点击数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'Hits'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'LastUseTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最近登录时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'LastUseTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'Photo'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'来源图片' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'Photo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'Intro'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'简介' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'Intro'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'Address'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'Address'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'Tel'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'电话' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'Tel'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'Fax'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'传真' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'Fax'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'Mail'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'通信地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'Mail'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'Email'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'电子邮件' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'Email'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'ZipCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮政编码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'ZipCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'HomePage'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'个人网站' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'HomePage'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'Im'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Imeeting，即时聊天号码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'Im'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', N'COLUMN',N'Contacter'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'联系人名字' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source', @level2type=N'COLUMN',@level2name=N'Contacter'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Source', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'来源表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Source'
GO
/****** Object:  Table [dbo].[PE_SigninLog]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SigninLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_SigninLog](
	[GeneralID] [int] NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[IsSignin] [bit] NULL,
	[SigninTime] [datetime] NULL,
	[IP] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_SigninLog] PRIMARY KEY CLUSTERED 
(
	[GeneralID] ASC,
	[UserName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SigninLog', N'COLUMN',N'GeneralID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SigninLog', @level2type=N'COLUMN',@level2name=N'GeneralID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SigninLog', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'签收用户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SigninLog', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SigninLog', N'COLUMN',N'IsSignin'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否签收' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SigninLog', @level2type=N'COLUMN',@level2name=N'IsSignin'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SigninLog', N'COLUMN',N'SigninTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'签收时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SigninLog', @level2type=N'COLUMN',@level2name=N'SigninTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SigninLog', N'COLUMN',N'IP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'签收IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SigninLog', @level2type=N'COLUMN',@level2name=N'IP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SigninLog', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'签收日志表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SigninLog'
GO
/****** Object:  Table [dbo].[PE_SigninContent]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SigninContent]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_SigninContent](
	[GeneralID] [int] NOT NULL,
	[Title] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[SigninType] [int] NULL,
	[Priority] [int] NULL,
	[EndTime] [datetime] NULL,
	[Status] [int] NULL,
 CONSTRAINT [PK_PE_SigninContent] PRIMARY KEY CLUSTERED 
(
	[GeneralID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SigninContent', N'COLUMN',N'GeneralID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SigninContent', @level2type=N'COLUMN',@level2name=N'GeneralID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SigninContent', N'COLUMN',N'Title'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SigninContent', @level2type=N'COLUMN',@level2name=N'Title'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SigninContent', N'COLUMN',N'SigninType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'签收类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SigninContent', @level2type=N'COLUMN',@level2name=N'SigninType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SigninContent', N'COLUMN',N'Priority'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优先级' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SigninContent', @level2type=N'COLUMN',@level2name=N'Priority'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SigninContent', N'COLUMN',N'EndTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'签收截止时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SigninContent', @level2type=N'COLUMN',@level2name=N'EndTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SigninContent', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'签收状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SigninContent', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SigninContent', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容签收表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SigninContent'
GO
/****** Object:  Table [dbo].[PE_ShoppingCarts]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ShoppingCarts](
	[CartItemID] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[CartID] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [int] NULL,
	[Quantity] [int] NULL,
	[IsPresent] [bit] NULL,
	[UpdateTime] [datetime] NULL,
	[TableName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Property] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[InformResult] [int] NULL,
	[BelongsToProductID] [int] NULL,
	[GroupBuyID] [int] NULL,
	[SecondsKillID] [int] NULL,
 CONSTRAINT [PK_PE_ShoppingCarts_CartItemID] PRIMARY KEY CLUSTERED 
(
	[CartItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]') AND name = N'IX_PE_ShoppingCarts_CartID')
CREATE NONCLUSTERED INDEX [IX_PE_ShoppingCarts_CartID] ON [dbo].[PE_ShoppingCarts] 
(
	[CartID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]') AND name = N'IX_PE_ShoppingCarts_PresentID')
CREATE NONCLUSTERED INDEX [IX_PE_ShoppingCarts_PresentID] ON [dbo].[PE_ShoppingCarts] 
(
	[IsPresent] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]') AND name = N'IX_PE_ShoppingCarts_ProductID')
CREATE NONCLUSTERED INDEX [IX_PE_ShoppingCarts_ProductID] ON [dbo].[PE_ShoppingCarts] 
(
	[ProductID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ShoppingCarts', N'COLUMN',N'CartItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ShoppingCarts', @level2type=N'COLUMN',@level2name=N'CartItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ShoppingCarts', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ShoppingCarts', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ShoppingCarts', N'COLUMN',N'CartID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'购物车ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ShoppingCarts', @level2type=N'COLUMN',@level2name=N'CartID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ShoppingCarts', N'COLUMN',N'ProductID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ShoppingCarts', @level2type=N'COLUMN',@level2name=N'ProductID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ShoppingCarts', N'COLUMN',N'Quantity'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订购数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ShoppingCarts', @level2type=N'COLUMN',@level2name=N'Quantity'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ShoppingCarts', N'COLUMN',N'IsPresent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'赠品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ShoppingCarts', @level2type=N'COLUMN',@level2name=N'IsPresent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ShoppingCarts', N'COLUMN',N'UpdateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ShoppingCarts', @level2type=N'COLUMN',@level2name=N'UpdateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ShoppingCarts', N'COLUMN',N'TableName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品表名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ShoppingCarts', @level2type=N'COLUMN',@level2name=N'TableName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ShoppingCarts', N'COLUMN',N'Property'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品属性' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ShoppingCarts', @level2type=N'COLUMN',@level2name=N'Property'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ShoppingCarts', N'COLUMN',N'InformResult'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信通知结果' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ShoppingCarts', @level2type=N'COLUMN',@level2name=N'InformResult'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ShoppingCarts', N'COLUMN',N'BelongsToProductID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关联商品编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ShoppingCarts', @level2type=N'COLUMN',@level2name=N'BelongsToProductID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ShoppingCarts', N'COLUMN',N'GroupBuyID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'团购ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ShoppingCarts', @level2type=N'COLUMN',@level2name=N'GroupBuyID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ShoppingCarts', N'COLUMN',N'SecondsKillID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'秒杀ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ShoppingCarts', @level2type=N'COLUMN',@level2name=N'SecondsKillID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ShoppingCarts', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'购物车表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ShoppingCarts'
GO
/****** Object:  Table [dbo].[PE_ServiceItem]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ServiceItem](
	[ItemID] [int] IDENTITY(1,1) NOT NULL,
	[ClientID] [int] NULL,
	[ContacterID] [int] NULL,
	[OrderID] [int] NULL,
	[ServiceTime] [datetime] NULL,
	[ServiceType] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ServiceMode] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ServiceTitle] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ServiceContent] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[ServiceResult] [int] NULL,
	[TakeTime] [int] NULL,
	[ServicePoint] [int] NOT NULL,
	[Processor] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Inputer] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Feedback] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[ConfirmTime] [datetime] NULL,
	[ConfirmCaller] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ConfirmScore] [int] NULL,
	[ConfirmFeedback] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_ServiceItem] PRIMARY KEY CLUSTERED 
(
	[ItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]') AND name = N'IX_PE_ServiceItem_ClientID')
CREATE NONCLUSTERED INDEX [IX_PE_ServiceItem_ClientID] ON [dbo].[PE_ServiceItem] 
(
	[ClientID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]') AND name = N'IX_PE_ServiceItem_ContacterID')
CREATE NONCLUSTERED INDEX [IX_PE_ServiceItem_ContacterID] ON [dbo].[PE_ServiceItem] 
(
	[ContacterID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]') AND name = N'IX_PE_ServiceItem_OrderID')
CREATE NONCLUSTERED INDEX [IX_PE_ServiceItem_OrderID] ON [dbo].[PE_ServiceItem] 
(
	[OrderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'明细ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'ClientID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'ClientID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'ContacterID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'联系人ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'ContacterID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'ServiceTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'ServiceTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'ServiceType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'ServiceType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'ServiceMode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'ServiceMode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'ServiceTitle'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务主题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'ServiceTitle'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'ServiceContent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'ServiceContent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'ServiceResult'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务结果，0为未完成，1为完成' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'ServiceResult'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'TakeTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'花费时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'TakeTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'ServicePoint'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务点数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'ServicePoint'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'Processor'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'执行人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'Processor'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'Feedback'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户反馈' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'Feedback'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'ConfirmTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回访时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'ConfirmTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'ConfirmCaller'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回访人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'ConfirmCaller'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'ConfirmScore'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户评价' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'ConfirmScore'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'ConfirmFeedback'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户反馈' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'ConfirmFeedback'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ServiceItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务记录表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ServiceItem'
GO
/****** Object:  Table [dbo].[PE_SendBackItem]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SendBackItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_SendBackItem](
	[ItemID] [int] NOT NULL,
	[SendBackID] [int] NOT NULL,
	[ProductID] [int] NOT NULL,
	[Property] [nvarchar](510) COLLATE Chinese_PRC_CI_AS NULL,
	[Amount] [int] NOT NULL,
	[Price] [money] NULL,
	[TableName] [nvarchar](510) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_SendBackItem] PRIMARY KEY CLUSTERED 
(
	[ItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBackItem', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBackItem', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBackItem', N'COLUMN',N'SendBackID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'退货单记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBackItem', @level2type=N'COLUMN',@level2name=N'SendBackID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBackItem', N'COLUMN',N'ProductID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBackItem', @level2type=N'COLUMN',@level2name=N'ProductID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBackItem', N'COLUMN',N'Property'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品属性' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBackItem', @level2type=N'COLUMN',@level2name=N'Property'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBackItem', N'COLUMN',N'Amount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBackItem', @level2type=N'COLUMN',@level2name=N'Amount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBackItem', N'COLUMN',N'Price'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'价钱(成本价/售货价)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBackItem', @level2type=N'COLUMN',@level2name=N'Price'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBackItem', N'COLUMN',N'TableName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据表名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBackItem', @level2type=N'COLUMN',@level2name=N'TableName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBackItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'退货项表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBackItem'
GO
/****** Object:  Table [dbo].[PE_SendBack]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_SendBack]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_SendBack](
	[SendBackID] [int] NOT NULL,
	[SendBackNum] [nvarchar](40) COLLATE Chinese_PRC_CI_AS NULL,
	[InputTime] [datetime] NOT NULL,
	[Inputer] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Status] [int] NOT NULL,
	[Remark] [nvarchar](510) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_SendBack] PRIMARY KEY CLUSTERED 
(
	[SendBackID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBack', N'COLUMN',N'SendBackID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBack', @level2type=N'COLUMN',@level2name=N'SendBackID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBack', N'COLUMN',N'SendBackNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBack', @level2type=N'COLUMN',@level2name=N'SendBackNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBack', N'COLUMN',N'InputTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBack', @level2type=N'COLUMN',@level2name=N'InputTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBack', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBack', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBack', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBack', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBack', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBack', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_SendBack', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'退货表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_SendBack'
GO
/****** Object:  Table [dbo].[PE_ScreenShot]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ScreenShot]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ScreenShot](
	[ModuleID] [int] NOT NULL,
	[ModuleName] [nvarchar](500) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ModuleUrl] [nvarchar](250) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ModuleLeftUrl] [nvarchar](250) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ModulePicAddress] [nvarchar](500) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[AdminID] [int] NOT NULL,
 CONSTRAINT [PK_PE_ScreenShot] PRIMARY KEY CLUSTERED 
(
	[ModuleID] ASC,
	[AdminID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ScreenShot', N'COLUMN',N'ModuleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模块ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ScreenShot', @level2type=N'COLUMN',@level2name=N'ModuleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ScreenShot', N'COLUMN',N'ModuleName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模块名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ScreenShot', @level2type=N'COLUMN',@level2name=N'ModuleName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ScreenShot', N'COLUMN',N'ModuleUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模块连接地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ScreenShot', @level2type=N'COLUMN',@level2name=N'ModuleUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ScreenShot', N'COLUMN',N'ModuleLeftUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模块连接左地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ScreenShot', @level2type=N'COLUMN',@level2name=N'ModuleLeftUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ScreenShot', N'COLUMN',N'ModulePicAddress'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模块图片地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ScreenShot', @level2type=N'COLUMN',@level2name=N'ModulePicAddress'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ScreenShot', N'COLUMN',N'AdminID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ScreenShot', @level2type=N'COLUMN',@level2name=N'AdminID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ScreenShot', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网页生成图片表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ScreenShot'
GO
/****** Object:  Table [dbo].[PE_Roles_ScopePermissions]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Roles_ScopePermissions]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Roles_ScopePermissions](
	[RoleID] [int] NOT NULL,
	[ScopeCode] [int] NOT NULL,
	[Scope] [int] NULL,
 CONSTRAINT [PK_PE_Roles_ScopePermissions] PRIMARY KEY CLUSTERED 
(
	[RoleID] ASC,
	[ScopeCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Roles_ScopePermissions', N'COLUMN',N'RoleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Roles_ScopePermissions', @level2type=N'COLUMN',@level2name=N'RoleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Roles_ScopePermissions', N'COLUMN',N'ScopeCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作范围码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Roles_ScopePermissions', @level2type=N'COLUMN',@level2name=N'ScopeCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Roles_ScopePermissions', N'COLUMN',N'Scope'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作范围' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Roles_ScopePermissions', @level2type=N'COLUMN',@level2name=N'Scope'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Roles_ScopePermissions', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色操作范围表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Roles_ScopePermissions'
GO
/****** Object:  Table [dbo].[PE_Roles_Permissions]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Roles_Permissions]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Roles_Permissions](
	[RoleID] [int] NOT NULL,
	[OperateCode] [int] NOT NULL,
 CONSTRAINT [PK_PE_Roles_Permissions] PRIMARY KEY CLUSTERED 
(
	[RoleID] ASC,
	[OperateCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Roles_Permissions', N'COLUMN',N'RoleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Roles_Permissions', @level2type=N'COLUMN',@level2name=N'RoleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Roles_Permissions', N'COLUMN',N'OperateCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'权限操作码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Roles_Permissions', @level2type=N'COLUMN',@level2name=N'OperateCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Roles_Permissions', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色权限表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Roles_Permissions'
GO
/****** Object:  Table [dbo].[PE_Roles]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Roles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Roles](
	[RoleID] [int] NOT NULL,
	[RoleName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Description] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Roles] PRIMARY KEY CLUSTERED 
(
	[RoleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Roles', N'COLUMN',N'RoleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Roles', @level2type=N'COLUMN',@level2name=N'RoleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Roles', N'COLUMN',N'RoleName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Roles', @level2type=N'COLUMN',@level2name=N'RoleName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Roles', N'COLUMN',N'Description'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Roles', @level2type=N'COLUMN',@level2name=N'Description'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Roles', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Roles'
GO
/****** Object:  Table [dbo].[PE_Role_Special_Permissions]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Role_Special_Permissions]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Role_Special_Permissions](
	[RoleID] [int] NOT NULL,
	[SpecialID] [int] NOT NULL,
	[OperateCode] [int] NOT NULL,
 CONSTRAINT [PK_PE_Role_Special_Permissions] PRIMARY KEY CLUSTERED 
(
	[RoleID] ASC,
	[SpecialID] ASC,
	[OperateCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Role_Special_Permissions', N'COLUMN',N'RoleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Role_Special_Permissions', @level2type=N'COLUMN',@level2name=N'RoleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Role_Special_Permissions', N'COLUMN',N'SpecialID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Role_Special_Permissions', @level2type=N'COLUMN',@level2name=N'SpecialID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Role_Special_Permissions', N'COLUMN',N'OperateCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'权限操作码值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Role_Special_Permissions', @level2type=N'COLUMN',@level2name=N'OperateCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Role_Special_Permissions', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色专题权限表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Role_Special_Permissions'
GO
/****** Object:  Table [dbo].[PE_Role_Node_Permissions]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Role_Node_Permissions]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Role_Node_Permissions](
	[RoleID] [int] NOT NULL,
	[NodeID] [int] NOT NULL,
	[OperateCode] [int] NOT NULL,
 CONSTRAINT [PK_PE_Role_Node_Permissions] PRIMARY KEY CLUSTERED 
(
	[RoleID] ASC,
	[NodeID] ASC,
	[OperateCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Role_Node_Permissions', N'COLUMN',N'RoleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Role_Node_Permissions', @level2type=N'COLUMN',@level2name=N'RoleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Role_Node_Permissions', N'COLUMN',N'NodeID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Role_Node_Permissions', @level2type=N'COLUMN',@level2name=N'NodeID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Role_Node_Permissions', N'COLUMN',N'OperateCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'权限操作码值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Role_Node_Permissions', @level2type=N'COLUMN',@level2name=N'OperateCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Role_Node_Permissions', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色节点权限表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Role_Node_Permissions'
GO
/****** Object:  Table [dbo].[PE_Role_Field_Permissions]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Role_Field_Permissions]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Role_Field_Permissions](
	[RoleID] [int] NOT NULL,
	[ModelID] [int] NOT NULL,
	[FieldName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[OperateCode] [int] NOT NULL,
 CONSTRAINT [PK_PE_Role_Field_Permissions] PRIMARY KEY CLUSTERED 
(
	[RoleID] ASC,
	[ModelID] ASC,
	[FieldName] ASC,
	[OperateCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Role_Field_Permissions', N'COLUMN',N'RoleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Role_Field_Permissions', @level2type=N'COLUMN',@level2name=N'RoleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Role_Field_Permissions', N'COLUMN',N'ModelID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Role_Field_Permissions', @level2type=N'COLUMN',@level2name=N'ModelID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Role_Field_Permissions', N'COLUMN',N'FieldName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型字段名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Role_Field_Permissions', @level2type=N'COLUMN',@level2name=N'FieldName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Role_Field_Permissions', N'COLUMN',N'OperateCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'权限操作码值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Role_Field_Permissions', @level2type=N'COLUMN',@level2name=N'OperateCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Role_Field_Permissions', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色字段权限表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Role_Field_Permissions'
GO
/****** Object:  Table [dbo].[PE_RemindItem]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_RemindItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_RemindItem](
	[RemindId] [int] NOT NULL,
	[Creater] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[CreateTime] [datetime] NULL,
	[RemindTime] [datetime] NULL,
	[RelationType] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[RemindContent] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
	[CorrelativeClient] [int] NULL,
	[CorrelativeContacter] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[RemindByTips] [bit] NULL,
	[RemindByEmail] [bit] NULL,
	[RemindBySms] [bit] NULL,
	[Status] [bit] NULL,
 CONSTRAINT [PK_PE_RemindItem] PRIMARY KEY CLUSTERED 
(
	[RemindId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RemindItem', N'COLUMN',N'RemindId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'提醒ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RemindItem', @level2type=N'COLUMN',@level2name=N'RemindId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RemindItem', N'COLUMN',N'Creater'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建提醒的人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RemindItem', @level2type=N'COLUMN',@level2name=N'Creater'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RemindItem', N'COLUMN',N'CreateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建提醒的时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RemindItem', @level2type=N'COLUMN',@level2name=N'CreateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RemindItem', N'COLUMN',N'RemindTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'提醒时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RemindItem', @level2type=N'COLUMN',@level2name=N'RemindTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RemindItem', N'COLUMN',N'RelationType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'预约联系方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RemindItem', @level2type=N'COLUMN',@level2name=N'RelationType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RemindItem', N'COLUMN',N'RemindContent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'提醒内容（备注型字段，不支持HTML）' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RemindItem', @level2type=N'COLUMN',@level2name=N'RemindContent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RemindItem', N'COLUMN',N'CorrelativeClient'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关联客户（记录客户ID）' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RemindItem', @level2type=N'COLUMN',@level2name=N'CorrelativeClient'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RemindItem', N'COLUMN',N'CorrelativeContacter'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关联客户的联系人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RemindItem', @level2type=N'COLUMN',@level2name=N'CorrelativeContacter'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RemindItem', N'COLUMN',N'RemindByTips'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否冒泡提示主动提醒' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RemindItem', @level2type=N'COLUMN',@level2name=N'RemindByTips'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RemindItem', N'COLUMN',N'RemindByEmail'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否发送邮件主动提醒' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RemindItem', @level2type=N'COLUMN',@level2name=N'RemindByEmail'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RemindItem', N'COLUMN',N'RemindBySms'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否发送手机短信主动提醒' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RemindItem', @level2type=N'COLUMN',@level2name=N'RemindBySms'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RemindItem', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态。0表示未处理，1表示已经处理' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RemindItem', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RemindItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'预约提醒表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RemindItem'
GO
/****** Object:  Table [dbo].[PE_Region]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Region]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Region](
	[RegionID] [int] IDENTITY(1,1) NOT NULL,
	[Country] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Province] [nvarchar](25) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[City] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[Area] [nvarchar](25) COLLATE Chinese_PRC_CI_AS NULL,
	[PostCode] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[AreaCode] [nvarchar](8) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK_PE_Region_RegionID] PRIMARY KEY CLUSTERED 
(
	[RegionID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Region', N'COLUMN',N'RegionID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'区域ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Region', @level2type=N'COLUMN',@level2name=N'RegionID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Region', N'COLUMN',N'Country'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'国家名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Region', @level2type=N'COLUMN',@level2name=N'Country'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Region', N'COLUMN',N'Province'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'省份名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Region', @level2type=N'COLUMN',@level2name=N'Province'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Region', N'COLUMN',N'City'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'城市名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Region', @level2type=N'COLUMN',@level2name=N'City'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Region', N'COLUMN',N'Area'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'区域名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Region', @level2type=N'COLUMN',@level2name=N'Area'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Region', N'COLUMN',N'PostCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮政编码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Region', @level2type=N'COLUMN',@level2name=N'PostCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Region', N'COLUMN',N'AreaCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'区号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Region', @level2type=N'COLUMN',@level2name=N'AreaCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Region', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'行政区划表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Region'
GO
/****** Object:  Table [dbo].[PE_RedirectUrl]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_RedirectUrl]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_RedirectUrl](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[UrlID] [int] NOT NULL,
	[UrlName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[UrlValue] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[UrlDescription] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[CategoryID] [int] NOT NULL,
 CONSTRAINT [PK_PE_RedirectUrl_ID] PRIMARY KEY NONCLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RedirectUrl', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RedirectUrl', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RedirectUrl', N'COLUMN',N'UrlID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'链接编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RedirectUrl', @level2type=N'COLUMN',@level2name=N'UrlID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RedirectUrl', N'COLUMN',N'UrlName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'链接名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RedirectUrl', @level2type=N'COLUMN',@level2name=N'UrlName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RedirectUrl', N'COLUMN',N'UrlValue'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'连接地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RedirectUrl', @level2type=N'COLUMN',@level2name=N'UrlValue'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RedirectUrl', N'COLUMN',N'UrlDescription'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RedirectUrl', @level2type=N'COLUMN',@level2name=N'UrlDescription'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RedirectUrl', N'COLUMN',N'CategoryID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'类别编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RedirectUrl', @level2type=N'COLUMN',@level2name=N'CategoryID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RedirectUrl', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'转向链接信息表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RedirectUrl'
GO
/****** Object:  Table [dbo].[PE_RedirectCategory]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_RedirectCategory]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_RedirectCategory](
	[CategoryID] [int] IDENTITY(1,1) NOT NULL,
	[CategoryName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[CategoryDescription] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[OrderID] [int] NULL,
 CONSTRAINT [PK_PE_RedirectCategory_CategoryID] PRIMARY KEY NONCLUSTERED 
(
	[CategoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RedirectCategory', N'COLUMN',N'CategoryID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'链接类别编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RedirectCategory', @level2type=N'COLUMN',@level2name=N'CategoryID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RedirectCategory', N'COLUMN',N'CategoryName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'链接类别名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RedirectCategory', @level2type=N'COLUMN',@level2name=N'CategoryName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RedirectCategory', N'COLUMN',N'CategoryDescription'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'链接类别描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RedirectCategory', @level2type=N'COLUMN',@level2name=N'CategoryDescription'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RedirectCategory', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RedirectCategory', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_RedirectCategory', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'转向链接信息类别表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_RedirectCategory'
GO
/****** Object:  Table [dbo].[PE_Provider]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Provider]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Provider](
	[ProviderID] [int] NOT NULL,
	[ProviderName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[InputTime] [datetime] NOT NULL,
	[Inputer] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [nvarchar](510) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Provider] PRIMARY KEY CLUSTERED 
(
	[ProviderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Provider', N'COLUMN',N'ProviderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Provider', @level2type=N'COLUMN',@level2name=N'ProviderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Provider', N'COLUMN',N'ProviderName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'供应商名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Provider', @level2type=N'COLUMN',@level2name=N'ProviderName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Provider', N'COLUMN',N'InputTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Provider', @level2type=N'COLUMN',@level2name=N'InputTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Provider', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Provider', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Provider', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Provider', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Provider', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'供应商表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Provider'
GO
/****** Object:  Table [dbo].[PE_ProductPrice]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ProductPrice]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ProductPrice](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ProductID] [int] NULL,
	[PropertyValue] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[TableName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[GroupID] [int] NULL,
	[Price] [money] NULL,
 CONSTRAINT [PK_PE_ProductPrice] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductPrice', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductPrice', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductPrice', N'COLUMN',N'ProductID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductPrice', @level2type=N'COLUMN',@level2name=N'ProductID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductPrice', N'COLUMN',N'PropertyValue'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'属性值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductPrice', @level2type=N'COLUMN',@level2name=N'PropertyValue'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductPrice', N'COLUMN',N'TableName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'表名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductPrice', @level2type=N'COLUMN',@level2name=N'TableName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductPrice', N'COLUMN',N'GroupID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员组ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductPrice', @level2type=N'COLUMN',@level2name=N'GroupID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductPrice', N'COLUMN',N'Price'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'价格' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductPrice', @level2type=N'COLUMN',@level2name=N'Price'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductPrice', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品价格表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductPrice'
GO
/****** Object:  Table [dbo].[PE_ProductData]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ProductData]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ProductData](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ProductID] [int] NULL,
	[TableName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[PropertyValue] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Stocks] [int] NULL,
	[OrderNum] [int] NULL,
	[AlarmNum] [int] NULL,
	[BuyTimes] [int] NULL,
	[Price] [money] NULL,
	[Price_Member] [money] NULL,
	[Price_Agent] [money] NULL,
	[Price_Wholesale1] [money] NULL,
	[Price_Wholesale2] [money] NULL,
	[Price_Wholesale3] [money] NULL,
	[Number_Wholesale1] [int] NULL,
	[Number_Wholesale2] [int] NULL,
	[Number_Wholesale3] [int] NULL,
	[IsValid] [bit] NULL,
 CONSTRAINT [PK_PE_ProductData] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'ProductID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属商品ID 对应GeneralID为实连接' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'ProductID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'TableName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'表名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'TableName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'PropertyValue'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'属性值：如：红色|加大码，用|分隔几个属性的组合查询' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'PropertyValue'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'Stocks'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'库存数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'Stocks'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'OrderNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订货数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'OrderNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'AlarmNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'库存报警下限' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'AlarmNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'BuyTimes'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'购买次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'BuyTimes'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'Price'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'零售价' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'Price'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'Price_Member'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员零售价' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'Price_Member'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'Price_Agent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'代理零售价' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'Price_Agent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'Price_Wholesale1'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'批发价1' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'Price_Wholesale1'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'Price_Wholesale2'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'批发价2' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'Price_Wholesale2'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'Price_Wholesale3'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'批发价3' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'Price_Wholesale3'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'Number_Wholesale1'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'一次性购买此商品数量1' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'Number_Wholesale1'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'Number_Wholesale2'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'一次性购买此商品数量2' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'Number_Wholesale2'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'Number_Wholesale3'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'一次性购买此商品数量3' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'Number_Wholesale3'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', N'COLUMN',N'IsValid'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否有效' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData', @level2type=N'COLUMN',@level2name=N'IsValid'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProductData', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'多属性商品数据表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProductData'
GO
/****** Object:  Table [dbo].[PE_Producer]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Producer]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Producer](
	[ProducerID] [int] NOT NULL,
	[ProducerType] [int] NOT NULL,
	[ProducerName] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProducerShortName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ProducerPhoto] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[BirthDay] [datetime] NULL,
	[Address] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Postcode] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[Phone] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Fax] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Homepage] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ProducerIntro] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[LastUseTime] [datetime] NULL,
	[Passed] [bit] NOT NULL,
	[onTop] [bit] NOT NULL,
	[IsElite] [bit] NOT NULL,
	[Hits] [int] NOT NULL,
 CONSTRAINT [PK_PE_Producer_ProducerID] PRIMARY KEY CLUSTERED 
(
	[ProducerID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Producer]') AND name = N'IX_PE_Producer_Postcode')
CREATE NONCLUSTERED INDEX [IX_PE_Producer_Postcode] ON [dbo].[PE_Producer] 
(
	[Postcode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'ProducerID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生产商ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'ProducerID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'ProducerType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生产商分类' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'ProducerType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'ProducerName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生产商' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'ProducerName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'ProducerShortName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生产商简称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'ProducerShortName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'ProducerPhoto'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生产商图片' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'ProducerPhoto'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'BirthDay'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创立日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'BirthDay'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'Address'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'Address'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'Postcode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮政编码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'Postcode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'Phone'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'电话' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'Phone'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'Fax'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'传真' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'Fax'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'Email'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'电子信箱' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'Email'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'Homepage'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主页' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'Homepage'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'ProducerIntro'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生产商简介' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'ProducerIntro'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'LastUseTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后修改时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'LastUseTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'Passed'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否通过' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'Passed'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'onTop'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'固顶' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'onTop'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'IsElite'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'推荐' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'IsElite'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'COLUMN',N'Hits'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'点击数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'COLUMN',@level2name=N'Hits'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'厂商表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Producer', N'INDEX',N'IX_PE_Producer_Postcode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Producer', @level2type=N'INDEX',@level2name=N'IX_PE_Producer_Postcode'
GO
/****** Object:  Table [dbo].[PE_ProcessStatusCode]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ProcessStatusCode]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ProcessStatusCode](
	[FlowID] [int] NOT NULL,
	[ProcessID] [int] NOT NULL,
	[StatusCode] [int] NOT NULL,
 CONSTRAINT [PK_PE_ProcessStatusCode] PRIMARY KEY CLUSTERED 
(
	[FlowID] ASC,
	[ProcessID] ASC,
	[StatusCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProcessStatusCode', N'COLUMN',N'FlowID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'流程ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProcessStatusCode', @level2type=N'COLUMN',@level2name=N'FlowID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProcessStatusCode', N'COLUMN',N'ProcessID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'步骤ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProcessStatusCode', @level2type=N'COLUMN',@level2name=N'ProcessID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProcessStatusCode', N'COLUMN',N'StatusCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProcessStatusCode', @level2type=N'COLUMN',@level2name=N'StatusCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ProcessStatusCode', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'步骤状态码表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ProcessStatusCode'
GO
/****** Object:  Table [dbo].[PE_Process_Roles]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Process_Roles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Process_Roles](
	[FlowID] [int] NOT NULL,
	[ProcessID] [int] NOT NULL,
	[RoleID] [int] NOT NULL,
 CONSTRAINT [PK_PE_Process_Roles] PRIMARY KEY CLUSTERED 
(
	[FlowID] ASC,
	[ProcessID] ASC,
	[RoleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Process_Roles', N'COLUMN',N'FlowID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'流程ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Process_Roles', @level2type=N'COLUMN',@level2name=N'FlowID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Process_Roles', N'COLUMN',N'ProcessID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'步骤ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Process_Roles', @level2type=N'COLUMN',@level2name=N'ProcessID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Process_Roles', N'COLUMN',N'RoleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Process_Roles', @level2type=N'COLUMN',@level2name=N'RoleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Process_Roles', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'步骤角色表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Process_Roles'
GO
/****** Object:  Table [dbo].[PE_PresentProject]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PresentProject]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_PresentProject](
	[ProjectID] [int] IDENTITY(1,1) NOT NULL,
	[ProjectName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[BeginDate] [datetime] NULL,
	[EndDate] [datetime] NULL,
	[MinMoney] [money] NULL,
	[MaxMoney] [money] NULL,
	[PresentContent] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Price] [money] NULL,
	[PresentID] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Cash] [money] NULL,
	[PresentExp] [int] NULL,
	[PresentPoint] [int] NULL,
	[Disabled] [bit] NOT NULL,
 CONSTRAINT [PK_PE_PresentProject_ProjectID] PRIMARY KEY CLUSTERED 
(
	[ProjectID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_PresentProject]') AND name = N'IX_PE_PresentProjectBeginDate')
CREATE NONCLUSTERED INDEX [IX_PE_PresentProjectBeginDate] ON [dbo].[PE_PresentProject] 
(
	[BeginDate] DESC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_PresentProject]') AND name = N'IX_PE_PresentProjectEndDate')
CREATE NONCLUSTERED INDEX [IX_PE_PresentProjectEndDate] ON [dbo].[PE_PresentProject] 
(
	[EndDate] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_PresentProject]') AND name = N'IX_PE_PresentProjectMaxMoney')
CREATE NONCLUSTERED INDEX [IX_PE_PresentProjectMaxMoney] ON [dbo].[PE_PresentProject] 
(
	[MaxMoney] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_PresentProject]') AND name = N'IX_PE_PresentProjectMinMoney')
CREATE NONCLUSTERED INDEX [IX_PE_PresentProjectMinMoney] ON [dbo].[PE_PresentProject] 
(
	[MinMoney] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PresentProject', N'COLUMN',N'ProjectID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'促销方案ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PresentProject', @level2type=N'COLUMN',@level2name=N'ProjectID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PresentProject', N'COLUMN',N'ProjectName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'方案名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PresentProject', @level2type=N'COLUMN',@level2name=N'ProjectName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PresentProject', N'COLUMN',N'BeginDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'有效期开启' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PresentProject', @level2type=N'COLUMN',@level2name=N'BeginDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PresentProject', N'COLUMN',N'EndDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'有效期结束' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PresentProject', @level2type=N'COLUMN',@level2name=N'EndDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PresentProject', N'COLUMN',N'MinMoney'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'价格区间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PresentProject', @level2type=N'COLUMN',@level2name=N'MinMoney'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PresentProject', N'COLUMN',N'MaxMoney'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'价格区间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PresentProject', @level2type=N'COLUMN',@level2name=N'MaxMoney'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PresentProject', N'COLUMN',N'PresentContent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'可以超值换购商品' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PresentProject', @level2type=N'COLUMN',@level2name=N'PresentContent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PresentProject', N'COLUMN',N'Price'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'可以超值换购商品' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PresentProject', @level2type=N'COLUMN',@level2name=N'Price'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PresentProject', N'COLUMN',N'PresentID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'促销品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PresentProject', @level2type=N'COLUMN',@level2name=N'PresentID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PresentProject', N'COLUMN',N'Cash'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'返还的现金券' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PresentProject', @level2type=N'COLUMN',@level2name=N'Cash'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PresentProject', N'COLUMN',N'PresentExp'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'可以得到的积分' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PresentProject', @level2type=N'COLUMN',@level2name=N'PresentExp'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PresentProject', N'COLUMN',N'PresentPoint'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'赠送点券' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PresentProject', @level2type=N'COLUMN',@level2name=N'PresentPoint'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PresentProject', N'COLUMN',N'Disabled'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否启用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PresentProject', @level2type=N'COLUMN',@level2name=N'Disabled'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PresentProject', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'促销方案表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PresentProject'
GO
/****** Object:  Table [dbo].[PE_Present]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Present]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Present](
	[PresentID] [int] NOT NULL,
	[PresentName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[PresentPic] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Unit] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[PresentNum] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ServiceTermUnit] [int] NULL,
	[ServiceTerm] [int] NULL,
	[Price] [money] NULL,
	[Price_Market] [money] NULL,
	[Weight] [float] NULL,
	[Stocks] [int] NULL,
	[StocksProject] [int] NULL,
	[OrderNum] [int] NULL,
	[AlarmNum] [int] NULL,
	[ProductCharacter] [int] NULL,
	[DownloadUrl] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[PresentThumb] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[PresentIntro] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[PresentExplain] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[NeedCredits] [int] NULL,
	[PresentType] [int] NULL,
	[CreditProductProperty] [int] NULL,
	[InputTime] [datetime] NULL,
	[BuyTimes] [int] NULL,
	[EnableSale] [bit] NULL,
 CONSTRAINT [PK_PE_Present] PRIMARY KEY CLUSTERED 
(
	[PresentID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'PresentID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'礼品编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'PresentID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'PresentName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'礼品名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'PresentName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'PresentPic'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'礼品图片' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'PresentPic'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'Unit'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'礼品单位' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'Unit'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'PresentNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'礼品数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'PresentNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'ServiceTermUnit'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单位' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'ServiceTermUnit'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'ServiceTerm'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务期限' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'ServiceTerm'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'Price'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'价格' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'Price'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'Price_Market'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'市场价' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'Price_Market'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'Weight'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'重量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'Weight'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'Stocks'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'库存' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'Stocks'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'StocksProject'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'库存计算方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'StocksProject'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'OrderNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订购数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'OrderNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'AlarmNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'警报数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'AlarmNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'ProductCharacter'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'礼品类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'ProductCharacter'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'DownloadUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'下载地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'DownloadUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'下载说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'PresentThumb'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'缩略图' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'PresentThumb'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'PresentIntro'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'简单介绍' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'PresentIntro'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'PresentExplain'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'详细介绍' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'PresentExplain'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'NeedCredits'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'换购积分' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'NeedCredits'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'PresentType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'礼品类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'PresentType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'CreditProductProperty'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'积分商品属性' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'CreditProductProperty'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'InputTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'InputTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'BuyTimes'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'购买次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'BuyTimes'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', N'COLUMN',N'EnableSale'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否可销售，1是0否' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present', @level2type=N'COLUMN',@level2name=N'EnableSale'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Present', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'礼品表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Present'
GO
/****** Object:  Table [dbo].[PE_PointLog]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PointLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_PointLog](
	[LogID] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[ModuleType] [int] NULL,
	[InfoID] [int] NULL,
	[Point] [int] NULL,
	[LogTime] [datetime] NULL,
	[Times] [int] NULL,
	[IncomePayOut] [int] NULL,
	[Remark] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IP] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Inputer] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Memo] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IsConsume] [bit] NULL,
 CONSTRAINT [PK_PE_PointLog_LogID] PRIMARY KEY CLUSTERED 
(
	[LogID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PointLog', N'COLUMN',N'LogID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'消费点券记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PointLog', @level2type=N'COLUMN',@level2name=N'LogID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PointLog', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PointLog', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PointLog', N'COLUMN',N'ModuleType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息所属功能模块' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PointLog', @level2type=N'COLUMN',@level2name=N'ModuleType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PointLog', N'COLUMN',N'InfoID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PointLog', @level2type=N'COLUMN',@level2name=N'InfoID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PointLog', N'COLUMN',N'Point'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'点数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PointLog', @level2type=N'COLUMN',@level2name=N'Point'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PointLog', N'COLUMN',N'LogTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'消费时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PointLog', @level2type=N'COLUMN',@level2name=N'LogTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PointLog', N'COLUMN',N'Times'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PointLog', @level2type=N'COLUMN',@level2name=N'Times'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PointLog', N'COLUMN',N'IncomePayOut'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'消费明细类型  1--收入  2--支出' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PointLog', @level2type=N'COLUMN',@level2name=N'IncomePayOut'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PointLog', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注/说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PointLog', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PointLog', N'COLUMN',N'IP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PointLog', @level2type=N'COLUMN',@level2name=N'IP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PointLog', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PointLog', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PointLog', N'COLUMN',N'Memo'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内部记录' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PointLog', @level2type=N'COLUMN',@level2name=N'Memo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PointLog', N'COLUMN',N'IsConsume'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否消费' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PointLog', @level2type=N'COLUMN',@level2name=N'IsConsume'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PointLog', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'消费明细表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PointLog'
GO
/****** Object:  Table [dbo].[PE_PM_UserAccount]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PM_UserAccount]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_PM_UserAccount](
	[ID] [int] NOT NULL,
	[HolderName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Bank] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Account] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[OpeningBank] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[CardNum] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_UserAccount] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_UserAccount', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_UserAccount', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_UserAccount', N'COLUMN',N'HolderName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'开户人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_UserAccount', @level2type=N'COLUMN',@level2name=N'HolderName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_UserAccount', N'COLUMN',N'Bank'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'开户银行' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_UserAccount', @level2type=N'COLUMN',@level2name=N'Bank'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_UserAccount', N'COLUMN',N'Account'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'银行帐号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_UserAccount', @level2type=N'COLUMN',@level2name=N'Account'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_UserAccount', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_UserAccount', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_UserAccount', N'COLUMN',N'OpeningBank'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'开户银行' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_UserAccount', @level2type=N'COLUMN',@level2name=N'OpeningBank'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_UserAccount', N'COLUMN',N'CardNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'卡号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_UserAccount', @level2type=N'COLUMN',@level2name=N'CardNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_UserAccount', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'推广用户帐户表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_UserAccount'
GO
/****** Object:  Table [dbo].[PE_PM_RegisterPromotion]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PM_RegisterPromotion]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_PM_RegisterPromotion](
	[ID] [int] NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[RegisterUserName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[RegisterIP] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[RegisterTime] [datetime] NOT NULL,
	[Commission] [money] NOT NULL,
	[State] [int] NOT NULL,
	[GatheringID] [int] NOT NULL,
 CONSTRAINT [PK_PE_PM_RegisterPromotion] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_RegisterPromotion', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_RegisterPromotion', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_RegisterPromotion', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'推广人用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_RegisterPromotion', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_RegisterPromotion', N'COLUMN',N'RegisterUserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'注册会员名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_RegisterPromotion', @level2type=N'COLUMN',@level2name=N'RegisterUserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_RegisterPromotion', N'COLUMN',N'RegisterIP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'注册IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_RegisterPromotion', @level2type=N'COLUMN',@level2name=N'RegisterIP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_RegisterPromotion', N'COLUMN',N'RegisterTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'注册时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_RegisterPromotion', @level2type=N'COLUMN',@level2name=N'RegisterTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_RegisterPromotion', N'COLUMN',N'Commission'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'佣金' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_RegisterPromotion', @level2type=N'COLUMN',@level2name=N'Commission'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_RegisterPromotion', N'COLUMN',N'State'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'推广状态，0：未审核；1：通过审核' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_RegisterPromotion', @level2type=N'COLUMN',@level2name=N'State'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_RegisterPromotion', N'COLUMN',N'GatheringID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'提现ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_RegisterPromotion', @level2type=N'COLUMN',@level2name=N'GatheringID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_RegisterPromotion', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员注册推广表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_RegisterPromotion'
GO
/****** Object:  Table [dbo].[PE_PM_PromotionOrder]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PM_PromotionOrder]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_PM_PromotionOrder](
	[ID] [int] NOT NULL,
	[OrderID] [int] NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK_PE_PM_PromotionOrder] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_PromotionOrder', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_PromotionOrder', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_PromotionOrder', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_PromotionOrder', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_PromotionOrder', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_PromotionOrder', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_PromotionOrder', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'推广订单表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_PromotionOrder'
GO
/****** Object:  Table [dbo].[PE_PM_Promotion]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PM_Promotion]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_PM_Promotion](
	[ID] [int] NOT NULL,
	[ProductID] [int] NOT NULL,
	[CommissionType] [int] NULL,
	[Rate] [money] NOT NULL,
 CONSTRAINT [PK_PE_PM_Promotion] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_Promotion', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'推广商品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_Promotion', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_Promotion', N'COLUMN',N'ProductID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_Promotion', @level2type=N'COLUMN',@level2name=N'ProductID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_Promotion', N'COLUMN',N'CommissionType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'佣金类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_Promotion', @level2type=N'COLUMN',@level2name=N'CommissionType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_Promotion', N'COLUMN',N'Rate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'佣金比率' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_Promotion', @level2type=N'COLUMN',@level2name=N'Rate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_Promotion', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'推广商品表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_Promotion'
GO
/****** Object:  Table [dbo].[PE_PM_GatheringDetail]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PM_GatheringDetail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_PM_GatheringDetail](
	[ID] [int] NOT NULL,
	[Amount] [money] NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[CreateTime] [datetime] NOT NULL,
	[Remark] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[State] [int] NOT NULL,
	[RealityAmount] [money] NULL,
	[ProcessingTime] [datetime] NULL,
	[ApprovalHuman] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Sender] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[RemittancesTime] [datetime] NULL,
 CONSTRAINT [PK_PE_PM_GatheringDetail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_GatheringDetail', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'申请提现ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_GatheringDetail', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_GatheringDetail', N'COLUMN',N'Amount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'申请金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_GatheringDetail', @level2type=N'COLUMN',@level2name=N'Amount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_GatheringDetail', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_GatheringDetail', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_GatheringDetail', N'COLUMN',N'CreateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'申请时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_GatheringDetail', @level2type=N'COLUMN',@level2name=N'CreateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_GatheringDetail', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_GatheringDetail', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_GatheringDetail', N'COLUMN',N'State'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态（-1  已拒绝 ;0  待审批; 1  已审批待支付 ;2 已支付 ）' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_GatheringDetail', @level2type=N'COLUMN',@level2name=N'State'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_GatheringDetail', N'COLUMN',N'RealityAmount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'实际支付金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_GatheringDetail', @level2type=N'COLUMN',@level2name=N'RealityAmount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_GatheringDetail', N'COLUMN',N'ProcessingTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'审批时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_GatheringDetail', @level2type=N'COLUMN',@level2name=N'ProcessingTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_GatheringDetail', N'COLUMN',N'ApprovalHuman'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'审批人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_GatheringDetail', @level2type=N'COLUMN',@level2name=N'ApprovalHuman'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_GatheringDetail', N'COLUMN',N'Sender'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'汇款人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_GatheringDetail', @level2type=N'COLUMN',@level2name=N'Sender'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_GatheringDetail', N'COLUMN',N'RemittancesTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'汇款时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_GatheringDetail', @level2type=N'COLUMN',@level2name=N'RemittancesTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_GatheringDetail', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'推广提现表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_GatheringDetail'
GO
/****** Object:  Table [dbo].[PE_PM_CommissionDetail]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PM_CommissionDetail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_PM_CommissionDetail](
	[ID] [int] NOT NULL,
	[OrderID] [int] NOT NULL,
	[ProductID] [int] NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Commission] [money] NOT NULL,
	[CreateTime] [datetime] NOT NULL,
	[GatheringID] [int] NOT NULL,
	[Amount] [int] NOT NULL,
	[CommissionType] [int] NULL,
	[Rate] [money] NULL,
	[Property] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_PM_CommissionDetail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_CommissionDetail', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'佣金ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_CommissionDetail', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_CommissionDetail', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_CommissionDetail', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_CommissionDetail', N'COLUMN',N'ProductID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_CommissionDetail', @level2type=N'COLUMN',@level2name=N'ProductID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_CommissionDetail', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_CommissionDetail', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_CommissionDetail', N'COLUMN',N'Commission'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'佣金' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_CommissionDetail', @level2type=N'COLUMN',@level2name=N'Commission'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_CommissionDetail', N'COLUMN',N'CreateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_CommissionDetail', @level2type=N'COLUMN',@level2name=N'CreateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_CommissionDetail', N'COLUMN',N'GatheringID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'提现ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_CommissionDetail', @level2type=N'COLUMN',@level2name=N'GatheringID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_CommissionDetail', N'COLUMN',N'Amount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_CommissionDetail', @level2type=N'COLUMN',@level2name=N'Amount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_CommissionDetail', N'COLUMN',N'CommissionType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'佣金类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_CommissionDetail', @level2type=N'COLUMN',@level2name=N'CommissionType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_CommissionDetail', N'COLUMN',N'Rate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'佣金比率' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_CommissionDetail', @level2type=N'COLUMN',@level2name=N'Rate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_CommissionDetail', N'COLUMN',N'Property'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'属性，如果是单一商品这属性为空' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_CommissionDetail', @level2type=N'COLUMN',@level2name=N'Property'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PM_CommissionDetail', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'推广佣金明细表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PM_CommissionDetail'
GO
/****** Object:  Table [dbo].[PE_PC_PreConsultationReply]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PC_PreConsultationReply]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_PC_PreConsultationReply](
	[ID] [int] NULL,
	[ConsultationID] [int] NULL,
	[ReplyContent] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL,
	[ReplyDateTime] [datetime] NULL,
	[Replyer] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [int] NULL
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultationReply', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回复Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultationReply', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultationReply', N'COLUMN',N'ConsultationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'售前咨询Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultationReply', @level2type=N'COLUMN',@level2name=N'ConsultationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultationReply', N'COLUMN',N'ReplyContent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回复内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultationReply', @level2type=N'COLUMN',@level2name=N'ReplyContent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultationReply', N'COLUMN',N'ReplyDateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回复时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultationReply', @level2type=N'COLUMN',@level2name=N'ReplyDateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultationReply', N'COLUMN',N'Replyer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回复者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultationReply', @level2type=N'COLUMN',@level2name=N'Replyer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultationReply', N'COLUMN',N'ProductID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultationReply', @level2type=N'COLUMN',@level2name=N'ProductID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultationReply', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'售前咨询回复' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultationReply'
GO
/****** Object:  Table [dbo].[PE_PC_PreConsultation]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PC_PreConsultation]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_PC_PreConsultation](
	[ID] [int] NULL,
	[ConsultContent] [nvarchar](1000) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductId] [int] NULL,
	[CategoryId] [int] NULL,
	[UserName] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
	[InputDateTime] [datetime] NULL,
	[AuditStatus] [bit] NULL,
	[ReplyStatus] [bit] NULL
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultation', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultation', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultation', N'COLUMN',N'ConsultContent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'咨询内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultation', @level2type=N'COLUMN',@level2name=N'ConsultContent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultation', N'COLUMN',N'ProductId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultation', @level2type=N'COLUMN',@level2name=N'ProductId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultation', N'COLUMN',N'CategoryId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分类Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultation', @level2type=N'COLUMN',@level2name=N'CategoryId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultation', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultation', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultation', N'COLUMN',N'InputDateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'提交日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultation', @level2type=N'COLUMN',@level2name=N'InputDateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultation', N'COLUMN',N'AuditStatus'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'审核状态:0未审核,1已审核' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultation', @level2type=N'COLUMN',@level2name=N'AuditStatus'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultation', N'COLUMN',N'ReplyStatus'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回复状态:0未回复,1已回复' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultation', @level2type=N'COLUMN',@level2name=N'ReplyStatus'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PC_PreConsultation', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'售前咨询' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PC_PreConsultation'
GO
/****** Object:  Table [dbo].[PE_PayPlatForm]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PayPlatForm]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_PayPlatForm](
	[PayPlatformID] [int] NOT NULL,
	[PayPlatformName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[AccountsID] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[MD5] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Rate] [float] NULL,
	[OrderID] [int] NULL,
	[IsDisabled] [bit] NOT NULL,
	[IsDefault] [bit] NULL,
	[PayPlatformIcon] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_PayPlatForm_PayPlatformID] PRIMARY KEY CLUSTERED 
(
	[PayPlatformID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PayPlatForm', N'COLUMN',N'PayPlatformID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'平台ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PayPlatForm', @level2type=N'COLUMN',@level2name=N'PayPlatformID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PayPlatForm', N'COLUMN',N'PayPlatformName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'平台名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PayPlatForm', @level2type=N'COLUMN',@level2name=N'PayPlatformName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PayPlatForm', N'COLUMN',N'AccountsID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'帐号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PayPlatForm', @level2type=N'COLUMN',@level2name=N'AccountsID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PayPlatForm', N'COLUMN',N'MD5'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'MD5密钥' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PayPlatForm', @level2type=N'COLUMN',@level2name=N'MD5'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PayPlatForm', N'COLUMN',N'Rate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'手续费' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PayPlatForm', @level2type=N'COLUMN',@level2name=N'Rate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PayPlatForm', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PayPlatForm', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PayPlatForm', N'COLUMN',N'IsDisabled'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否启用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PayPlatForm', @level2type=N'COLUMN',@level2name=N'IsDisabled'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PayPlatForm', N'COLUMN',N'IsDefault'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否默认' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PayPlatForm', @level2type=N'COLUMN',@level2name=N'IsDefault'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PayPlatForm', N'COLUMN',N'PayPlatformIcon'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'支付平台图标' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PayPlatForm', @level2type=N'COLUMN',@level2name=N'PayPlatformIcon'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PayPlatForm', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PayPlatForm', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PayPlatForm', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'支付平台表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PayPlatForm'
GO
/****** Object:  Table [dbo].[PE_PaymentType]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PaymentType]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_PaymentType](
	[TypeID] [int] NOT NULL,
	[TypeName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Intro] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Discount] [float] NULL,
	[OrderID] [int] NULL,
	[IsDefault] [bit] NOT NULL,
	[IsDisabled] [bit] NOT NULL,
	[Category] [int] NULL,
 CONSTRAINT [PK_PE_PaymentType_TypeID] PRIMARY KEY CLUSTERED 
(
	[TypeID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_PaymentType]') AND name = N'IX_PE_PaymentType_OrderID')
CREATE NONCLUSTERED INDEX [IX_PE_PaymentType_OrderID] ON [dbo].[PE_PaymentType] 
(
	[OrderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentType', N'COLUMN',N'TypeID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'付款方式ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentType', @level2type=N'COLUMN',@level2name=N'TypeID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentType', N'COLUMN',N'TypeName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'付款方式名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentType', @level2type=N'COLUMN',@level2name=N'TypeName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentType', N'COLUMN',N'Intro'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'付款方式简介' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentType', @level2type=N'COLUMN',@level2name=N'Intro'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentType', N'COLUMN',N'Discount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'折扣率' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentType', @level2type=N'COLUMN',@level2name=N'Discount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentType', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentType', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentType', N'COLUMN',N'IsDefault'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否默认' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentType', @level2type=N'COLUMN',@level2name=N'IsDefault'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentType', N'COLUMN',N'IsDisabled'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否禁用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentType', @level2type=N'COLUMN',@level2name=N'IsDisabled'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentType', N'COLUMN',N'Category'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'付款方式类别 0 其它 、1 在线支付 、2 余额支付' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentType', @level2type=N'COLUMN',@level2name=N'Category'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentType', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'支付方式表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentType'
GO
/****** Object:  Table [dbo].[PE_PaymentLog]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_PaymentLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_PaymentLog](
	[PaymentLogID] [int] NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[OrderID] [int] NULL,
	[PaymentNum] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[PlatformID] [int] NULL,
	[MoneyPay] [money] NULL,
	[MoneyTrue] [money] NULL,
	[PayTime] [datetime] NULL,
	[SuccessTime] [datetime] NULL,
	[Status] [int] NULL,
	[PlatformInfo] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Point] [int] NULL,
	[TradeNum] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_PaymentLog_PaymentLogID] PRIMARY KEY CLUSTERED 
(
	[PaymentLogID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_PaymentLog]') AND name = N'IX_PE_PaymentLog_MoneyPay')
CREATE NONCLUSTERED INDEX [IX_PE_PaymentLog_MoneyPay] ON [dbo].[PE_PaymentLog] 
(
	[MoneyPay] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_PaymentLog]') AND name = N'IX_PE_PaymentLog_OrderID')
CREATE NONCLUSTERED INDEX [IX_PE_PaymentLog_OrderID] ON [dbo].[PE_PaymentLog] 
(
	[OrderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_PaymentLog]') AND name = N'IX_PE_PaymentLog_PaymentNum')
CREATE NONCLUSTERED INDEX [IX_PE_PaymentLog_PaymentNum] ON [dbo].[PE_PaymentLog] 
(
	[PaymentNum] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_PaymentLog]') AND name = N'IX_PE_PaymentLog_PlatformID')
CREATE NONCLUSTERED INDEX [IX_PE_PaymentLog_PlatformID] ON [dbo].[PE_PaymentLog] 
(
	[PlatformID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_PaymentLog]') AND name = N'IX_PE_PaymentLog_UserName')
CREATE NONCLUSTERED INDEX [IX_PE_PaymentLog_UserName] ON [dbo].[PE_PaymentLog] 
(
	[UserName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', N'COLUMN',N'PaymentLogID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'支付ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog', @level2type=N'COLUMN',@level2name=N'PaymentLogID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', N'COLUMN',N'PaymentNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'支付序号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog', @level2type=N'COLUMN',@level2name=N'PaymentNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', N'COLUMN',N'PlatformID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'支付平台' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog', @level2type=N'COLUMN',@level2name=N'PlatformID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', N'COLUMN',N'MoneyPay'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'支付金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog', @level2type=N'COLUMN',@level2name=N'MoneyPay'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', N'COLUMN',N'MoneyTrue'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'实际支付金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog', @level2type=N'COLUMN',@level2name=N'MoneyTrue'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', N'COLUMN',N'PayTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'交易时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog', @level2type=N'COLUMN',@level2name=N'PayTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', N'COLUMN',N'SuccessTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'交易成功时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog', @level2type=N'COLUMN',@level2name=N'SuccessTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'支付状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', N'COLUMN',N'PlatformInfo'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'银行信息' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog', @level2type=N'COLUMN',@level2name=N'PlatformInfo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', N'COLUMN',N'Point'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'购买点券数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog', @level2type=N'COLUMN',@level2name=N'Point'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', N'COLUMN',N'TradeNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'支付宝交易号,针对支付宝担保交易返回的交易号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog', @level2type=N'COLUMN',@level2name=N'TradeNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_PaymentLog', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'在线支付记录表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_PaymentLog'
GO
/****** Object:  Table [dbo].[PE_Package]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Package]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Package](
	[PackageID] [int] IDENTITY(1,1) NOT NULL,
	[PackageName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PackageWeight] [float] NULL,
	[GoodsWeightMin] [float] NULL,
	[GoodsWeightMax] [float] NULL,
 CONSTRAINT [PK_PE_Package_PackageID] PRIMARY KEY CLUSTERED 
(
	[PackageID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Package', N'COLUMN',N'PackageID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'包装ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Package', @level2type=N'COLUMN',@level2name=N'PackageID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Package', N'COLUMN',N'PackageName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'包装名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Package', @level2type=N'COLUMN',@level2name=N'PackageName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Package', N'COLUMN',N'PackageWeight'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'包装重量(kg)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Package', @level2type=N'COLUMN',@level2name=N'PackageWeight'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Package', N'COLUMN',N'GoodsWeightMin'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'货物重量上限' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Package', @level2type=N'COLUMN',@level2name=N'GoodsWeightMin'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Package', N'COLUMN',N'GoodsWeightMax'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'货物重量下限' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Package', @level2type=N'COLUMN',@level2name=N'GoodsWeightMax'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Package', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'包装表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Package'
GO
/****** Object:  Table [dbo].[PE_OutOfStockLog]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_OutOfStockLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_OutOfStockLog](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Email] [nvarchar](64) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[UserId] [int] NOT NULL,
	[Mobile] [nvarchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductId] [int] NOT NULL,
	[OrderNum] [int] NULL,
	[InputTime] [datetime] NOT NULL,
	[IP] [nvarchar](64) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[EmailStatus] [int] NOT NULL,
	[MobileStatus] [int] NOT NULL,
	[Property] [nvarchar](64) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_OutOfStockLog_ID] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OutOfStockLog', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OutOfStockLog', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OutOfStockLog', N'COLUMN',N'Email'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Email地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OutOfStockLog', @level2type=N'COLUMN',@level2name=N'Email'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OutOfStockLog', N'COLUMN',N'UserId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OutOfStockLog', @level2type=N'COLUMN',@level2name=N'UserId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OutOfStockLog', N'COLUMN',N'Mobile'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'手机' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OutOfStockLog', @level2type=N'COLUMN',@level2name=N'Mobile'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OutOfStockLog', N'COLUMN',N'ProductId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'产品编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OutOfStockLog', @level2type=N'COLUMN',@level2name=N'ProductId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OutOfStockLog', N'COLUMN',N'OrderNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订购数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OutOfStockLog', @level2type=N'COLUMN',@level2name=N'OrderNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OutOfStockLog', N'COLUMN',N'InputTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'登记时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OutOfStockLog', @level2type=N'COLUMN',@level2name=N'InputTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OutOfStockLog', N'COLUMN',N'IP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OutOfStockLog', @level2type=N'COLUMN',@level2name=N'IP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OutOfStockLog', N'COLUMN',N'EmailStatus'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮件发送状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OutOfStockLog', @level2type=N'COLUMN',@level2name=N'EmailStatus'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OutOfStockLog', N'COLUMN',N'MobileStatus'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信发送状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OutOfStockLog', @level2type=N'COLUMN',@level2name=N'MobileStatus'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OutOfStockLog', N'COLUMN',N'Property'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'规格' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OutOfStockLog', @level2type=N'COLUMN',@level2name=N'Property'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OutOfStockLog', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'缺货登记' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OutOfStockLog'
GO
/****** Object:  Table [dbo].[PE_Orders]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Orders]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Orders](
	[OrderID] [int] NOT NULL,
	[OrderNum] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[AgentName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Functionary] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ClientID] [int] NULL,
	[MoneyTotal] [money] NULL,
	[MoneyGoods] [money] NULL,
	[NeedInvoice] [bit] NOT NULL,
	[InvoiceContent] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Invoiced] [bit] NOT NULL,
	[MoneyReceipt] [money] NULL,
	[BeginDate] [datetime] NULL,
	[InputTime] [datetime] NULL,
	[ContacterName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Address] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ZipCode] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[Mobile] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Phone] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[PaymentType] [int] NULL,
	[DeliverType] [int] NULL,
	[Status] [int] NULL,
	[DeliverStatus] [int] NULL,
	[EnableDownload] [bit] NOT NULL,
	[PresentMoney] [money] NULL,
	[PresentPoint] [int] NULL,
	[PresentExp] [int] NULL,
	[Discount_Payment] [float] NULL,
	[Charge_Deliver] [money] NULL,
	[Memo] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[OrderType] [int] NULL,
	[CouponID] [int] NULL,
	[PrintState] [bit] NULL,
	[PrintTime] [datetime] NULL,
	[OrderKind] [int] NULL,
	[ExpressPrintTime] [datetime] NULL,
	[IsExpressPrinted] [bit] NULL,
	[GroupBuyID] [int] NULL,
	[IsNotice] [bit] NULL,
	[SecondsKillID] [int] NULL,
 CONSTRAINT [PK_PE_Orders_OrderID] PRIMARY KEY CLUSTERED 
(
	[OrderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Orders]') AND name = N'IX_PE_Orders_AgentName')
CREATE NONCLUSTERED INDEX [IX_PE_Orders_AgentName] ON [dbo].[PE_Orders] 
(
	[AgentName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Orders]') AND name = N'IX_PE_Orders_ClientID')
CREATE NONCLUSTERED INDEX [IX_PE_Orders_ClientID] ON [dbo].[PE_Orders] 
(
	[ClientID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Orders]') AND name = N'IX_PE_Orders_OrderNum')
CREATE NONCLUSTERED INDEX [IX_PE_Orders_OrderNum] ON [dbo].[PE_Orders] 
(
	[OrderNum] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Orders]') AND name = N'IX_PE_Orders_UserName')
CREATE NONCLUSTERED INDEX [IX_PE_Orders_UserName] ON [dbo].[PE_Orders] 
(
	[UserName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Orders]') AND name = N'IX_PE_Orders_ZipCode')
CREATE NONCLUSTERED INDEX [IX_PE_Orders_ZipCode] ON [dbo].[PE_Orders] 
(
	[ZipCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'OrderNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'OrderNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'AgentName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'代理商名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'AgentName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'Functionary'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'跟单员' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'Functionary'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'ClientID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'ClientID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'MoneyTotal'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单总金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'MoneyTotal'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'MoneyGoods'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'购买商品合计金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'MoneyGoods'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'NeedInvoice'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否需要开发票' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'NeedInvoice'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'InvoiceContent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发表内容，包括抬头、商品名称、金额等' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'InvoiceContent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'Invoiced'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否已开发票' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'Invoiced'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'MoneyReceipt'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'已收款' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'MoneyReceipt'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'BeginDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'开始服务日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'BeginDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'InputTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'InputTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'ContacterName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'受货人姓名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'ContacterName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'Address'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'收货人地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'Address'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'ZipCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮编' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'ZipCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'Mobile'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'手机' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'Mobile'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'Phone'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'联系电话' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'Phone'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'Email'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Email' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'Email'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'PaymentType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'付款方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'PaymentType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'DeliverType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'送货方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'DeliverType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'DeliverStatus'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'物流状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'DeliverStatus'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'EnableDownload'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否开通下载' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'EnableDownload'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'PresentMoney'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'返还的现金券' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'PresentMoney'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'PresentPoint'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'赠送点券' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'PresentPoint'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'PresentExp'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'得到的积分' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'PresentExp'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'Discount_Payment'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'付款方式的折扣' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'Discount_Payment'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'Charge_Deliver'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'运费' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'Charge_Deliver'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'Memo'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内部记录' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'Memo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'OrderType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'OrderType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'CouponID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠券' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'CouponID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'PrintState'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单发货单打印状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'PrintState'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'PrintTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发货单打印时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'PrintTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'OrderKind'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'OrderKind'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'ExpressPrintTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单快递单打印时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'ExpressPrintTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'IsExpressPrinted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单快递单是否已打印' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'IsExpressPrinted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'GroupBuyID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'团购ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'GroupBuyID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'IsNotice'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否已通知团购' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'IsNotice'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', N'COLUMN',N'SecondsKillID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'秒杀ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders', @level2type=N'COLUMN',@level2name=N'SecondsKillID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Orders', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Orders'
GO
/****** Object:  Table [dbo].[PE_OrderItem]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_OrderItem](
	[ItemID] [int] NOT NULL,
	[OrderID] [int] NULL,
	[ProductID] [int] NULL,
	[TableName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Property] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[SaleType] [int] NULL,
	[Price_Market] [money] NULL,
	[Price] [money] NULL,
	[TruePrice] [money] NULL,
	[Amount] [int] NULL,
	[SubTotal] [money] NULL,
	[BeginDate] [datetime] NULL,
	[ServiceTerm] [int] NULL,
	[ServiceTermUnit] [int] NULL,
	[Remark] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[PresentMoney] [money] NULL,
	[PresentPoint] [int] NULL,
	[PresentExp] [int] NULL,
	[ProductCharacter] [int] NULL,
	[ProductName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Unit] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[Weight] [float] NULL,
	[TrueAmount] [int] NULL,
	[TrueSubTotal] [money] NULL,
	[Status] [int] NULL,
	[GroupBuyID] [int] NULL,
	[SecondsKillID] [int] NULL,
 CONSTRAINT [PK_PE_OrderItem_ItemID] PRIMARY KEY CLUSTERED 
(
	[ItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]') AND name = N'IX_PE_OrderItem_OrderID')
CREATE NONCLUSTERED INDEX [IX_PE_OrderItem_OrderID] ON [dbo].[PE_OrderItem] 
(
	[OrderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]') AND name = N'IX_PE_OrderItem_ProductID')
CREATE NONCLUSTERED INDEX [IX_PE_OrderItem_ProductID] ON [dbo].[PE_OrderItem] 
(
	[ProductID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'ProductID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'产品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'ProductID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'TableName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'表名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'TableName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'Property'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'属性，如果是单一商品这属性为空' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'Property'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'SaleType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'销售类型  1--正常销售  2--换购  3--赠送  4--批发 5--体验价格' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'SaleType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'Price_Market'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'原价' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'Price_Market'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'Price'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'系统计算出的销售价' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'Price'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'TruePrice'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'实际销售价' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'TruePrice'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'Amount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订购数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'Amount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'SubTotal'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订购金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'SubTotal'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'BeginDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'开始计算服务期限日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'BeginDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'ServiceTerm'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务期限' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'ServiceTerm'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'ServiceTermUnit'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务年限单位　0－年，1－月，2－日' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'ServiceTermUnit'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'PresentMoney'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'返还的现金券' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'PresentMoney'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'PresentPoint'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'赠送点券' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'PresentPoint'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'PresentExp'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'赠送的积分' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'PresentExp'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'ProductCharacter'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品性质' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'ProductCharacter'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'ProductName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'ProductName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'Unit'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单位' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'Unit'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'Weight'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'重量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'Weight'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'TrueAmount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'实际销售量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'TrueAmount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'TrueSubTotal'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'实际销售金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'TrueSubTotal'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'GroupBuyID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'团购ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'GroupBuyID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', N'COLUMN',N'SecondsKillID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'秒杀ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem', @level2type=N'COLUMN',@level2name=N'SecondsKillID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单明细表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderItem'
GO
/****** Object:  Table [dbo].[PE_OrderHistoryItem]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_OrderHistoryItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_OrderHistoryItem](
	[ItemID] [int] NOT NULL,
	[OrderHistoryID] [int] NOT NULL,
	[FieldName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[OldValue] [nvarchar](4000) COLLATE Chinese_PRC_CI_AS NULL,
	[NewValue] [nvarchar](4000) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_OrderHistoryItem] PRIMARY KEY CLUSTERED 
(
	[ItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_OrderHistoryItem]') AND name = N'IX_PE_OrderHistoryItem_OrderHistoryID')
CREATE NONCLUSTERED INDEX [IX_PE_OrderHistoryItem_OrderHistoryID] ON [dbo].[PE_OrderHistoryItem] 
(
	[OrderHistoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderHistoryItem', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'历史记录明细ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderHistoryItem', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderHistoryItem', N'COLUMN',N'OrderHistoryID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单历史记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderHistoryItem', @level2type=N'COLUMN',@level2name=N'OrderHistoryID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderHistoryItem', N'COLUMN',N'FieldName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderHistoryItem', @level2type=N'COLUMN',@level2name=N'FieldName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderHistoryItem', N'COLUMN',N'OldValue'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'旧值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderHistoryItem', @level2type=N'COLUMN',@level2name=N'OldValue'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderHistoryItem', N'COLUMN',N'NewValue'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'新值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderHistoryItem', @level2type=N'COLUMN',@level2name=N'NewValue'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderHistoryItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单历史记录详情表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderHistoryItem'
GO
/****** Object:  Table [dbo].[PE_OrderHistory]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_OrderHistory]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_OrderHistory](
	[OrderHistoryID] [int] NOT NULL,
	[OrderNum] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[ActionName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ActionTime] [datetime] NULL,
	[UserIP] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_OrderHistory] PRIMARY KEY CLUSTERED 
(
	[OrderHistoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderHistory', N'COLUMN',N'OrderHistoryID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单记录编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderHistory', @level2type=N'COLUMN',@level2name=N'OrderHistoryID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderHistory', N'COLUMN',N'OrderNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderHistory', @level2type=N'COLUMN',@level2name=N'OrderNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderHistory', N'COLUMN',N'ActionName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderHistory', @level2type=N'COLUMN',@level2name=N'ActionName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderHistory', N'COLUMN',N'ActionTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderHistory', @level2type=N'COLUMN',@level2name=N'ActionTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderHistory', N'COLUMN',N'UserIP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderHistory', @level2type=N'COLUMN',@level2name=N'UserIP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderHistory', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作员名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderHistory', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderHistory', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderHistory', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderHistory', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单历史记录表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderHistory'
GO
/****** Object:  Table [dbo].[PE_OrderFeedback]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_OrderFeedback]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_OrderFeedback](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[OrderID] [int] NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[WriteTime] [datetime] NULL,
	[ReplyName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ReplyContent] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[ReplyTime] [datetime] NULL,
 CONSTRAINT [PK_PE_OrderFeedback] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderFeedback', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderFeedback', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderFeedback', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderFeedback', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderFeedback', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderFeedback', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderFeedback', N'COLUMN',N'Content'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderFeedback', @level2type=N'COLUMN',@level2name=N'Content'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderFeedback', N'COLUMN',N'WriteTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'添加反馈时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderFeedback', @level2type=N'COLUMN',@level2name=N'WriteTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderFeedback', N'COLUMN',N'ReplyName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回复管理 员' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderFeedback', @level2type=N'COLUMN',@level2name=N'ReplyName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderFeedback', N'COLUMN',N'ReplyContent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回复内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderFeedback', @level2type=N'COLUMN',@level2name=N'ReplyContent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderFeedback', N'COLUMN',N'ReplyTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回复时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderFeedback', @level2type=N'COLUMN',@level2name=N'ReplyTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_OrderFeedback', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单反馈表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_OrderFeedback'
GO
/****** Object:  Table [dbo].[PE_Nodes_Template]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Nodes_Template]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Nodes_Template](
	[NodeID] [int] NOT NULL,
	[TemplateID] [int] NOT NULL,
	[IsDefault] [bit] NULL,
 CONSTRAINT [PK_PE_Nodes_Template] PRIMARY KEY CLUSTERED 
(
	[NodeID] ASC,
	[TemplateID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes_Template', N'COLUMN',N'NodeID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes_Template', @level2type=N'COLUMN',@level2name=N'NodeID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes_Template', N'COLUMN',N'TemplateID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列表模板ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes_Template', @level2type=N'COLUMN',@level2name=N'TemplateID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes_Template', N'COLUMN',N'IsDefault'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否默认' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes_Template', @level2type=N'COLUMN',@level2name=N'IsDefault'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes_Template', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点模板表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes_Template'
GO
/****** Object:  Table [dbo].[PE_Nodes_Model_Template]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Nodes_Model_Template]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Nodes_Model_Template](
	[NodeID] [int] NOT NULL,
	[ModelID] [int] NOT NULL,
	[DefaultTemplateFile] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK_PE_Nodes_Model_Template] PRIMARY KEY CLUSTERED 
(
	[NodeID] ASC,
	[ModelID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes_Model_Template', N'COLUMN',N'NodeID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes_Model_Template', @level2type=N'COLUMN',@level2name=N'NodeID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes_Model_Template', N'COLUMN',N'ModelID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes_Model_Template', @level2type=N'COLUMN',@level2name=N'ModelID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes_Model_Template', N'COLUMN',N'DefaultTemplateFile'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容模板ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes_Model_Template', @level2type=N'COLUMN',@level2name=N'DefaultTemplateFile'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes_Model_Template', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点模型模板表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes_Model_Template'
GO
/****** Object:  Table [dbo].[PE_Nodes]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Nodes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Nodes](
	[NodeID] [int] NOT NULL,
	[NodeIdentifier] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[NodeType] [int] NOT NULL,
	[ParentID] [int] NOT NULL,
	[ParentPath] [ntext] COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Depth] [int] NOT NULL,
	[RootID] [int] NOT NULL,
	[Child] [int] NOT NULL,
	[arrChildID] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[PrevID] [int] NULL,
	[NextID] [int] NULL,
	[OrderID] [int] NULL,
	[NodeDir] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ParentDir] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[NodeName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Tips] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Description] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[NodePicUrl] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Meta_Keywords] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Meta_Description] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ShowOnMenu] [bit] NULL,
	[ShowOnPath] [bit] NULL,
	[ShowOnMap] [bit] NULL,
	[ShowOnList_Index] [bit] NULL,
	[ShowOnList_Parent] [bit] NULL,
	[PurviewType] [int] NULL,
	[Creater] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[InheritPurviewFromParent] [int] NULL,
	[WorkFlowID] [int] NULL,
	[HitsOfHot] [int] NULL,
	[LeastOfEliteLevel] [int] NULL,
	[OpenType] [int] NULL,
	[ItemCount] [int] NULL,
	[ItemChecked] [int] NULL,
	[CommentCount] [int] NULL,
	[Custom_Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IsCreateListPage] [bit] NULL,
	[IsCreateContentPage] [bit] NULL,
	[AutoCreateHtmlType] [int] NULL,
	[ContentPageHtmlRule] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ListPageHtmlRule] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ItemAspxFileName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[RelateNode] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[RelateSpecial] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[DefaultTemplateFile] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ContainChildTemplateFile] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ItemOpenType] [int] NULL,
	[ItemListOrderType] [int] NULL,
	[ItemPageSize] [int] NULL,
	[UpLoadDirRule] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[LinkUrl] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Settings] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IPLock] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[ListPagePostFix] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ListPageSavePathType] [int] NULL,
	[NeedCreateHtml] [bit] NULL,
	[CultureName] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[EnableSubDomain] [bit] NULL,
	[SubDomain] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ConfigType] [int] NULL,
	[IncrementalUpdatePages] [int] NULL,
	[EnablePhone] [bit] NULL,
	[EnablePad] [bit] NULL,
 CONSTRAINT [PK_PE_Nodes_NodeID] PRIMARY KEY CLUSTERED 
(
	[NodeID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Nodes]') AND name = N'IX_PE_Nodes')
CREATE NONCLUSTERED INDEX [IX_PE_Nodes] ON [dbo].[PE_Nodes] 
(
	[NodeID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Nodes]') AND name = N'IX_PE_Nodes_OrderID')
CREATE NONCLUSTERED INDEX [IX_PE_Nodes_OrderID] ON [dbo].[PE_Nodes] 
(
	[OrderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Nodes]') AND name = N'IX_PE_Nodes_ParentId')
CREATE NONCLUSTERED INDEX [IX_PE_Nodes_ParentId] ON [dbo].[PE_Nodes] 
(
	[ParentID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Nodes]') AND name = N'IX_PE_Nodes_RootID')
CREATE NONCLUSTERED INDEX [IX_PE_Nodes_RootID] ON [dbo].[PE_Nodes] 
(
	[RootID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'NodeID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'NodeID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'NodeIdentifier'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点标识符，用于前台调用时可以直接用标识符取代ID。' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'NodeIdentifier'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'NodeType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点类型。1为容器栏目，3为单页节点，4为外部链接' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'NodeType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ParentID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'父节点ID，根节点的值为0' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ParentID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ParentPath'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'父路径，根节点的值为0，子节点的值为：0,1,6,76' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ParentPath'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'Depth'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点树的深度，根节点的值为0，子节点的值为该节点所在的层数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'Depth'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'RootID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'根节点排序ID。根节点使用RootID进行排序，同时子节点与根节点的RootID相等。' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'RootID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'Child'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'子节点数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'Child'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'arrChildID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所有子节点的ID数组' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'arrChildID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'PrevID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'同级节点的上一个节点ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'PrevID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'NextID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'同级节点的下一个节点ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'NextID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'NodeDir'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点目录，只能是英文字母和数字，并且要以字母开头。' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'NodeDir'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ParentDir'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'父目录，系统自动根据树形目录算出来的目录路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ParentDir'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'NodeName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'NodeName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'Tips'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点提示，不支持HTML' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'Tips'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'Description'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点说明，支持HTML' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'Description'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'NodePicUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'图片地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'NodePicUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'Meta_Keywords'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'针对搜索引擎的关键字' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'Meta_Keywords'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'Meta_Description'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'针对搜索引擎的说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'Meta_Description'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ShowOnMenu'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否在顶部菜单处显示' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ShowOnMenu'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ShowOnPath'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否位置导航处显示' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ShowOnPath'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ShowOnMap'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否在网站地图（栏目导航）处显示' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ShowOnMap'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ShowOnList_Index'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否在首页的分类列表处显示' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ShowOnList_Index'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ShowOnList_Parent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否在父栏目的分类列表处显示' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ShowOnList_Parent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'PurviewType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'栏目权限。0--开放栏目  1--半开放栏目  2--认证栏目' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'PurviewType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'Creater'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'栏目创建者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'Creater'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'InheritPurviewFromParent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'从父栏目继承权限设置。' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'InheritPurviewFromParent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'WorkFlowID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'工作流程ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'WorkFlowID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'HitsOfHot'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'本栏目热点的点击数最小值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'HitsOfHot'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'LeastOfEliteLevel'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'本栏目推荐的' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'LeastOfEliteLevel'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'OpenType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'此节点的打开方式( 0--原窗口  1--新窗口)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'OpenType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ItemCount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ItemCount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ItemChecked'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'审核项目数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ItemChecked'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'CommentCount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'CommentCount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'Custom_Content'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自设内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'Custom_Content'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'IsCreateListPage'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列表页生成方式 0不生成，1生成' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'IsCreateListPage'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'IsCreateContentPage'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容页生成方式 0不生成，1生成' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'IsCreateContentPage'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'AutoCreateHtmlType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自动生成Html类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'AutoCreateHtmlType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ContentPageHtmlRule'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容页的文件名规则' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ContentPageHtmlRule'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ListPageHtmlRule'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列表页的文件名规则' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ListPageHtmlRule'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ItemAspxFileName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'动态方式的内容页文件名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ItemAspxFileName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'RelateNode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关联节点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'RelateNode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'RelateSpecial'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关联专题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'RelateSpecial'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'DefaultTemplateFile'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'此节点的默认首页模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'DefaultTemplateFile'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ContainChildTemplateFile'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列表页模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ContainChildTemplateFile'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ItemOpenType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'此节点下项目的打开方式 ( 0--原窗口  1--新窗口)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ItemOpenType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ItemListOrderType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'此节点下项目列表的排序方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ItemListOrderType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ItemPageSize'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点下内容每页分页数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ItemPageSize'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'UpLoadDirRule'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上传文件路径规则' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'UpLoadDirRule'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'LinkUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'外部链接地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'LinkUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'Settings'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点设置，使用XML保存配置' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'Settings'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'IPLock'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点IP设置，使用XML保存配置' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'IPLock'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ListPagePostFix'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列表页后缀' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ListPagePostFix'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ListPageSavePathType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列表页生成类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ListPageSavePathType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'NeedCreateHtml'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点下是否有需要生成HTML的内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'NeedCreateHtml'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'CultureName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文化名(语言种类)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'CultureName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'EnableSubDomain'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否开启子域名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'EnableSubDomain'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'SubDomain'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'子域名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'SubDomain'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'ConfigType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点配置类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'ConfigType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'IncrementalUpdatePages'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'增量更新页数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'IncrementalUpdatePages'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'EnablePhone'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否启用手机端' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'EnablePhone'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', N'COLUMN',N'EnablePad'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否启用平板端' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes', @level2type=N'COLUMN',@level2name=N'EnablePad'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Nodes', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Nodes'
GO
/****** Object:  Table [dbo].[PE_MoodScheme]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_MoodScheme]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_MoodScheme](
	[MoodID] [int] NOT NULL,
	[MoodName] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[MoodOption] [nvarchar](4000) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[MoodStatus] [bit] NOT NULL,
	[IsOnlyMember] [bit] NOT NULL,
 CONSTRAINT [PK_MoodScheme_MoodID] PRIMARY KEY CLUSTERED 
(
	[MoodID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_MoodScheme', N'COLUMN',N'MoodID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'心情指数方案ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_MoodScheme', @level2type=N'COLUMN',@level2name=N'MoodID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_MoodScheme', N'COLUMN',N'MoodName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'心情指数方案名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_MoodScheme', @level2type=N'COLUMN',@level2name=N'MoodName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_MoodScheme', N'COLUMN',N'MoodOption'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'心情指数方案选项用$$$拆分' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_MoodScheme', @level2type=N'COLUMN',@level2name=N'MoodOption'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_MoodScheme', N'COLUMN',N'MoodStatus'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'心情指数方案是否启用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_MoodScheme', @level2type=N'COLUMN',@level2name=N'MoodStatus'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_MoodScheme', N'COLUMN',N'IsOnlyMember'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否仅能会员投票' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_MoodScheme', @level2type=N'COLUMN',@level2name=N'IsOnlyMember'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_MoodScheme', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'心情指数方案表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_MoodScheme'
GO
/****** Object:  Table [dbo].[PE_Mood]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Mood]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Mood](
	[GeneralID] [int] NOT NULL,
	[MoodID] [int] NOT NULL,
	[M0] [int] NOT NULL,
	[M1] [int] NOT NULL,
	[M2] [int] NOT NULL,
	[M3] [int] NOT NULL,
	[M4] [int] NOT NULL,
	[M5] [int] NOT NULL,
	[M6] [int] NOT NULL,
	[M7] [int] NOT NULL,
	[M8] [int] NOT NULL,
	[M9] [int] NOT NULL,
	[M10] [int] NOT NULL,
	[M11] [int] NOT NULL,
	[M12] [int] NOT NULL,
	[M13] [int] NOT NULL,
	[M14] [int] NOT NULL,
	[M15] [int] NOT NULL,
	[M16] [int] NOT NULL,
	[M17] [int] NOT NULL,
	[M18] [int] NOT NULL,
	[M19] [int] NOT NULL,
 CONSTRAINT [PK_Mood_GeneralID] PRIMARY KEY CLUSTERED 
(
	[GeneralID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Mood]') AND name = N'IX_PE_Mood_MoodID')
CREATE NONCLUSTERED INDEX [IX_PE_Mood_MoodID] ON [dbo].[PE_Mood] 
(
	[MoodID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'GeneralID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'GeneralID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'MoodID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'心情指数方案ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'MoodID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M0'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项0' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M0'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M1'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项1' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M1'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M2'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项2' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M2'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M3'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项3' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M3'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M4'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项4' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M4'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M5'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项5' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M5'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M6'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项6' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M6'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M7'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项7' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M7'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M8'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项8' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M8'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M9'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项9' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M9'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M10'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项10' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M10'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M11'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项11' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M11'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M12'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项12' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M12'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M13'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项13' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M13'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M14'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项14' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M14'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M15'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项15' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M15'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M16'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项16' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M16'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M17'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项17' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M17'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M18'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项18' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M18'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', N'COLUMN',N'M19'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'选项19' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood', @level2type=N'COLUMN',@level2name=N'M19'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Mood', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'心情指数表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Mood'
GO
/****** Object:  Table [dbo].[PE_ModelTemplates]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ModelTemplates]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ModelTemplates](
	[TemplateID] [int] NOT NULL,
	[TemplateName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[TemplateDescription] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Field] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IsEshop] [bit] NULL,
 CONSTRAINT [PK_PE_ModelTemplates_TemplateID] PRIMARY KEY CLUSTERED 
(
	[TemplateID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ModelTemplates', N'COLUMN',N'TemplateID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型模板ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ModelTemplates', @level2type=N'COLUMN',@level2name=N'TemplateID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ModelTemplates', N'COLUMN',N'TemplateName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型模板名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ModelTemplates', @level2type=N'COLUMN',@level2name=N'TemplateName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ModelTemplates', N'COLUMN',N'TemplateDescription'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型模板描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ModelTemplates', @level2type=N'COLUMN',@level2name=N'TemplateDescription'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ModelTemplates', N'COLUMN',N'Field'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型模板XML' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ModelTemplates', @level2type=N'COLUMN',@level2name=N'Field'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ModelTemplates', N'COLUMN',N'IsEshop'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ModelTemplates', @level2type=N'COLUMN',@level2name=N'IsEshop'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ModelTemplates', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型模板表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ModelTemplates'
GO
/****** Object:  Table [dbo].[PE_Model_FilterField]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Model_FilterField]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Model_FilterField](
	[ID] [int] NOT NULL,
	[ModelID] [int] NULL,
	[FieldName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[FieldValue] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model_FilterField', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model_FilterField', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model_FilterField', N'COLUMN',N'ModelID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model_FilterField', @level2type=N'COLUMN',@level2name=N'ModelID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model_FilterField', N'COLUMN',N'FieldName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model_FilterField', @level2type=N'COLUMN',@level2name=N'FieldName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model_FilterField', N'COLUMN',N'FieldValue'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model_FilterField', @level2type=N'COLUMN',@level2name=N'FieldValue'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model_FilterField', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段筛选表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model_FilterField'
GO
/****** Object:  Table [dbo].[PE_Model]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Model]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Model](
	[ModelID] [int] NOT NULL,
	[ModelName] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ModelType] [int] NULL,
	[Description] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[TableName] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ItemName] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ItemUnit] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ItemIcon] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[IsCountHits] [bit] NOT NULL,
	[Disabled] [bit] NOT NULL,
	[Field] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[DefaultTemplateFile] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[EnableCharge] [bit] NULL,
	[EnableSignin] [bit] NULL,
	[AddInfoFilePath] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
	[ManageInfoFilePath] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
	[PreviewInfoFilePath] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
	[BatchInfoFilePath] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
	[Character] [int] NULL,
	[MaxPerUser] [int] NULL,
	[PrintTemplate] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[EnableVote] [bit] NULL,
	[SearchTemplate] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[AdvanceSearchFormTemplate] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[AdvanceSearchTemplate] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ChargeTips] [nvarchar](4000) COLLATE Chinese_PRC_CI_AS NULL,
	[NeedPointChargeTips] [nvarchar](4000) COLLATE Chinese_PRC_CI_AS NULL,
	[OutTimeChargeTips] [nvarchar](4000) COLLATE Chinese_PRC_CI_AS NULL,
	[UsePointChargeTips] [nvarchar](4000) COLLATE Chinese_PRC_CI_AS NULL,
	[CommentManageTemplate] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[AnonymouseTemplate] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[UserAddContentTemplate] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[EnableVerificationCode] [bit] NULL,
	[EnableWap] [bit] NULL,
	[WapField] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[TitleField] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_ContentModel_ModelID] PRIMARY KEY CLUSTERED 
(
	[ModelID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'ModelID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'ModelID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'ModelName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'ModelName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'ModelType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'ModelType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'Description'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'Description'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'TableName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型关联的表名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'TableName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'ItemName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目名称：如文章、新闻、日志、信息' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'ItemName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'ItemUnit'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目单位：如篇、条、个' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'ItemUnit'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'ItemIcon'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型图标' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'ItemIcon'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'IsCountHits'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否统计点击数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'IsCountHits'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'Disabled'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否禁用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'Disabled'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'Field'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段对象' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'Field'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'DefaultTemplateFile'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容页模板路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'DefaultTemplateFile'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'EnableCharge'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否启用收费功能' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'EnableCharge'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'EnableSignin'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否启用签收功能' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'EnableSignin'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'AddInfoFilePath'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'添加程序页面路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'AddInfoFilePath'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'ManageInfoFilePath'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'管理程序页面路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'ManageInfoFilePath'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'PreviewInfoFilePath'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'预览程序页面路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'PreviewInfoFilePath'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'BatchInfoFilePath'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'批量程序页面路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'BatchInfoFilePath'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'Character'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品性质' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'Character'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'MaxPerUser'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'每个用户可以在此内容模型下发表多少篇内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'MaxPerUser'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'PrintTemplate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'打印页模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'PrintTemplate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'EnableVote'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否允许投票' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'EnableVote'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'SearchTemplate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'搜索页模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'SearchTemplate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'AdvanceSearchFormTemplate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'高级搜索表单模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'AdvanceSearchFormTemplate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'AdvanceSearchTemplate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'高级搜索结果模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'AdvanceSearchTemplate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'ChargeTips'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生成静态页时模型收费提示' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'ChargeTips'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'NeedPointChargeTips'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型收费提示' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'NeedPointChargeTips'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'OutTimeChargeTips'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型收费提示' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'OutTimeChargeTips'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'UsePointChargeTips'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型收费提示' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'UsePointChargeTips'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'CommentManageTemplate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论页模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'CommentManageTemplate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'AnonymouseTemplate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'匿名投稿模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'AnonymouseTemplate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'UserAddContentTemplate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户添加信息模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'UserAddContentTemplate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'EnableVerificationCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'验证码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'EnableVerificationCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'EnableWap'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否启用WAP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'EnableWap'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'WapField'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'WAP字段映射' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'WapField'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', N'COLUMN',N'TitleField'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自定义表单标题字段' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model', @level2type=N'COLUMN',@level2name=N'TitleField'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Model', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Model'
GO
/****** Object:  Table [dbo].[PE_Message]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Message]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Message](
	[MessageID] [int] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Content] [ntext] COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Sender] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Incept] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[SendTime] [datetime] NOT NULL,
	[IsSend] [int] NOT NULL,
	[IsDelInbox] [int] NOT NULL,
	[IsDelSendbox] [int] NOT NULL,
	[IsRead] [int] NOT NULL,
 CONSTRAINT [PK_PE_Message_MessageID] PRIMARY KEY CLUSTERED 
(
	[MessageID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Message', N'COLUMN',N'MessageID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短消息Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Message', @level2type=N'COLUMN',@level2name=N'MessageID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Message', N'COLUMN',N'Title'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Message', @level2type=N'COLUMN',@level2name=N'Title'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Message', N'COLUMN',N'Content'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Message', @level2type=N'COLUMN',@level2name=N'Content'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Message', N'COLUMN',N'Sender'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发件人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Message', @level2type=N'COLUMN',@level2name=N'Sender'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Message', N'COLUMN',N'Incept'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'收件人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Message', @level2type=N'COLUMN',@level2name=N'Incept'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Message', N'COLUMN',N'SendTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发送日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Message', @level2type=N'COLUMN',@level2name=N'SendTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Message', N'COLUMN',N'IsSend'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否被发送，0为没发送，1为被发送' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Message', @level2type=N'COLUMN',@level2name=N'IsSend'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Message', N'COLUMN',N'IsDelInbox'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'收件箱中信息的删除标记，0为未删除，1为已删除' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Message', @level2type=N'COLUMN',@level2name=N'IsDelInbox'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Message', N'COLUMN',N'IsDelSendbox'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发件箱中信息的删除标记，0为未删除，1为已删除' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Message', @level2type=N'COLUMN',@level2name=N'IsDelSendbox'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Message', N'COLUMN',N'IsRead'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短消息状态，0为未读，1为已读' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Message', @level2type=N'COLUMN',@level2name=N'IsRead'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Message', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短消息表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Message'
GO
/****** Object:  Table [dbo].[PE_MailList_SubscriptionItem]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_MailList_SubscriptionItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_MailList_SubscriptionItem](
	[MailListId] [int] NOT NULL,
	[SubscriptionItemId] [int] NOT NULL
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_MailList_SubscriptionItem', N'COLUMN',N'MailListId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮件ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_MailList_SubscriptionItem', @level2type=N'COLUMN',@level2name=N'MailListId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_MailList_SubscriptionItem', N'COLUMN',N'SubscriptionItemId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订阅项ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_MailList_SubscriptionItem', @level2type=N'COLUMN',@level2name=N'SubscriptionItemId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_MailList_SubscriptionItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订阅邮件地址_订阅项关系表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_MailList_SubscriptionItem'
GO
/****** Object:  Table [dbo].[PE_MailList]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_MailList]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_MailList](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Email] [nvarchar](64) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK_PE_MailList] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_MailList', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮件ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_MailList', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_MailList', N'COLUMN',N'Email'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮件地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_MailList', @level2type=N'COLUMN',@level2name=N'Email'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_MailList', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮件订阅列表表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_MailList'
GO
/****** Object:  Table [dbo].[PE_Log]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Log]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Log](
	[LogID] [int] IDENTITY(1,1) NOT NULL,
	[Category] [int] NULL,
	[Priority] [int] NULL,
	[Title] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Message] [text] COLLATE Chinese_PRC_CI_AS NULL,
	[Timestamp] [datetime] NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[UserIP] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Source] [text] COLLATE Chinese_PRC_CI_AS NULL,
	[ScriptName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[PostString] [text] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Log_LogID] PRIMARY KEY CLUSTERED 
(
	[LogID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Log', N'COLUMN',N'LogID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Log', @level2type=N'COLUMN',@level2name=N'LogID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Log', N'COLUMN',N'Category'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分类' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Log', @level2type=N'COLUMN',@level2name=N'Category'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Log', N'COLUMN',N'Priority'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优先级别' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Log', @level2type=N'COLUMN',@level2name=N'Priority'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Log', N'COLUMN',N'Title'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Log', @level2type=N'COLUMN',@level2name=N'Title'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Log', N'COLUMN',N'Message'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Log', @level2type=N'COLUMN',@level2name=N'Message'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Log', N'COLUMN',N'Timestamp'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'记录日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Log', @level2type=N'COLUMN',@level2name=N'Timestamp'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Log', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Log', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Log', N'COLUMN',N'UserIP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Log', @level2type=N'COLUMN',@level2name=N'UserIP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Log', N'COLUMN',N'Source'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'StackTrace，TargetSite：异常源，堆栈跟踪，等异常信息' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Log', @level2type=N'COLUMN',@level2name=N'Source'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Log', N'COLUMN',N'ScriptName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'页面' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Log', @level2type=N'COLUMN',@level2name=N'ScriptName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Log', N'COLUMN',N'PostString'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'提交信息' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Log', @level2type=N'COLUMN',@level2name=N'PostString'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Log', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'日志表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Log'
GO
/****** Object:  Table [dbo].[PE_Keywords]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Keywords]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Keywords](
	[KeywordID] [int] IDENTITY(1,1) NOT NULL,
	[KeywordText] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[KeywordType] [int] NOT NULL,
	[Priority] [int] NOT NULL,
	[Hits] [int] NOT NULL,
	[LastUseTime] [datetime] NOT NULL,
	[GeneralID] [int] NULL,
	[QuoteTimes] [int] NULL,
 CONSTRAINT [PK_PE_Keywords_KeywordID] PRIMARY KEY CLUSTERED 
(
	[KeywordID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Keywords', N'COLUMN',N'KeywordID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Keywords', @level2type=N'COLUMN',@level2name=N'KeywordID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Keywords', N'COLUMN',N'KeywordText'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Keywords', @level2type=N'COLUMN',@level2name=N'KeywordText'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Keywords', N'COLUMN',N'KeywordType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字类别' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Keywords', @level2type=N'COLUMN',@level2name=N'KeywordType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Keywords', N'COLUMN',N'Priority'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字优先级' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Keywords', @level2type=N'COLUMN',@level2name=N'Priority'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Keywords', N'COLUMN',N'Hits'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字使用量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Keywords', @level2type=N'COLUMN',@level2name=N'Hits'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Keywords', N'COLUMN',N'LastUseTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字最后使用时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Keywords', @level2type=N'COLUMN',@level2name=N'LastUseTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Keywords', N'COLUMN',N'GeneralID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字对应的内容ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Keywords', @level2type=N'COLUMN',@level2name=N'GeneralID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Keywords', N'COLUMN',N'QuoteTimes'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字被引用的次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Keywords', @level2type=N'COLUMN',@level2name=N'QuoteTimes'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Keywords', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Keywords'
GO
/****** Object:  Table [dbo].[PE_KeywordRelationShip]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_KeywordRelationShip]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_KeywordRelationShip](
	[KeywordID] [int] NOT NULL,
	[GeneralID] [int] NOT NULL
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_KeywordRelationShip', N'COLUMN',N'KeywordID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_KeywordRelationShip', @level2type=N'COLUMN',@level2name=N'KeywordID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_KeywordRelationShip', N'COLUMN',N'GeneralID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_KeywordRelationShip', @level2type=N'COLUMN',@level2name=N'GeneralID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_KeywordRelationShip', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字与内容关系表表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_KeywordRelationShip'
GO
/****** Object:  Table [dbo].[PE_InvoiceItem]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_InvoiceItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_InvoiceItem](
	[InvoiceID] [int] IDENTITY(1,1) NOT NULL,
	[ClientID] [int] NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[OrderID] [int] NULL,
	[InvoiceType] [int] NULL,
	[InvoiceNum] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[InvoiceTitle] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[InvoiceContent] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[InvoiceDate] [datetime] NULL,
	[TotalMoney] [money] NULL,
	[Drawer] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Inputer] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[InputTime] [datetime] NULL,
	[Memo] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_InvoiceItem_InvoiceID] PRIMARY KEY CLUSTERED 
(
	[InvoiceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_InvoiceItem]') AND name = N'IX_PE_InvoiceItem_InvoiceNum')
CREATE NONCLUSTERED INDEX [IX_PE_InvoiceItem_InvoiceNum] ON [dbo].[PE_InvoiceItem] 
(
	[InvoiceNum] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_InvoiceItem]') AND name = N'IX_PE_InvoiceItem_OrderID')
CREATE NONCLUSTERED INDEX [IX_PE_InvoiceItem_OrderID] ON [dbo].[PE_InvoiceItem] 
(
	[OrderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_InvoiceItem]') AND name = N'IX_PE_InvoiceItem_UserName')
CREATE NONCLUSTERED INDEX [IX_PE_InvoiceItem_UserName] ON [dbo].[PE_InvoiceItem] 
(
	[UserName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', N'COLUMN',N'InvoiceID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发票记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem', @level2type=N'COLUMN',@level2name=N'InvoiceID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', N'COLUMN',N'ClientID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem', @level2type=N'COLUMN',@level2name=N'ClientID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', N'COLUMN',N'InvoiceType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发票类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem', @level2type=N'COLUMN',@level2name=N'InvoiceType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', N'COLUMN',N'InvoiceNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发票号码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem', @level2type=N'COLUMN',@level2name=N'InvoiceNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', N'COLUMN',N'InvoiceTitle'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发票抬头' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem', @level2type=N'COLUMN',@level2name=N'InvoiceTitle'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', N'COLUMN',N'InvoiceContent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发票内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem', @level2type=N'COLUMN',@level2name=N'InvoiceContent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', N'COLUMN',N'InvoiceDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发票日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem', @level2type=N'COLUMN',@level2name=N'InvoiceDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', N'COLUMN',N'TotalMoney'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发票金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem', @level2type=N'COLUMN',@level2name=N'TotalMoney'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', N'COLUMN',N'Drawer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'开票人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem', @level2type=N'COLUMN',@level2name=N'Drawer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', N'COLUMN',N'InputTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem', @level2type=N'COLUMN',@level2name=N'InputTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', N'COLUMN',N'Memo'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内部记录' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem', @level2type=N'COLUMN',@level2name=N'Memo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InvoiceItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发票记录表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InvoiceItem'
GO
/****** Object:  Table [dbo].[PE_InfoNextProcessRoles]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_InfoNextProcessRoles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_InfoNextProcessRoles](
	[GeneralID] [int] NOT NULL,
	[RoleID] [int] NOT NULL,
 CONSTRAINT [PK_PE_InfoNextProcessRoles] PRIMARY KEY CLUSTERED 
(
	[GeneralID] ASC,
	[RoleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InfoNextProcessRoles', N'COLUMN',N'GeneralID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InfoNextProcessRoles', @level2type=N'COLUMN',@level2name=N'GeneralID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InfoNextProcessRoles', N'COLUMN',N'RoleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InfoNextProcessRoles', @level2type=N'COLUMN',@level2name=N'RoleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InfoNextProcessRoles', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息下一步可审核的角色列表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InfoNextProcessRoles'
GO
/****** Object:  Table [dbo].[PE_InfoFileRelation]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_InfoFileRelation]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_InfoFileRelation](
	[InfoID] [int] NOT NULL,
	[InfoType] [int] NULL,
	[Path] [nvarchar](1000) COLLATE Chinese_PRC_CI_AS NULL
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InfoFileRelation', N'COLUMN',N'InfoID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InfoFileRelation', @level2type=N'COLUMN',@level2name=N'InfoID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InfoFileRelation', N'COLUMN',N'InfoType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InfoFileRelation', @level2type=N'COLUMN',@level2name=N'InfoType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InfoFileRelation', N'COLUMN',N'Path'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文件路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InfoFileRelation', @level2type=N'COLUMN',@level2name=N'Path'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_InfoFileRelation', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文件和信息关系表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_InfoFileRelation'
GO
/****** Object:  Table [dbo].[PE_IndentItem]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_IndentItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_IndentItem](
	[ItemID] [int] NOT NULL,
	[IndentID] [int] NOT NULL,
	[ProductID] [int] NOT NULL,
	[Property] [nvarchar](510) COLLATE Chinese_PRC_CI_AS NULL,
	[Amount] [int] NOT NULL,
	[Price] [money] NULL,
	[TableName] [nvarchar](510) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_IndentItem] PRIMARY KEY CLUSTERED 
(
	[ItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IndentItem', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IndentItem', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IndentItem', N'COLUMN',N'IndentID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订货单记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IndentItem', @level2type=N'COLUMN',@level2name=N'IndentID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IndentItem', N'COLUMN',N'ProductID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IndentItem', @level2type=N'COLUMN',@level2name=N'ProductID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IndentItem', N'COLUMN',N'Property'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品属性' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IndentItem', @level2type=N'COLUMN',@level2name=N'Property'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IndentItem', N'COLUMN',N'Amount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IndentItem', @level2type=N'COLUMN',@level2name=N'Amount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IndentItem', N'COLUMN',N'Price'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'价钱(成本价/售货价)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IndentItem', @level2type=N'COLUMN',@level2name=N'Price'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IndentItem', N'COLUMN',N'TableName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据表名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IndentItem', @level2type=N'COLUMN',@level2name=N'TableName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IndentItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订货项表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IndentItem'
GO
/****** Object:  Table [dbo].[PE_Indent]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Indent]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Indent](
	[IndentID] [int] NOT NULL,
	[IndentNum] [nvarchar](40) COLLATE Chinese_PRC_CI_AS NULL,
	[InputTime] [datetime] NOT NULL,
	[Inputer] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Status] [int] NOT NULL,
	[Remark] [nvarchar](510) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Indent] PRIMARY KEY CLUSTERED 
(
	[IndentID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Indent', N'COLUMN',N'IndentID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Indent', @level2type=N'COLUMN',@level2name=N'IndentID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Indent', N'COLUMN',N'IndentNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Indent', @level2type=N'COLUMN',@level2name=N'IndentNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Indent', N'COLUMN',N'InputTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Indent', @level2type=N'COLUMN',@level2name=N'InputTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Indent', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Indent', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Indent', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Indent', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Indent', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Indent', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Indent', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订货表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Indent'
GO
/****** Object:  Table [dbo].[PE_IncludeFile]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_IncludeFile]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_IncludeFile](
	[ID] [int] NOT NULL,
	[Name] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Description] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IncludeType] [int] NULL,
	[AssociateType] [int] NULL,
	[CallType] [int] NULL,
	[FileName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Template] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_IncludeFile_ID] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IncludeFile', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IncludeFile', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IncludeFile', N'COLUMN',N'Name'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IncludeFile', @level2type=N'COLUMN',@level2name=N'Name'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IncludeFile', N'COLUMN',N'Description'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IncludeFile', @level2type=N'COLUMN',@level2name=N'Description'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IncludeFile', N'COLUMN',N'IncludeType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IncludeFile', @level2type=N'COLUMN',@level2name=N'IncludeType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IncludeFile', N'COLUMN',N'AssociateType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关联生成类型，0-不关联，1-关联节点，2-关联专题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IncludeFile', @level2type=N'COLUMN',@level2name=N'AssociateType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IncludeFile', N'COLUMN',N'CallType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'调用方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IncludeFile', @level2type=N'COLUMN',@level2name=N'CallType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IncludeFile', N'COLUMN',N'FileName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文件名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IncludeFile', @level2type=N'COLUMN',@level2name=N'FileName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IncludeFile', N'COLUMN',N'Template'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IncludeFile', @level2type=N'COLUMN',@level2name=N'Template'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_IncludeFile', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内嵌文件表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_IncludeFile'
GO
/****** Object:  Table [dbo].[PE_GroupSpecialPermissions]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_GroupSpecialPermissions]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_GroupSpecialPermissions](
	[GroupID] [int] NOT NULL,
	[OperateCode] [int] NOT NULL,
	[SpecialID] [int] NOT NULL,
	[IDType] [int] NOT NULL,
 CONSTRAINT [PK_PE_GroupSpecialPermissions] PRIMARY KEY CLUSTERED 
(
	[GroupID] ASC,
	[OperateCode] ASC,
	[SpecialID] ASC,
	[IDType] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupSpecialPermissions', N'COLUMN',N'GroupID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户组ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupSpecialPermissions', @level2type=N'COLUMN',@level2name=N'GroupID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupSpecialPermissions', N'COLUMN',N'OperateCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'权限操作码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupSpecialPermissions', @level2type=N'COLUMN',@level2name=N'OperateCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupSpecialPermissions', N'COLUMN',N'SpecialID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupSpecialPermissions', @level2type=N'COLUMN',@level2name=N'SpecialID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupSpecialPermissions', N'COLUMN',N'IDType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID类型 0 用户 1 用户组' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupSpecialPermissions', @level2type=N'COLUMN',@level2name=N'IDType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupSpecialPermissions', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员专题权限表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupSpecialPermissions'
GO
/****** Object:  Table [dbo].[PE_GroupSpecialCategoryPermissions]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_GroupSpecialCategoryPermissions]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_GroupSpecialCategoryPermissions](
	[GroupID] [int] NOT NULL,
	[OperateCode] [int] NOT NULL,
	[SpecialCategoryID] [int] NOT NULL,
	[IDType] [int] NOT NULL,
 CONSTRAINT [PK_PE_GroupSpecialCategoryPermissions] PRIMARY KEY CLUSTERED 
(
	[GroupID] ASC,
	[OperateCode] ASC,
	[SpecialCategoryID] ASC,
	[IDType] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupSpecialCategoryPermissions', N'COLUMN',N'GroupID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户组ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupSpecialCategoryPermissions', @level2type=N'COLUMN',@level2name=N'GroupID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupSpecialCategoryPermissions', N'COLUMN',N'OperateCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'权限操作码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupSpecialCategoryPermissions', @level2type=N'COLUMN',@level2name=N'OperateCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupSpecialCategoryPermissions', N'COLUMN',N'SpecialCategoryID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题类别ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupSpecialCategoryPermissions', @level2type=N'COLUMN',@level2name=N'SpecialCategoryID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupSpecialCategoryPermissions', N'COLUMN',N'IDType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID类型 0 用户 1 用户组' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupSpecialCategoryPermissions', @level2type=N'COLUMN',@level2name=N'IDType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupSpecialCategoryPermissions', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员专题分类权限表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupSpecialCategoryPermissions'
GO
/****** Object:  Table [dbo].[PE_GroupNodePermissions]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_GroupNodePermissions]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_GroupNodePermissions](
	[GroupID] [int] NOT NULL,
	[OperateCode] [int] NOT NULL,
	[NodeID] [int] NOT NULL,
	[IdType] [int] NOT NULL,
 CONSTRAINT [PK_PE_GroupNodePermissions] PRIMARY KEY CLUSTERED 
(
	[GroupID] ASC,
	[OperateCode] ASC,
	[NodeID] ASC,
	[IdType] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupNodePermissions', N'COLUMN',N'GroupID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户组ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupNodePermissions', @level2type=N'COLUMN',@level2name=N'GroupID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupNodePermissions', N'COLUMN',N'OperateCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'权限操作码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupNodePermissions', @level2type=N'COLUMN',@level2name=N'OperateCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupNodePermissions', N'COLUMN',N'NodeID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'栏目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupNodePermissions', @level2type=N'COLUMN',@level2name=N'NodeID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupNodePermissions', N'COLUMN',N'IdType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID类型 0 用户 1 用户组' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupNodePermissions', @level2type=N'COLUMN',@level2name=N'IdType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupNodePermissions', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员节点权限表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupNodePermissions'
GO
/****** Object:  Table [dbo].[PE_GroupFieldPermissions]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_GroupFieldPermissions]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_GroupFieldPermissions](
	[GroupID] [int] NOT NULL,
	[OperateCode] [int] NOT NULL,
	[ModelID] [int] NOT NULL,
	[FieldName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[IdType] [int] NOT NULL,
 CONSTRAINT [PK_PE_GroupFieldPermissions] PRIMARY KEY CLUSTERED 
(
	[GroupID] ASC,
	[OperateCode] ASC,
	[ModelID] ASC,
	[FieldName] ASC,
	[IdType] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupFieldPermissions', N'COLUMN',N'GroupID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员组ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupFieldPermissions', @level2type=N'COLUMN',@level2name=N'GroupID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupFieldPermissions', N'COLUMN',N'OperateCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'权限操作码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupFieldPermissions', @level2type=N'COLUMN',@level2name=N'OperateCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupFieldPermissions', N'COLUMN',N'ModelID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupFieldPermissions', @level2type=N'COLUMN',@level2name=N'ModelID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupFieldPermissions', N'COLUMN',N'FieldName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型字段名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupFieldPermissions', @level2type=N'COLUMN',@level2name=N'FieldName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupFieldPermissions', N'COLUMN',N'IdType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID类型 0 用户 1 用户组' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupFieldPermissions', @level2type=N'COLUMN',@level2name=N'IdType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_GroupFieldPermissions', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员字段权限表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_GroupFieldPermissions'
GO
/****** Object:  Table [dbo].[PE_Friend]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Friend]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Friend](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[FriendName] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[AddTime] [datetime] NULL,
	[GroupID] [int] NULL,
 CONSTRAINT [PK_PE_Friend_ID] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Friend]') AND name = N'IX_PE_Friend_AddTime')
CREATE NONCLUSTERED INDEX [IX_PE_Friend_AddTime] ON [dbo].[PE_Friend] 
(
	[AddTime] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Friend]') AND name = N'IX_PE_Friend_GroupID')
CREATE NONCLUSTERED INDEX [IX_PE_Friend_GroupID] ON [dbo].[PE_Friend] 
(
	[GroupID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Friend', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'好友ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Friend', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Friend', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Friend', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Friend', N'COLUMN',N'FriendName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'好友名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Friend', @level2type=N'COLUMN',@level2name=N'FriendName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Friend', N'COLUMN',N'AddTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Friend', @level2type=N'COLUMN',@level2name=N'AddTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Friend', N'COLUMN',N'GroupID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'好友分组ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Friend', @level2type=N'COLUMN',@level2name=N'GroupID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Friend', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'好友表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Friend'
GO
/****** Object:  Table [dbo].[PE_FlowProcess]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_FlowProcess]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_FlowProcess](
	[ProcessID] [int] NOT NULL,
	[FlowID] [int] NOT NULL,
	[ProcessName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Description] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[PassActionName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PassActionStatus] [int] NOT NULL,
	[RejectActionName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[RejectActionStatus] [int] NOT NULL,
 CONSTRAINT [PK_PE_FlowProcess] PRIMARY KEY CLUSTERED 
(
	[ProcessID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_FlowProcess', N'COLUMN',N'ProcessID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'步骤ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_FlowProcess', @level2type=N'COLUMN',@level2name=N'ProcessID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_FlowProcess', N'COLUMN',N'FlowID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'流程ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_FlowProcess', @level2type=N'COLUMN',@level2name=N'FlowID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_FlowProcess', N'COLUMN',N'ProcessName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'步骤名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_FlowProcess', @level2type=N'COLUMN',@level2name=N'ProcessName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_FlowProcess', N'COLUMN',N'Description'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'步骤说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_FlowProcess', @level2type=N'COLUMN',@level2name=N'Description'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_FlowProcess', N'COLUMN',N'PassActionName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'通过操作的操作名，例如：一审通过' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_FlowProcess', @level2type=N'COLUMN',@level2name=N'PassActionName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_FlowProcess', N'COLUMN',N'PassActionStatus'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'通过后的状态码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_FlowProcess', @level2type=N'COLUMN',@level2name=N'PassActionStatus'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_FlowProcess', N'COLUMN',N'RejectActionName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'打回操作的操作名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_FlowProcess', @level2type=N'COLUMN',@level2name=N'RejectActionName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_FlowProcess', N'COLUMN',N'RejectActionStatus'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'打回后的状态码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_FlowProcess', @level2type=N'COLUMN',@level2name=N'RejectActionStatus'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_FlowProcess', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'流程步骤表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_FlowProcess'
GO
/****** Object:  Table [dbo].[PE_Files]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Files]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Files](
	[ID] [int] NOT NULL,
	[Name] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Size] [int] NULL,
	[Path] [nvarchar](1000) COLLATE Chinese_PRC_CI_AS NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[FileType] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Files_ID] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Files', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文件ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Files', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Files', N'COLUMN',N'Name'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文件名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Files', @level2type=N'COLUMN',@level2name=N'Name'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Files', N'COLUMN',N'Size'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文件大小' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Files', @level2type=N'COLUMN',@level2name=N'Size'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Files', N'COLUMN',N'Path'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文件存放路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Files', @level2type=N'COLUMN',@level2name=N'Path'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Files', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Files', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Files', N'COLUMN',N'FileType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文件类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Files', @level2type=N'COLUMN',@level2name=N'FileType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Files', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文件表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Files'
GO
/****** Object:  Table [dbo].[PE_Favorite]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Favorite]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Favorite](
	[FavoriteID] [int] NOT NULL,
	[UserID] [int] NULL,
	[InfoID] [int] NULL,
	[FavoriteTime] [datetime] NULL,
 CONSTRAINT [PK_PE_Favorite_FavoriteID] PRIMARY KEY CLUSTERED 
(
	[FavoriteID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Favorite', N'COLUMN',N'FavoriteID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'收藏ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Favorite', @level2type=N'COLUMN',@level2name=N'FavoriteID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Favorite', N'COLUMN',N'UserID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Favorite', @level2type=N'COLUMN',@level2name=N'UserID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Favorite', N'COLUMN',N'InfoID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容信息ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Favorite', @level2type=N'COLUMN',@level2name=N'InfoID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Favorite', N'COLUMN',N'FavoriteTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'收藏时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Favorite', @level2type=N'COLUMN',@level2name=N'FavoriteTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Favorite', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户收藏表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Favorite'
GO
/****** Object:  Table [dbo].[PE_DownServer]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_DownServer]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_DownServer](
	[ServerID] [int] NOT NULL,
	[ServerName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ServerUrl] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ServerLogo] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[OrderID] [int] NULL,
	[ShowType] [int] NULL,
 CONSTRAINT [PK_PE_DownServer_ServerID] PRIMARY KEY CLUSTERED 
(
	[ServerID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DownServer', N'COLUMN',N'ServerID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'镜像服务器ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DownServer', @level2type=N'COLUMN',@level2name=N'ServerID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DownServer', N'COLUMN',N'ServerName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'镜像服务器名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DownServer', @level2type=N'COLUMN',@level2name=N'ServerName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DownServer', N'COLUMN',N'ServerUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'镜像服务器地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DownServer', @level2type=N'COLUMN',@level2name=N'ServerUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DownServer', N'COLUMN',N'ServerLogo'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'镜像服务器Logo' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DownServer', @level2type=N'COLUMN',@level2name=N'ServerLogo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DownServer', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'镜像服务器排序ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DownServer', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DownServer', N'COLUMN',N'ShowType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'镜像服务器显示方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DownServer', @level2type=N'COLUMN',@level2name=N'ShowType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DownServer', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'下载服务器表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DownServer'
GO
/****** Object:  Table [dbo].[PE_DownloadError]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_DownloadError]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_DownloadError](
	[ErrorID] [int] NOT NULL,
	[InfoID] [int] NULL,
	[ErrorUrl] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ErrorTimes] [int] NULL,
	[ErrorDate] [datetime] NULL,
 CONSTRAINT [PK_PE_DownloadError_ErrorID] PRIMARY KEY CLUSTERED 
(
	[ErrorID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DownloadError', N'COLUMN',N'ErrorID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'错误ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DownloadError', @level2type=N'COLUMN',@level2name=N'ErrorID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DownloadError', N'COLUMN',N'InfoID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'错误信息ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DownloadError', @level2type=N'COLUMN',@level2name=N'InfoID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DownloadError', N'COLUMN',N'ErrorUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用$$$分割的错误下载地址序号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DownloadError', @level2type=N'COLUMN',@level2name=N'ErrorUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DownloadError', N'COLUMN',N'ErrorTimes'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'报错次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DownloadError', @level2type=N'COLUMN',@level2name=N'ErrorTimes'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DownloadError', N'COLUMN',N'ErrorDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'报错日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DownloadError', @level2type=N'COLUMN',@level2name=N'ErrorDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DownloadError', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'下载报错表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DownloadError'
GO
/****** Object:  Table [dbo].[PE_Dictionary]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Dictionary]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Dictionary](
	[FieldID] [int] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[TableName] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[FieldName] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[FieldValue] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Dictionary_FieldID] PRIMARY KEY CLUSTERED 
(
	[FieldID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Dictionary', N'COLUMN',N'FieldID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Dictionary', @level2type=N'COLUMN',@level2name=N'FieldID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Dictionary', N'COLUMN',N'Title'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Dictionary', @level2type=N'COLUMN',@level2name=N'Title'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Dictionary', N'COLUMN',N'TableName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段所属的表名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Dictionary', @level2type=N'COLUMN',@level2name=N'TableName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Dictionary', N'COLUMN',N'FieldName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Dictionary', @level2type=N'COLUMN',@level2name=N'FieldName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Dictionary', N'COLUMN',N'FieldValue'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段值（选项名|是否启用值|默认值）' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Dictionary', @level2type=N'COLUMN',@level2name=N'FieldValue'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Dictionary', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据字典表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Dictionary'
GO
/****** Object:  Table [dbo].[PE_Department_Members]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Department_Members]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Department_Members](
	[AdminId] [int] NOT NULL,
	[DepartmentId] [int] NOT NULL
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department_Members', N'COLUMN',N'AdminId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department_Members', @level2type=N'COLUMN',@level2name=N'AdminId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department_Members', N'COLUMN',N'DepartmentId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department_Members', @level2type=N'COLUMN',@level2name=N'DepartmentId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department_Members', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门成员关系表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department_Members'
GO
/****** Object:  Table [dbo].[PE_Department]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Department]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Department](
	[DepartmentId] [int] NOT NULL,
	[DepartmentName] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[CategoryName] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[UploadDir] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Number] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Priority] [int] NULL,
	[Template] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Abbreviation] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[SerialNumber] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[SerialNumberYear] [int] NULL,
	[ParentDepartmentId] [int] NULL,
	[DepartmentTemplate] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Department] PRIMARY KEY CLUSTERED 
(
	[DepartmentId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department', N'COLUMN',N'DepartmentId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department', @level2type=N'COLUMN',@level2name=N'DepartmentId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department', N'COLUMN',N'DepartmentName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department', @level2type=N'COLUMN',@level2name=N'DepartmentName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department', N'COLUMN',N'CategoryName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属分类' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department', @level2type=N'COLUMN',@level2name=N'CategoryName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department', N'COLUMN',N'UploadDir'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上传文件目录' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department', @level2type=N'COLUMN',@level2name=N'UploadDir'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department', N'COLUMN',N'Number'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department', @level2type=N'COLUMN',@level2name=N'Number'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department', N'COLUMN',N'Priority'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门优先级' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department', @level2type=N'COLUMN',@level2name=N'Priority'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department', N'COLUMN',N'Template'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息公开部门模板路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department', @level2type=N'COLUMN',@level2name=N'Template'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department', N'COLUMN',N'Abbreviation'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门缩写名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department', @level2type=N'COLUMN',@level2name=N'Abbreviation'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department', N'COLUMN',N'SerialNumber'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'公开信息流水号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department', @level2type=N'COLUMN',@level2name=N'SerialNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department', N'COLUMN',N'SerialNumberYear'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'公开信息流水号-年份' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department', @level2type=N'COLUMN',@level2name=N'SerialNumberYear'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department', N'COLUMN',N'ParentDepartmentId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上级部门ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department', @level2type=N'COLUMN',@level2name=N'ParentDepartmentId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department', N'COLUMN',N'DepartmentTemplate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门信息模板页路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department', @level2type=N'COLUMN',@level2name=N'DepartmentTemplate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Department', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Department'
GO
/****** Object:  Table [dbo].[PE_DeliverType]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_DeliverType](
	[TypeID] [int] NOT NULL,
	[TypeName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Intro] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ChargeType] [int] NOT NULL,
	[IsDefault] [bit] NOT NULL,
	[IsDisabled] [bit] NOT NULL,
	[OrderID] [int] NOT NULL,
	[ReleaseType] [int] NOT NULL,
	[MinMoney1] [money] NULL,
	[ReleaseCharge] [money] NULL,
	[Minmoney2] [money] NULL,
	[MaxCharge] [money] NULL,
	[MinMoney3] [money] NULL,
	[Charge_Min] [money] NULL,
	[Charge_Max] [money] NULL,
	[Charge_Percent] [smallint] NULL,
	[IncludeTax] [int] NULL,
	[TaxRate] [float] NULL,
 CONSTRAINT [PK_PE_DeliverType_TypeID] PRIMARY KEY CLUSTERED 
(
	[TypeID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'TypeID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'送货方式ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'TypeID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'TypeName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'送货方式名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'TypeName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'Intro'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'送货方式简介' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'Intro'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'ChargeType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N' 运费类型 0为免费； 1为按重量计算运费； 2为按订单金额的百分比' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'ChargeType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'IsDefault'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否默认' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'IsDefault'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'IsDisabled'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否禁用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'IsDisabled'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'ReleaseType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'运费优惠方式， 0 为不优惠；　1 为优惠' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'ReleaseType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'MinMoney1'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠要求达到的 订单总金额1' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'MinMoney1'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'ReleaseCharge'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'达到总金额1 时免除的运费数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'ReleaseCharge'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'Minmoney2'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠要求达到的 订单总金额2' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'Minmoney2'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'MaxCharge'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'运费总额上限条件数目' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'MaxCharge'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'MinMoney3'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠要求达到的 订单总金额3' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'MinMoney3'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'Charge_Min'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'运费类型 = 为按订单金额的百分比 —— 基本运费' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'Charge_Min'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'Charge_Max'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'运费类型 = 为按订单金额的百分比 ——最高运费' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'Charge_Max'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'Charge_Percent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'运费类型 = 为按订单金额的百分比 ——百分比率' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'Charge_Percent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'IncludeTax'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否含税' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'IncludeTax'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', N'COLUMN',N'TaxRate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'税率' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType', @level2type=N'COLUMN',@level2name=N'TaxRate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverType', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'送货方式表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverType'
GO
/****** Object:  Table [dbo].[PE_DeliverItemDetails]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_DeliverItemDetails]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_DeliverItemDetails](
	[DeliverItemDetailsID] [int] NOT NULL,
	[DeliverID] [int] NULL,
	[ProductID] [int] NULL,
	[OrderID] [int] NULL,
	[ProductNum] [int] NULL,
	[Property] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_DeliverItemDetails] PRIMARY KEY CLUSTERED 
(
	[DeliverItemDetailsID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItemDetails', N'COLUMN',N'DeliverItemDetailsID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发货明细表ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItemDetails', @level2type=N'COLUMN',@level2name=N'DeliverItemDetailsID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItemDetails', N'COLUMN',N'DeliverID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发退货单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItemDetails', @level2type=N'COLUMN',@level2name=N'DeliverID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItemDetails', N'COLUMN',N'ProductID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItemDetails', @level2type=N'COLUMN',@level2name=N'ProductID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItemDetails', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItemDetails', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItemDetails', N'COLUMN',N'ProductNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发退货数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItemDetails', @level2type=N'COLUMN',@level2name=N'ProductNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItemDetails', N'COLUMN',N'Property'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品属性' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItemDetails', @level2type=N'COLUMN',@level2name=N'Property'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItemDetails', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发退货明细' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItemDetails'
GO
/****** Object:  Table [dbo].[PE_DeliverItem]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_DeliverItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_DeliverItem](
	[DeliverID] [int] NOT NULL,
	[OrderID] [int] NULL,
	[DeliverDate] [datetime] NULL,
	[DeliverDirection] [int] NULL,
	[HandlerName] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[CourierId] [int] NULL,
	[ExpressNumber] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Inputer] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Received] [bit] NOT NULL,
	[Memo] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_DeliverItem_DeliverID] PRIMARY KEY CLUSTERED 
(
	[DeliverID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_DeliverItem]') AND name = N'IX_PE_DeliverItem_OrderID')
CREATE NONCLUSTERED INDEX [IX_PE_DeliverItem_OrderID] ON [dbo].[PE_DeliverItem] 
(
	[OrderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItem', N'COLUMN',N'DeliverID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发退货记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItem', @level2type=N'COLUMN',@level2name=N'DeliverID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItem', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItem', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItem', N'COLUMN',N'DeliverDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发退货日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItem', @level2type=N'COLUMN',@level2name=N'DeliverDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItem', N'COLUMN',N'DeliverDirection'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'方向  1--发货  2--退货' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItem', @level2type=N'COLUMN',@level2name=N'DeliverDirection'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItem', N'COLUMN',N'HandlerName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'经手人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItem', @level2type=N'COLUMN',@level2name=N'HandlerName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItem', N'COLUMN',N'CourierId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'快递公司名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItem', @level2type=N'COLUMN',@level2name=N'CourierId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItem', N'COLUMN',N'ExpressNumber'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'快递单号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItem', @level2type=N'COLUMN',@level2name=N'ExpressNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItem', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItem', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItem', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItem', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItem', N'COLUMN',N'Received'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否已签收' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItem', @level2type=N'COLUMN',@level2name=N'Received'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItem', N'COLUMN',N'Memo'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内部记录' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItem', @level2type=N'COLUMN',@level2name=N'Memo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发退货记录表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverItem'
GO
/****** Object:  Table [dbo].[PE_DeliverCharge]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_DeliverCharge](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[DeliverTypeID] [int] NULL,
	[AreaType] [int] NULL,
	[arrArea] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Charge_Min] [money] NULL,
	[Weight_Min] [float] NULL,
	[ChargePerUnit] [money] NULL,
	[WeightPerUnit] [float] NULL,
	[Charge_Max] [money] NULL,
 CONSTRAINT [PK_PE_DeliverCharge_ID] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]') AND name = N'IX_PE_DeliverCharge_AreaType')
CREATE NONCLUSTERED INDEX [IX_PE_DeliverCharge_AreaType] ON [dbo].[PE_DeliverCharge] 
(
	[AreaType] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]') AND name = N'IX_PE_DeliverCharge_DeliverTypeID')
CREATE NONCLUSTERED INDEX [IX_PE_DeliverCharge_DeliverTypeID] ON [dbo].[PE_DeliverCharge] 
(
	[DeliverTypeID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverCharge', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverCharge', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverCharge', N'COLUMN',N'DeliverTypeID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'送货方式ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverCharge', @level2type=N'COLUMN',@level2name=N'DeliverTypeID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverCharge', N'COLUMN',N'AreaType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1为同城，
2为同一区域，
3为同省，
4为指定省份，
5为国际' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverCharge', @level2type=N'COLUMN',@level2name=N'AreaType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverCharge', N'COLUMN',N'arrArea'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'指定的区域或省份' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverCharge', @level2type=N'COLUMN',@level2name=N'arrArea'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverCharge', N'COLUMN',N'Charge_Min'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'基础运费' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverCharge', @level2type=N'COLUMN',@level2name=N'Charge_Min'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverCharge', N'COLUMN',N'Weight_Min'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'基础运费的起算重量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverCharge', @level2type=N'COLUMN',@level2name=N'Weight_Min'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverCharge', N'COLUMN',N'ChargePerUnit'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单位运费' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverCharge', @level2type=N'COLUMN',@level2name=N'ChargePerUnit'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverCharge', N'COLUMN',N'WeightPerUnit'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单位重量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverCharge', @level2type=N'COLUMN',@level2name=N'WeightPerUnit'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverCharge', N'COLUMN',N'Charge_Max'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最高运费' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverCharge', @level2type=N'COLUMN',@level2name=N'Charge_Max'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_DeliverCharge', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'运费表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_DeliverCharge'
GO
/****** Object:  Table [dbo].[PE_D_ProductSuite]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_D_ProductSuite]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_D_ProductSuite](
	[Id] [int] NOT NULL,
	[ProductId] [int] NULL,
	[GeneralId] [int] NULL,
	[Property] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_D_ProductSuite', N'COLUMN',N'Id'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品套装ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_D_ProductSuite', @level2type=N'COLUMN',@level2name=N'Id'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_D_ProductSuite', N'COLUMN',N'ProductId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_D_ProductSuite', @level2type=N'COLUMN',@level2name=N'ProductId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_D_ProductSuite', N'COLUMN',N'GeneralId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'要关联的商品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_D_ProductSuite', @level2type=N'COLUMN',@level2name=N'GeneralId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_D_ProductSuite', N'COLUMN',N'Property'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品属性' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_D_ProductSuite', @level2type=N'COLUMN',@level2name=N'Property'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_D_ProductSuite', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品套装表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_D_ProductSuite'
GO
/****** Object:  Table [dbo].[PE_Courier]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Courier]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Courier](
	[CourierId] [int] IDENTITY(1,1) NOT NULL,
	[ShortName] [nvarchar](64) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[FullName] [nvarchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[Address] [nvarchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Telephone] [nvarchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Contacter] [nvarchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[SearchUrl] [nvarchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[Status] [int] NULL,
	[OrderId] [int] NULL,
 CONSTRAINT [PK_PE_Courier_CourierId] PRIMARY KEY CLUSTERED 
(
	[CourierId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Courier', N'COLUMN',N'CourierId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'快递公司ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Courier', @level2type=N'COLUMN',@level2name=N'CourierId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Courier', N'COLUMN',N'ShortName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'快递公司缩写名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Courier', @level2type=N'COLUMN',@level2name=N'ShortName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Courier', N'COLUMN',N'FullName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'全称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Courier', @level2type=N'COLUMN',@level2name=N'FullName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Courier', N'COLUMN',N'Address'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Courier', @level2type=N'COLUMN',@level2name=N'Address'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Courier', N'COLUMN',N'Telephone'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'电话' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Courier', @level2type=N'COLUMN',@level2name=N'Telephone'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Courier', N'COLUMN',N'Contacter'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'联系人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Courier', @level2type=N'COLUMN',@level2name=N'Contacter'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Courier', N'COLUMN',N'SearchUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'快递查询接口' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Courier', @level2type=N'COLUMN',@level2name=N'SearchUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Courier', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0禁用 1启用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Courier', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Courier', N'COLUMN',N'OrderId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Courier', @level2type=N'COLUMN',@level2name=N'OrderId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Courier', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'快递公司表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Courier'
GO
/****** Object:  Table [dbo].[PE_CouponItem]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CouponItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_CouponItem](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[CouponID] [int] NULL,
	[CouponNum] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[GainOrderID] [int] NULL,
	[OrderID] [int] NULL,
	[GainDate] [datetime] NULL,
	[UseDate] [datetime] NULL,
	[Used] [bit] NULL,
 CONSTRAINT [PK_PE_CouponItem] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CouponItem', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠卷ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CouponItem', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CouponItem', N'COLUMN',N'CouponID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠券规则ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CouponItem', @level2type=N'COLUMN',@level2name=N'CouponID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CouponItem', N'COLUMN',N'CouponNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠券号码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CouponItem', @level2type=N'COLUMN',@level2name=N'CouponNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CouponItem', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CouponItem', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CouponItem', N'COLUMN',N'GainOrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'得到的订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CouponItem', @level2type=N'COLUMN',@level2name=N'GainOrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CouponItem', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'使用的订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CouponItem', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CouponItem', N'COLUMN',N'GainDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'得到时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CouponItem', @level2type=N'COLUMN',@level2name=N'GainDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CouponItem', N'COLUMN',N'UseDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'使用时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CouponItem', @level2type=N'COLUMN',@level2name=N'UseDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CouponItem', N'COLUMN',N'Used'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'使用状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CouponItem', @level2type=N'COLUMN',@level2name=N'Used'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CouponItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠卷表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CouponItem'
GO
/****** Object:  Table [dbo].[PE_Coupon]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Coupon]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Coupon](
	[CouponID] [int] NOT NULL,
	[CouponName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[CouponNumPattern] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Money] [money] NULL,
	[State] [int] NULL,
	[UserGroup] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[BeginDate] [datetime] NULL,
	[EndDate] [datetime] NULL,
	[ProductLimitType] [int] NULL,
	[ProductLimitContent] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[CouponCreateType] [int] NULL,
	[CouponCreateContent] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[OrderTotalMoney] [money] NULL,
	[UseBeginDate] [datetime] NULL,
	[UseEndDate] [datetime] NULL,
	[CouponItemNum] [int] NULL,
	[NoticeType] [int] NULL,
 CONSTRAINT [PK_PE_Coupon] PRIMARY KEY CLUSTERED 
(
	[CouponID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'CouponID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠券规则ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'CouponID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'CouponName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠券名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'CouponName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'CouponNumPattern'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠券号码生成格式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'CouponNumPattern'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'Money'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'面值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'Money'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'State'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'State'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'UserGroup'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'适用会员组' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'UserGroup'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'BeginDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'开始时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'BeginDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'EndDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'截止时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'EndDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'ProductLimitType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'限用商品类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'ProductLimitType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'ProductLimitContent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'限用商品' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'ProductLimitContent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'CouponCreateType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠券生成方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'CouponCreateType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'CouponCreateContent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠券生成条件内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'CouponCreateContent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'OrderTotalMoney'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'使用该优惠券需要的订单满足金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'OrderTotalMoney'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'UseBeginDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'使用开始时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'UseBeginDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'UseEndDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'使用截止时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'UseEndDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'CouponItemNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠卷张数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'CouponItemNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', N'COLUMN',N'NoticeType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'通知类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon', @level2type=N'COLUMN',@level2name=N'NoticeType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Coupon', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优惠卷规则表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Coupon'
GO
/****** Object:  Table [dbo].[PE_CorrelativeItems]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CorrelativeItems]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_CorrelativeItems](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[GeneralId] [int] NOT NULL,
	[CorrelativeGeneralId] [int] NOT NULL,
	[ModelId] [int] NOT NULL,
	[OrderId] [int] NOT NULL,
 CONSTRAINT [PK_PE_CorrelativeItems_ID] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CorrelativeItems', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CorrelativeItems', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CorrelativeItems', N'COLUMN',N'GeneralId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'要关联的编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CorrelativeItems', @level2type=N'COLUMN',@level2name=N'GeneralId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CorrelativeItems', N'COLUMN',N'CorrelativeGeneralId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关联对象的编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CorrelativeItems', @level2type=N'COLUMN',@level2name=N'CorrelativeGeneralId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CorrelativeItems', N'COLUMN',N'ModelId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CorrelativeItems', @level2type=N'COLUMN',@level2name=N'ModelId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CorrelativeItems', N'COLUMN',N'OrderId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CorrelativeItems', @level2type=N'COLUMN',@level2name=N'OrderId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CorrelativeItems', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据关联表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CorrelativeItems'
GO
/****** Object:  Table [dbo].[PE_ContentPermission]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ContentPermission]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ContentPermission](
	[GeneralID] [int] NOT NULL,
	[PermissionType] [int] NULL,
	[arrGroupID] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_ContentPermission] PRIMARY KEY CLUSTERED 
(
	[GeneralID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ContentPermission', N'COLUMN',N'GeneralID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ContentPermission', @level2type=N'COLUMN',@level2name=N'GeneralID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ContentPermission', N'COLUMN',N'PermissionType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'权限类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ContentPermission', @level2type=N'COLUMN',@level2name=N'PermissionType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ContentPermission', N'COLUMN',N'arrGroupID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户组数组' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ContentPermission', @level2type=N'COLUMN',@level2name=N'arrGroupID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ContentPermission', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容权限表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ContentPermission'
GO
/****** Object:  Table [dbo].[PE_ContentCharge]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ContentCharge]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ContentCharge](
	[GeneralID] [int] NOT NULL,
	[ChargeType] [int] NULL,
	[InfoPoint] [int] NULL,
	[PitchTime] [int] NULL,
	[ReadTimes] [int] NULL,
	[DividePercent] [int] NULL,
 CONSTRAINT [PK_PE_ContentCharge_GeneralID] PRIMARY KEY CLUSTERED 
(
	[GeneralID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ContentCharge', N'COLUMN',N'GeneralID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ContentCharge', @level2type=N'COLUMN',@level2name=N'GeneralID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ContentCharge', N'COLUMN',N'ChargeType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'重复收费方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ContentCharge', @level2type=N'COLUMN',@level2name=N'ChargeType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ContentCharge', N'COLUMN',N'InfoPoint'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'阅读点数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ContentCharge', @level2type=N'COLUMN',@level2name=N'InfoPoint'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ContentCharge', N'COLUMN',N'PitchTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'重复收费小时数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ContentCharge', @level2type=N'COLUMN',@level2name=N'PitchTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ContentCharge', N'COLUMN',N'ReadTimes'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'重复收费查看次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ContentCharge', @level2type=N'COLUMN',@level2name=N'ReadTimes'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ContentCharge', N'COLUMN',N'DividePercent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分成比例' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ContentCharge', @level2type=N'COLUMN',@level2name=N'DividePercent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ContentCharge', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'收费表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ContentCharge'
GO
/****** Object:  Table [dbo].[PE_Contacter]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Contacter]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Contacter](
	[ContacterID] [int] NOT NULL,
	[ClientID] [int] NULL,
	[ParentID] [int] NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[UserType] [int] NULL,
	[TrueName] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[Sex] [int] NULL,
	[Title] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Company] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Department] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Position] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Operation] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[CompanyAddress] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Homepage] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[QQ] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[ICQ] [nvarchar](25) COLLATE Chinese_PRC_CI_AS NULL,
	[MSN] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Yahoo] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[UC] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Aim] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[OfficePhone] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[HomePhone] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[PHS] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[Fax] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[Mobile] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[Country] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Province] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[City] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[Address] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ZipCode] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[NativePlace] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Nation] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Birthday] [datetime] NULL,
	[IDCard] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[Marriage] [int] NULL,
	[Family] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Income] [int] NULL,
	[Education] [int] NULL,
	[GraduateFrom] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[InterestsOfLife] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[InterestsOfCulture] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[InterestsOfAmusement] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[InterestsOfSport] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[InterestsOfOther] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[CreateTime] [datetime] NULL,
	[UpdateTime] [datetime] NULL,
	[Owner] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Contacter_ContacterID] PRIMARY KEY CLUSTERED 
(
	[ContacterID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Contacter]') AND name = N'IX_PE_Contacter_ClientID')
CREATE NONCLUSTERED INDEX [IX_PE_Contacter_ClientID] ON [dbo].[PE_Contacter] 
(
	[ClientID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'ContacterID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'联系人ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'ContacterID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'ClientID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'对应的客户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'ClientID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'ParentID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上级联系人ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'ParentID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'UserType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员类别  1--个人会员  其他--企业会员' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'UserType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'TrueName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'真实姓名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'TrueName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Sex'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'性别' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Sex'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Title'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'称谓，如王总，张老师，田部长' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Title'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Company'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单位名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Company'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Department'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属部门' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Department'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Position'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'职务' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Position'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Operation'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'负责业务' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Operation'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'CompanyAddress'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单位地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'CompanyAddress'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Email'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备用邮箱' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Email'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Homepage'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'相关网址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Homepage'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'QQ'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'QQ号码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'QQ'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'ICQ'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ICQ号码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'ICQ'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'MSN'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'MSN帐号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'MSN'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Yahoo'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'雅虎通帐号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Yahoo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'UC'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'UC帐号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'UC'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Aim'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Aim帐号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Aim'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'OfficePhone'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'办公电话' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'OfficePhone'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'HomePhone'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'住宅电话' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'HomePhone'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'PHS'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'小灵通' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'PHS'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Fax'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'传真号码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Fax'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Mobile'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'移动电话' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Mobile'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Country'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'国家/地区' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Country'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Province'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'省市/州郡' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Province'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'City'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'城市' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'City'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Address'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'联系地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Address'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'ZipCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮政编码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'ZipCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'NativePlace'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'籍贯' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'NativePlace'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Nation'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'民族' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Nation'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Birthday'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'出生日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Birthday'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'IDCard'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'证件号码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'IDCard'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Marriage'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'婚姻状况' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Marriage'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Family'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'家庭情况' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Family'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Income'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'月收入' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Income'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Education'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'学历' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Education'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'GraduateFrom'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'毕业学校' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'GraduateFrom'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'InterestsOfLife'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生活爱好' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'InterestsOfLife'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'InterestsOfCulture'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文化爱好' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'InterestsOfCulture'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'InterestsOfAmusement'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'娱乐休闲爱好' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'InterestsOfAmusement'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'InterestsOfSport'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'体育爱好' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'InterestsOfSport'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'InterestsOfOther'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'其他爱好' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'InterestsOfOther'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'CreateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'CreateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'UpdateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'UpdateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', N'COLUMN',N'Owner'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所有者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter', @level2type=N'COLUMN',@level2name=N'Owner'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Contacter', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'联系人表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Contacter'
GO
/****** Object:  Table [dbo].[PE_ComplainItem]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ComplainItem](
	[ItemID] [int] NOT NULL,
	[ClientID] [int] NULL,
	[ContacterID] [int] NULL,
	[ComplainType] [int] NULL,
	[ComplainMode] [int] NULL,
	[Title] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[FirstReceiver] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[DateAndTime] [datetime] NULL,
	[MagnitudeOfExigence] [int] NULL,
	[Process] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Processor] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Result] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[EndTime] [datetime] NULL,
	[Feedback] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ConfirmTime] [datetime] NULL,
	[ConfirmCaller] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ConfirmScore] [int] NULL,
	[ConfirmFeedback] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Status] [int] NULL,
	[CurrentOwner] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Defendant] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_ComplainItem_ItemID] PRIMARY KEY CLUSTERED 
(
	[ItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]') AND name = N'IX_PE_ComplainItem_ClientID')
CREATE NONCLUSTERED INDEX [IX_PE_ComplainItem_ClientID] ON [dbo].[PE_ComplainItem] 
(
	[ClientID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]') AND name = N'IX_PE_ComplainItem_ContacterID')
CREATE NONCLUSTERED INDEX [IX_PE_ComplainItem_ContacterID] ON [dbo].[PE_ComplainItem] 
(
	[ContacterID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'明细ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'ClientID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'ClientID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'ContacterID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'联系人ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'ContacterID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'ComplainType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投诉类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'ComplainType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'ComplainMode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投诉方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'ComplainMode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'Title'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投诉主题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'Title'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'Content'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投诉内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'Content'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'FirstReceiver'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'首问接待人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'FirstReceiver'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'DateAndTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投诉时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'DateAndTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'MagnitudeOfExigence'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'紧急程度' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'MagnitudeOfExigence'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'Process'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'处理过程' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'Process'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'Processor'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'处理人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'Processor'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'Result'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'处理结果' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'Result'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'EndTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'处理结束时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'EndTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'Feedback'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户反馈' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'Feedback'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'ConfirmTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回访时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'ConfirmTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'ConfirmCaller'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回访人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'ConfirmCaller'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'ConfirmScore'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户评定服务星级' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'ConfirmScore'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'ConfirmFeedback'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户反馈' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'ConfirmFeedback'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'记录状态，0为未处理，1为处理中，2为已处理，3为已回访' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'CurrentOwner'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'当前责任人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'CurrentOwner'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', N'COLUMN',N'Defendant'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'被投诉人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem', @level2type=N'COLUMN',@level2name=N'Defendant'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ComplainItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投诉表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ComplainItem'
GO
/****** Object:  Table [dbo].[PE_Company]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Company]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Company](
	[CompanyID] [int] NOT NULL,
	[ClientID] [int] NULL,
	[CompanyName] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
	[Country] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Province] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[City] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[Address] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ZipCode] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[Phone] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Fax] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[Homepage] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[BankOfDeposit] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[BankAccount] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[TaxNum] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[StatusInField] [int] NULL,
	[CompanySize] [int] NULL,
	[BusinessScope] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
	[AnnualSales] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ManagementForms] [int] NULL,
	[RegisteredCapital] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[CompanyIntro] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[CompanyPic] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Company_CompanyID] PRIMARY KEY CLUSTERED 
(
	[CompanyID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Company]') AND name = N'IX_PE_Company_ClientID')
CREATE NONCLUSTERED INDEX [IX_PE_Company_ClientID] ON [dbo].[PE_Company] 
(
	[ClientID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Company]') AND name = N'IX_PE_Company_TaxNum')
CREATE NONCLUSTERED INDEX [IX_PE_Company_TaxNum] ON [dbo].[PE_Company] 
(
	[TaxNum] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Company]') AND name = N'IX_PE_Company_ZipCode')
CREATE NONCLUSTERED INDEX [IX_PE_Company_ZipCode] ON [dbo].[PE_Company] 
(
	[ZipCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'CompanyID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'CompanyID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'ClientID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'对应客户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'ClientID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'CompanyName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单位名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'CompanyName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'Country'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'国家/地区' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'Country'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'Province'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'省市/州郡' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'Province'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'City'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'城市' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'City'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'Address'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'联系地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'Address'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'ZipCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮政编码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'ZipCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'Phone'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'电话' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'Phone'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'Fax'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'传真号码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'Fax'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'Homepage'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'相关网址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'Homepage'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'BankOfDeposit'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'开户银行' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'BankOfDeposit'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'BankAccount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'银行帐号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'BankAccount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'TaxNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'税号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'TaxNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'StatusInField'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'行业地位' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'StatusInField'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'CompanySize'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'公司规模' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'CompanySize'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'BusinessScope'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'业务范围' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'BusinessScope'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'AnnualSales'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'年销售额（万元）' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'AnnualSales'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'ManagementForms'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'经营状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'ManagementForms'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'RegisteredCapital'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'注册资本' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'RegisteredCapital'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'CompanyIntro'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'公司简介' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'CompanyIntro'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', N'COLUMN',N'CompanyPic'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'公司照片' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company', @level2type=N'COLUMN',@level2name=N'CompanyPic'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Company', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'公司表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Company'
GO
/****** Object:  Table [dbo].[PE_CommonProduct]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonProduct]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_CommonProduct](
	[ProductID] [int] NOT NULL,
	[TableName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductNum] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductType] [int] NULL,
	[Unit] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductThumb] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductPic] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ServiceTermUnit] [int] NULL,
	[ServiceTerm] [int] NULL,
	[Price] [money] NULL,
	[Price_Market] [money] NULL,
	[Price_Member] [money] NULL,
	[Price_Agent] [money] NULL,
	[EnableBuyWhenOutofstock] [bit] NULL,
	[EnableWholesale] [bit] NULL,
	[Price_Wholesale1] [money] NULL,
	[Price_Wholesale2] [money] NULL,
	[Price_Wholesale3] [money] NULL,
	[Number_Wholesale1] [int] NULL,
	[Number_Wholesale2] [int] NULL,
	[Number_Wholesale3] [int] NULL,
	[PresentID] [int] NULL,
	[PresentNumber] [int] NULL,
	[PresentPoint] [int] NULL,
	[PresentExp] [int] NULL,
	[PresentMoney] [money] NULL,
	[StocksProject] [int] NULL,
	[SalePromotionType] [int] NULL,
	[AlarmNum] [int] NULL,
	[BuyTimes] [int] NULL,
	[MinNumber] [int] NULL,
	[Discount] [float] NULL,
	[IncludeTax] [int] NULL,
	[TaxRate] [float] NULL,
	[Properties] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Weight] [float] NULL,
	[LimitNum] [int] NULL,
	[EnableSale] [bit] NULL,
	[EnableSingleSell] [bit] NULL,
	[ProductKind] [int] NULL,
	[DependentProducts] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Stocks] [int] NULL,
	[OrderNum] [int] NULL,
	[DownloadUrl] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[ProductCharacter] [int] NULL,
	[Keyword] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ProducerName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[TrademarkName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[BarCode] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductIntro] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductExplain] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IsNew] [bit] NULL,
	[IsHot] [bit] NULL,
	[IsBest] [bit] NULL,
	[Stars] [int] NULL,
	[Minimum] [int] NULL,
	[MultiplePhoto] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[ExpPrice] [money] NULL,
	[ExpMaxQuantity] [int] NULL,
	[SubTitle] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_CommonProduct_ID] PRIMARY KEY CLUSTERED 
(
	[ProductID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonProduct]') AND name = N'IX_PE_CommonProduct_AlarmNum')
CREATE NONCLUSTERED INDEX [IX_PE_CommonProduct_AlarmNum] ON [dbo].[PE_CommonProduct] 
(
	[AlarmNum] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonProduct]') AND name = N'IX_PE_CommonProduct_Keyword')
CREATE NONCLUSTERED INDEX [IX_PE_CommonProduct_Keyword] ON [dbo].[PE_CommonProduct] 
(
	[Keyword] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonProduct]') AND name = N'IX_PE_CommonProduct_LimitNum')
CREATE NONCLUSTERED INDEX [IX_PE_CommonProduct_LimitNum] ON [dbo].[PE_CommonProduct] 
(
	[LimitNum] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonProduct]') AND name = N'IX_PE_CommonProduct_OrderNum')
CREATE NONCLUSTERED INDEX [IX_PE_CommonProduct_OrderNum] ON [dbo].[PE_CommonProduct] 
(
	[OrderNum] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonProduct]') AND name = N'IX_PE_CommonProduct_PresentID')
CREATE NONCLUSTERED INDEX [IX_PE_CommonProduct_PresentID] ON [dbo].[PE_CommonProduct] 
(
	[PresentID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonProduct]') AND name = N'IX_PE_CommonProduct_ProducerName')
CREATE NONCLUSTERED INDEX [IX_PE_CommonProduct_ProducerName] ON [dbo].[PE_CommonProduct] 
(
	[ProducerName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ProductID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ProductID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'TableName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'表名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'TableName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ProductName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ProductName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ProductNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ProductNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ProductType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品状态 0--正常  3--特价　4--促销' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ProductType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Unit'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品单位' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Unit'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ProductThumb'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'缩略图' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ProductThumb'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ProductPic'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品大图' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ProductPic'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ServiceTermUnit'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务期限单位 0表示年，1表示月，2 表示日' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ServiceTermUnit'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ServiceTerm'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务期限' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ServiceTerm'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Price'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'零售价' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Price'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Price_Market'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'市场参考价' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Price_Market'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Price_Member'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员零售价' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Price_Member'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Price_Agent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'代理零售价' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Price_Agent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'EnableBuyWhenOutofstock'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'缺货时是否允许购买' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'EnableBuyWhenOutofstock'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'EnableWholesale'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否允许批发' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'EnableWholesale'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Price_Wholesale1'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'批发价1' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Price_Wholesale1'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Price_Wholesale2'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'批发价2' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Price_Wholesale2'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Price_Wholesale3'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'批发价3' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Price_Wholesale3'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Number_Wholesale1'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'次性购买此商品数量1' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Number_Wholesale1'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Number_Wholesale2'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'次性购买此商品数量2' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Number_Wholesale2'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Number_Wholesale3'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'次性购买此商品数量3' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Number_Wholesale3'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'PresentID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'赠品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'PresentID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'PresentNumber'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'促销赠送' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'PresentNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'PresentPoint'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'赠送点券' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'PresentPoint'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'PresentExp'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'购物积分' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'PresentExp'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'PresentMoney'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'返还的现金券' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'PresentMoney'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'StocksProject'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'库存报警方案 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'StocksProject'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'SalePromotionType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'促销设置' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'SalePromotionType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'AlarmNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'库存报警下限' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'AlarmNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'BuyTimes'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'购买次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'BuyTimes'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'MinNumber'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'促销购买商品最小值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'MinNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Discount'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'折扣率' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Discount'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'IncludeTax'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否包括税率' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'IncludeTax'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'TaxRate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'税率' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'TaxRate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Properties'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'属性' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Properties'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Weight'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品重量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Weight'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'LimitNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'限购数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'LimitNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'EnableSale'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否销售' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'EnableSale'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'EnableSingleSell'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否允许单独销售' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'EnableSingleSell'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ProductKind'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品类别' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ProductKind'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'DependentProducts'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'从属商品' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'DependentProducts'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Stocks'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'库存' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Stocks'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'OrderNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订购数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'OrderNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'DownloadUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'下载地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'DownloadUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'下载说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ProductCharacter'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品性质' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ProductCharacter'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Keyword'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Keyword'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ProducerName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'厂商' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ProducerName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'TrademarkName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商标' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'TrademarkName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'BarCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'条形码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'BarCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ProductIntro'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'简单介绍' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ProductIntro'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ProductExplain'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'详细介绍' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ProductExplain'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'IsNew'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否最新' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'IsNew'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'IsHot'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否热卖' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'IsHot'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'IsBest'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否精品' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'IsBest'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Stars'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品推荐等级' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Stars'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'Minimum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最低购买数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'Minimum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'MultiplePhoto'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'多图展示' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'MultiplePhoto'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ExpPrice'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品体验价' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ExpPrice'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'ExpMaxQuantity'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0--禁用体验功能，-1--不限体验限购数量，其他--体验限购数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'ExpMaxQuantity'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', N'COLUMN',N'SubTitle'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'副标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct', @level2type=N'COLUMN',@level2name=N'SubTitle'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonProduct', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品公共数据表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonProduct'
GO
/****** Object:  Table [dbo].[PE_CommonModel]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_CommonModel](
	[GeneralID] [int] NOT NULL,
	[NodeID] [int] NOT NULL,
	[ModelID] [int] NOT NULL,
	[ItemID] [int] NULL,
	[TableName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Title] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Inputer] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Hits] [int] NULL,
	[DayHits] [int] NULL,
	[WeekHits] [int] NULL,
	[MonthHits] [int] NULL,
	[LinkType] [int] NULL,
	[UpdateTime] [datetime] NULL,
	[CreateTime] [datetime] NULL,
	[TemplateFile] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Status] [int] NULL,
	[EliteLevel] [int] NULL,
	[Priority] [int] NULL,
	[CommentAudited] [int] NULL,
	[CommentUnAudited] [int] NULL,
	[SigninType] [int] NULL,
	[InputTime] [datetime] NULL,
	[PassedTime] [datetime] NULL,
	[Editor] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[LastHitTime] [datetime] NULL,
	[DefaultPicUrl] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[PinyinTitle] [nvarchar](1000) COLLATE Chinese_PRC_CI_AS NULL,
	[TitleFontColor] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[TitleFontType] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[IncludePic] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ShowCommentLink] [bit] NULL,
	[TitleHashKey] [decimal](32, 0) NULL,
	[HtmlPageName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[SGType] [int] NULL,
	[SGDataId] [int] NULL,
 CONSTRAINT [PK_PE_CommonModel_GeneralID] PRIMARY KEY CLUSTERED 
(
	[GeneralID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]') AND name = N'IX_PE_CommonModel_EliteLevel')
CREATE NONCLUSTERED INDEX [IX_PE_CommonModel_EliteLevel] ON [dbo].[PE_CommonModel] 
(
	[EliteLevel] DESC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]') AND name = N'IX_PE_CommonModel_ItemID')
CREATE NONCLUSTERED INDEX [IX_PE_CommonModel_ItemID] ON [dbo].[PE_CommonModel] 
(
	[ItemID] DESC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]') AND name = N'IX_PE_CommonModel_Priority')
CREATE NONCLUSTERED INDEX [IX_PE_CommonModel_Priority] ON [dbo].[PE_CommonModel] 
(
	[Priority] DESC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]') AND name = N'IX_PE_CommonModel_TitleHashKey')
CREATE NONCLUSTERED INDEX [IX_PE_CommonModel_TitleHashKey] ON [dbo].[PE_CommonModel] 
(
	[TitleHashKey] DESC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]') AND name = N'IX_PE_CommonModel_UpdateTime')
CREATE NONCLUSTERED INDEX [IX_PE_CommonModel_UpdateTime] ON [dbo].[PE_CommonModel] 
(
	[UpdateTime] DESC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'GeneralID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容全局ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'GeneralID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'NodeID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'NodeID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'ModelID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'ModelID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'相应表的记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'TableName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型表名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'TableName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'Title'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'Title'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'Hits'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'点击数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'Hits'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'DayHits'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'日点击数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'DayHits'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'WeekHits'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'周点击数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'WeekHits'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'MonthHits'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'月点击数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'MonthHits'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'LinkType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'链接类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'LinkType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'UpdateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'UpdateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'CreateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生成时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'CreateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'TemplateFile'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'该文章所使用的模板路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'TemplateFile'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息状态 -3为删除，-2为退稿，-1为草稿，0为待审核，99为终审通过，其它为自定义' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'EliteLevel'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'推荐级别' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'EliteLevel'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'Priority'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'优先级别' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'Priority'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'CommentAudited'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'通过审核的评论总数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'CommentAudited'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'CommentUnAudited'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'未通过审核的评论总数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'CommentUnAudited'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'SigninType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'签收类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'SigninType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'InputTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文章录入时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'InputTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'PassedTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'审核通过时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'PassedTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'Editor'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编辑' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'Editor'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'LastHitTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上次点击时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'LastHitTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'DefaultPicUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'默认首页图片' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'DefaultPicUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'PinyinTitle'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'拼音标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'PinyinTitle'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'TitleFontColor'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标题字体颜色' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'TitleFontColor'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'TitleFontType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标题字形' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'TitleFontType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'IncludePic'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标题前缀  1--[图文]  2--[组图]  3--[推荐]  4--[注意]' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'IncludePic'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'ShowCommentLink'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列表显示时是否在标题旁显示“评论”链接' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'ShowCommentLink'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'TitleHashKey'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标题Hash值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'TitleHashKey'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'HtmlPageName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'静态页名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'HtmlPageName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'SGType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'站群信息类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'SGType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', N'COLUMN',N'SGDataId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'站群数据ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel', @level2type=N'COLUMN',@level2name=N'SGDataId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommonModel', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型公共数据表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommonModel'
GO
/****** Object:  Table [dbo].[PE_CommentPK]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommentPK]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_CommentPK](
	[PKID] [int] NOT NULL,
	[CommentID] [int] NULL,
	[Title] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IP] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[UpdateTime] [datetime] NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Position] [int] NULL,
 CONSTRAINT [PK_PE_CommentPK_PKID] PRIMARY KEY CLUSTERED 
(
	[PKID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CommentPK]') AND name = N'IX_PE_CommentPK_CommentID')
CREATE NONCLUSTERED INDEX [IX_PE_CommentPK_CommentID] ON [dbo].[PE_CommentPK] 
(
	[CommentID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommentPK', N'COLUMN',N'PKID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'辩论ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommentPK', @level2type=N'COLUMN',@level2name=N'PKID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommentPK', N'COLUMN',N'CommentID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N' 评论ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommentPK', @level2type=N'COLUMN',@level2name=N'CommentID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommentPK', N'COLUMN',N'Title'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N' 评论标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommentPK', @level2type=N'COLUMN',@level2name=N'Title'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommentPK', N'COLUMN',N'Content'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommentPK', @level2type=N'COLUMN',@level2name=N'Content'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommentPK', N'COLUMN',N'IP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommentPK', @level2type=N'COLUMN',@level2name=N'IP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommentPK', N'COLUMN',N'UpdateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommentPK', @level2type=N'COLUMN',@level2name=N'UpdateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommentPK', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommentPK', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommentPK', N'COLUMN',N'Position'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'观点 0中立，1赞同，-1反对' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommentPK', @level2type=N'COLUMN',@level2name=N'Position'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CommentPK', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论PK表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CommentPK'
GO
/****** Object:  Table [dbo].[PE_Comment]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Comment]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Comment](
	[CommentID] [int] NOT NULL,
	[GeneralID] [int] NULL,
	[NodeID] [int] NULL,
	[TopicID] [int] NULL,
	[CommentTitle] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Face] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[UpdateTime] [datetime] NULL,
	[Position] [int] NULL,
	[Status] [bit] NULL,
	[Agree] [int] NULL,
	[Oppose] [int] NULL,
	[Neutral] [int] NULL,
	[Score] [int] NULL,
	[IP] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[IsElite] [bit] NULL,
	[IsPrivate] [bit] NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Reply] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[ReplyAdmin] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ReplyDatetime] [datetime] NULL,
	[ReplyIsPrivate] [bit] NULL,
	[ReplyUserName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[CommentType] [int] NULL,
	[WapId] [int] NULL,
	[ReferenceId] [int] NULL,
	[IsTop] [bit] NULL,
 CONSTRAINT [PK_PE_Comment_CommentID] PRIMARY KEY CLUSTERED 
(
	[CommentID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Comment]') AND name = N'IX_PE_Comment_GeneralID')
CREATE NONCLUSTERED INDEX [IX_PE_Comment_GeneralID] ON [dbo].[PE_Comment] 
(
	[GeneralID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Comment]') AND name = N'IX_PE_Comment_NodeID')
CREATE NONCLUSTERED INDEX [IX_PE_Comment_NodeID] ON [dbo].[PE_Comment] 
(
	[NodeID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'CommentID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'CommentID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'GeneralID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'GeneralID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'NodeID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'节点ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'NodeID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'TopicID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'在评论表中的主题ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'TopicID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'CommentTitle'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'CommentTitle'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'Email'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'电子邮件' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'Email'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'Content'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'Content'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'Face'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'表情' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'Face'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'UpdateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发表评论时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'UpdateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'Position'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发表评论观点
0中立，1赞同，-1反对
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'Position'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论状态，是否通过审核' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'Agree'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'当前评论的支持数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'Agree'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'Oppose'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'当前评论的反对数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'Oppose'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'Neutral'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'当前评论的中立数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'Neutral'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'Score'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评分' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'Score'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'IP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'IP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'IsElite'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否精华' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'IsElite'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'IsPrivate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'该评论是否可以公开（是否只有管理员可以看到）' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'IsPrivate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'Reply'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员回复内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'Reply'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'ReplyAdmin'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回复管理员' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'ReplyAdmin'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'ReplyDatetime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回复时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'ReplyDatetime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'ReplyIsPrivate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回复是否隐藏' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'ReplyIsPrivate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'ReplyUserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回复用户名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'ReplyUserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'CommentType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论类别  1-网站用户2-手机用户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'CommentType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'WapId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'WAP内容ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'WapId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'ReferenceId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论引用ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'ReferenceId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', N'COLUMN',N'IsTop'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否置顶' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment', @level2type=N'COLUMN',@level2name=N'IsTop'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Comment', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Comment'
GO
/****** Object:  Table [dbo].[PE_CollectionPagingRules]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionPagingRules]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_CollectionPagingRules](
	[PagingRuleID] [int] NOT NULL,
	[ItemID] [int] NOT NULL,
	[RuleType] [int] NOT NULL,
	[PagingType] [int] NOT NULL,
	[PagingBeginCode] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[PagingEndCode] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[LinkBeginCode] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[LinkEndCode] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[DesignatedUrl] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[ScopeBegin] [int] NULL,
	[ScopeEnd] [int] NULL,
	[PagingUrlList] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[CorrelationRuleId] [int] NULL,
 CONSTRAINT [PK_PE_CollectionPagingRules] PRIMARY KEY CLUSTERED 
(
	[PagingRuleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionPagingRules', N'COLUMN',N'PagingRuleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集分页ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionPagingRules', @level2type=N'COLUMN',@level2name=N'PagingRuleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionPagingRules', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集项目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionPagingRules', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionPagingRules', N'COLUMN',N'RuleType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'规则类型，0为列表页的分页规则，1为字段的分页规则' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionPagingRules', @level2type=N'COLUMN',@level2name=N'RuleType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionPagingRules', N'COLUMN',N'PagingType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分页类型，1为“下一页”，2从源代码中获取分页URL，3为指定URL，4为手动添加' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionPagingRules', @level2type=N'COLUMN',@level2name=N'PagingType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionPagingRules', N'COLUMN',N'PagingBeginCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分页开始代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionPagingRules', @level2type=N'COLUMN',@level2name=N'PagingBeginCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionPagingRules', N'COLUMN',N'PagingEndCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分页结束代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionPagingRules', @level2type=N'COLUMN',@level2name=N'PagingEndCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionPagingRules', N'COLUMN',N'LinkBeginCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'链接开始代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionPagingRules', @level2type=N'COLUMN',@level2name=N'LinkBeginCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionPagingRules', N'COLUMN',N'LinkEndCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'链接结束代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionPagingRules', @level2type=N'COLUMN',@level2name=N'LinkEndCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionPagingRules', N'COLUMN',N'DesignatedUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'指定URL 地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionPagingRules', @level2type=N'COLUMN',@level2name=N'DesignatedUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionPagingRules', N'COLUMN',N'ScopeBegin'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'范围开始' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionPagingRules', @level2type=N'COLUMN',@level2name=N'ScopeBegin'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionPagingRules', N'COLUMN',N'ScopeEnd'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'范围结束' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionPagingRules', @level2type=N'COLUMN',@level2name=N'ScopeEnd'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionPagingRules', N'COLUMN',N'PagingUrlList'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'手工指定分页URL列表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionPagingRules', @level2type=N'COLUMN',@level2name=N'PagingUrlList'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionPagingRules', N'COLUMN',N'CorrelationRuleId'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集类别ID 列表 内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionPagingRules', @level2type=N'COLUMN',@level2name=N'CorrelationRuleId'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionPagingRules', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集分页规则表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionPagingRules'
GO
/****** Object:  Table [dbo].[PE_CollectionListRules]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionListRules]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_CollectionListRules](
	[ItemID] [int] NOT NULL,
	[ListBeginCode] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[ListEndCode] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[LinkBeginCode] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[LinkEndCode] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IsLinkSpecialSolution] [bit] NULL,
	[RedirectUrl] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[UsePaging] [bit] NOT NULL
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionListRules', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集项目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionListRules', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionListRules', N'COLUMN',N'ListBeginCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列表开始代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionListRules', @level2type=N'COLUMN',@level2name=N'ListBeginCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionListRules', N'COLUMN',N'ListEndCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列表结束代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionListRules', @level2type=N'COLUMN',@level2name=N'ListEndCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionListRules', N'COLUMN',N'LinkBeginCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'链接开始代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionListRules', @level2type=N'COLUMN',@level2name=N'LinkBeginCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionListRules', N'COLUMN',N'LinkEndCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'链接结束代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionListRules', @level2type=N'COLUMN',@level2name=N'LinkEndCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionListRules', N'COLUMN',N'IsLinkSpecialSolution'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否链接特殊处理' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionListRules', @level2type=N'COLUMN',@level2name=N'IsLinkSpecialSolution'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionListRules', N'COLUMN',N'RedirectUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'重定向URL' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionListRules', @level2type=N'COLUMN',@level2name=N'RedirectUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionListRules', N'COLUMN',N'UsePaging'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否采集分页' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionListRules', @level2type=N'COLUMN',@level2name=N'UsePaging'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionListRules', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集列表规则表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionListRules'
GO
/****** Object:  Table [dbo].[PE_CollectionItem]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_CollectionItem](
	[ItemID] [int] NOT NULL,
	[ItemName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[UrlName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[CodeType] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Url] [ntext] COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Intro] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[NodeID] [int] NOT NULL,
	[InfoNodeID] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ModelID] [int] NOT NULL,
	[SpecialID] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[OrderType] [int] NOT NULL,
	[MaxNum] [int] NULL,
	[NewsCollecDate] [datetime] NULL,
	[Detection] [bit] NULL,
	[AutoCreateHtml] [bit] NULL,
 CONSTRAINT [PK_PE_CollectionItem] PRIMARY KEY CLUSTERED 
(
	[ItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集项目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'ItemName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'ItemName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'UrlName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集网站名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'UrlName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'CodeType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编码类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'CodeType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'Url'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'Url'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'Intro'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集简介' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'Intro'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'NodeID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'栏目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'NodeID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'InfoNodeID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'虚栏目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'InfoNodeID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'ModelID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'ModelID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'SpecialID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专题ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'SpecialID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'OrderType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集顺序　0　正续　1　倒续' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'OrderType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'MaxNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'指定采集数量　不指定为全部　' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'MaxNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'NewsCollecDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后一次采集时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'NewsCollecDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'Detection'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否测试通过' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'Detection'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', N'COLUMN',N'AutoCreateHtml'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否自动生成HTML' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem', @level2type=N'COLUMN',@level2name=N'AutoCreateHtml'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集项目表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionItem'
GO
/****** Object:  Table [dbo].[PE_CollectionHistory]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionHistory]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_CollectionHistory](
	[HistoryID] [int] NOT NULL,
	[ItemID] [int] NULL,
	[ModelID] [int] NULL,
	[NodeID] [int] NULL,
	[GeneralID] [int] NULL,
	[Title] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[CollectionTime] [datetime] NULL,
	[Result] [int] NULL,
	[NewsUrl] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_CollectionHistory] PRIMARY KEY CLUSTERED 
(
	[HistoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionHistory]') AND name = N'IX_PE_CollectionHistory_GeneralID')
CREATE NONCLUSTERED INDEX [IX_PE_CollectionHistory_GeneralID] ON [dbo].[PE_CollectionHistory] 
(
	[GeneralID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionHistory]') AND name = N'IX_PE_CollectionHistory_ItemID')
CREATE NONCLUSTERED INDEX [IX_PE_CollectionHistory_ItemID] ON [dbo].[PE_CollectionHistory] 
(
	[ItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionHistory]') AND name = N'IX_PE_CollectionHistory_ModelID')
CREATE NONCLUSTERED INDEX [IX_PE_CollectionHistory_ModelID] ON [dbo].[PE_CollectionHistory] 
(
	[ModelID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionHistory]') AND name = N'IX_PE_CollectionHistory_NodeID')
CREATE NONCLUSTERED INDEX [IX_PE_CollectionHistory_NodeID] ON [dbo].[PE_CollectionHistory] 
(
	[NodeID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionHistory', N'COLUMN',N'HistoryID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集历史记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionHistory', @level2type=N'COLUMN',@level2name=N'HistoryID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionHistory', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionHistory', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionHistory', N'COLUMN',N'ModelID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模型ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionHistory', @level2type=N'COLUMN',@level2name=N'ModelID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionHistory', N'COLUMN',N'NodeID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'栏目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionHistory', @level2type=N'COLUMN',@level2name=N'NodeID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionHistory', N'COLUMN',N'GeneralID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'文章ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionHistory', @level2type=N'COLUMN',@level2name=N'GeneralID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionHistory', N'COLUMN',N'Title'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionHistory', @level2type=N'COLUMN',@level2name=N'Title'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionHistory', N'COLUMN',N'CollectionTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionHistory', @level2type=N'COLUMN',@level2name=N'CollectionTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionHistory', N'COLUMN',N'Result'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集状态（成功，失败）' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionHistory', @level2type=N'COLUMN',@level2name=N'Result'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionHistory', N'COLUMN',N'NewsUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集URL' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionHistory', @level2type=N'COLUMN',@level2name=N'NewsUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionHistory', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionHistory', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionHistory', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集历史记录表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionHistory'
GO
/****** Object:  Table [dbo].[PE_CollectionFilterRules]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionFilterRules]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_CollectionFilterRules](
	[FilterRuleID] [int] NOT NULL,
	[FilterName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[FilterType] [int] NOT NULL,
	[BeginCode] [ntext] COLLATE Chinese_PRC_CI_AS NOT NULL,
	[EndCode] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Replace] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_CollectionFilterRules] PRIMARY KEY CLUSTERED 
(
	[FilterRuleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFilterRules', N'COLUMN',N'FilterRuleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'过滤规则ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFilterRules', @level2type=N'COLUMN',@level2name=N'FilterRuleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFilterRules', N'COLUMN',N'FilterName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'过滤名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFilterRules', @level2type=N'COLUMN',@level2name=N'FilterName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFilterRules', N'COLUMN',N'FilterType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'过滤类型　1　普通替换　2　截取替换  3为正则过滤' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFilterRules', @level2type=N'COLUMN',@level2name=N'FilterType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFilterRules', N'COLUMN',N'BeginCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'过滤开始代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFilterRules', @level2type=N'COLUMN',@level2name=N'BeginCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFilterRules', N'COLUMN',N'EndCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'过滤结束代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFilterRules', @level2type=N'COLUMN',@level2name=N'EndCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFilterRules', N'COLUMN',N'Replace'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'替换值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFilterRules', @level2type=N'COLUMN',@level2name=N'Replace'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFilterRules', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集过滤规则表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFilterRules'
GO
/****** Object:  Table [dbo].[PE_CollectionFieldRules]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionFieldRules]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_CollectionFieldRules](
	[FieldRuleID] [int] NOT NULL,
	[ItemID] [int] NOT NULL,
	[FieldName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[FieldType] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[RuleType] [int] NOT NULL,
	[BeginCode] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[EndCode] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[PrivateFilter] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[FilterRuleID] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[UsePaging] [bit] NULL,
	[SpecialSetting] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[ExclosionID] [int] NULL,
 CONSTRAINT [PK_PE_CollectionFieldRules] PRIMARY KEY CLUSTERED 
(
	[FieldRuleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFieldRules', N'COLUMN',N'FieldRuleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段规则ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFieldRules', @level2type=N'COLUMN',@level2name=N'FieldRuleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFieldRules', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集项目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFieldRules', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFieldRules', N'COLUMN',N'FieldName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFieldRules', @level2type=N'COLUMN',@level2name=N'FieldName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFieldRules', N'COLUMN',N'FieldType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFieldRules', @level2type=N'COLUMN',@level2name=N'FieldType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFieldRules', N'COLUMN',N'RuleType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0 默认  1 指定 2　从HTML获取 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFieldRules', @level2type=N'COLUMN',@level2name=N'RuleType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFieldRules', N'COLUMN',N'BeginCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'开始代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFieldRules', @level2type=N'COLUMN',@level2name=N'BeginCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFieldRules', N'COLUMN',N'EndCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'结束代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFieldRules', @level2type=N'COLUMN',@level2name=N'EndCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFieldRules', N'COLUMN',N'PrivateFilter'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'过滤项目 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFieldRules', @level2type=N'COLUMN',@level2name=N'PrivateFilter'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFieldRules', N'COLUMN',N'FilterRuleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'过滤规则ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFieldRules', @level2type=N'COLUMN',@level2name=N'FilterRuleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFieldRules', N'COLUMN',N'UsePaging'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否采集分页 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFieldRules', @level2type=N'COLUMN',@level2name=N'UsePaging'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFieldRules', N'COLUMN',N'SpecialSetting'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'特别设置' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFieldRules', @level2type=N'COLUMN',@level2name=N'SpecialSetting'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFieldRules', N'COLUMN',N'ExclosionID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排除关联ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFieldRules', @level2type=N'COLUMN',@level2name=N'ExclosionID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionFieldRules', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集字段规则表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionFieldRules'
GO
/****** Object:  Table [dbo].[PE_CollectionExclosion]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_CollectionExclosion]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_CollectionExclosion](
	[ExclosionID] [int] NOT NULL,
	[ExclosionName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ExclosionType] [int] NOT NULL,
	[ExclosionStringType] [int] NULL,
	[ExclosionString] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IsExclosionDesignatedNumber] [bit] NULL,
	[ExclosionDesignatedNumber] [int] NULL,
	[IsExclosionMaxNumber] [bit] NULL,
	[ExclosionMaxNumber] [int] NULL,
	[IsExclosionMinNumber] [bit] NULL,
	[ExclosionMinNumber] [int] NULL,
	[IsExclosionDesignatedDateTime] [bit] NULL,
	[ExclosionDesignatedDateTime] [datetime] NULL,
	[IsExclosionMaxDateTime] [bit] NULL,
	[ExclosionMaxDateTime] [datetime] NULL,
	[IsExclosionMinDateTime] [bit] NULL,
	[ExclosionMinDateTime] [datetime] NULL,
 CONSTRAINT [PK_PE_CollectionExclosion] PRIMARY KEY CLUSTERED 
(
	[ExclosionID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'ExclosionID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排除ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'ExclosionID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'ExclosionName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排除名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'ExclosionName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'ExclosionType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排除类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'ExclosionType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'ExclosionStringType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排除字符类别' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'ExclosionStringType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'ExclosionString'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排除字符' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'ExclosionString'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'IsExclosionDesignatedNumber'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否排除指定数字' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'IsExclosionDesignatedNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'ExclosionDesignatedNumber'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排除指定数字' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'ExclosionDesignatedNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'IsExclosionMaxNumber'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否排除大于数字' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'IsExclosionMaxNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'ExclosionMaxNumber'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排除大于数字' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'ExclosionMaxNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'IsExclosionMinNumber'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否排除小于数字' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'IsExclosionMinNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'ExclosionMinNumber'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排除小于数字' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'ExclosionMinNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'IsExclosionDesignatedDateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否排除指定时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'IsExclosionDesignatedDateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'ExclosionDesignatedDateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排除指定时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'ExclosionDesignatedDateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'IsExclosionMaxDateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否排除大于时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'IsExclosionMaxDateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'ExclosionMaxDateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排除大于时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'ExclosionMaxDateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'IsExclosionMinDateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否排除小于时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'IsExclosionMinDateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', N'COLUMN',N'ExclosionMinDateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排除小于时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion', @level2type=N'COLUMN',@level2name=N'ExclosionMinDateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_CollectionExclosion', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集内容排除表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_CollectionExclosion'
GO
/****** Object:  Table [dbo].[PE_ClientItem]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ClientItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ClientItem](
	[ID] [int] NOT NULL,
	[Seller] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ClientID] [int] NULL,
	[ItemStatus] [int] NULL,
	[ItemPrice] [int] NULL,
	[EstimatDate] [datetime] NULL,
	[SalesESRatio] [int] NULL,
	[ManagerESRatio] [int] NULL,
	[Remark] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_ClientItem] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientItem', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientItem', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientItem', N'COLUMN',N'Seller'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'销售员' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientItem', @level2type=N'COLUMN',@level2name=N'Seller'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientItem', N'COLUMN',N'ClientID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientItem', @level2type=N'COLUMN',@level2name=N'ClientID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientItem', N'COLUMN',N'ItemStatus'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientItem', @level2type=N'COLUMN',@level2name=N'ItemStatus'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientItem', N'COLUMN',N'ItemPrice'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目预算' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientItem', @level2type=N'COLUMN',@level2name=N'ItemPrice'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientItem', N'COLUMN',N'EstimatDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'预计签单日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientItem', @level2type=N'COLUMN',@level2name=N'EstimatDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientItem', N'COLUMN',N'SalesESRatio'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'销售预测成功率' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientItem', @level2type=N'COLUMN',@level2name=N'SalesESRatio'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientItem', N'COLUMN',N'ManagerESRatio'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'经理预测成功率' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientItem', @level2type=N'COLUMN',@level2name=N'ManagerESRatio'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientItem', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientItem', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户项目表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientItem'
GO
/****** Object:  Table [dbo].[PE_ClientHistoryItem]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ClientHistoryItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ClientHistoryItem](
	[ItemID] [int] NOT NULL,
	[ClientHistoryID] [int] NOT NULL,
	[FieldName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[OldValue] [nvarchar](4000) COLLATE Chinese_PRC_CI_AS NULL,
	[NewValue] [nvarchar](4000) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_ClientHistoryItem] PRIMARY KEY CLUSTERED 
(
	[ItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientHistoryItem', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'历史记录明细ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientHistoryItem', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientHistoryItem', N'COLUMN',N'ClientHistoryID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户历史记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientHistoryItem', @level2type=N'COLUMN',@level2name=N'ClientHistoryID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientHistoryItem', N'COLUMN',N'FieldName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientHistoryItem', @level2type=N'COLUMN',@level2name=N'FieldName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientHistoryItem', N'COLUMN',N'OldValue'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'旧值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientHistoryItem', @level2type=N'COLUMN',@level2name=N'OldValue'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientHistoryItem', N'COLUMN',N'NewValue'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'新值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientHistoryItem', @level2type=N'COLUMN',@level2name=N'NewValue'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientHistoryItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户历史记录详情表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientHistoryItem'
GO
/****** Object:  Table [dbo].[PE_ClientHistory]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ClientHistory]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ClientHistory](
	[ClientHistoryID] [int] NOT NULL,
	[ClientID] [int] NULL,
	[ActionName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ActionTime] [datetime] NULL,
	[UserIP] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_ClientHistory] PRIMARY KEY CLUSTERED 
(
	[ClientHistoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientHistory', N'COLUMN',N'ClientHistoryID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户记录编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientHistory', @level2type=N'COLUMN',@level2name=N'ClientHistoryID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientHistory', N'COLUMN',N'ClientID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientHistory', @level2type=N'COLUMN',@level2name=N'ClientID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientHistory', N'COLUMN',N'ActionName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientHistory', @level2type=N'COLUMN',@level2name=N'ActionName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientHistory', N'COLUMN',N'ActionTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientHistory', @level2type=N'COLUMN',@level2name=N'ActionTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientHistory', N'COLUMN',N'UserIP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientHistory', @level2type=N'COLUMN',@level2name=N'UserIP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientHistory', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作员名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientHistory', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientHistory', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientHistory', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientHistory', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户历史记录表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientHistory'
GO
/****** Object:  Table [dbo].[PE_ClientConfirm]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ClientConfirm]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ClientConfirm](
	[ID] [int] NOT NULL,
	[ClientName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ClientConfirmWay] [int] NULL,
	[ClientConfirmType] [int] NULL,
	[ClientConfirmTime] [datetime] NULL,
	[AdminName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Inputer] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Resualt] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Progress] [int] NULL,
	[RecordType] [int] NULL,
	[Record] [nvarchar](500) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_ClientConfirm] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientConfirm', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientConfirm', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientConfirm', N'COLUMN',N'ClientName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientConfirm', @level2type=N'COLUMN',@level2name=N'ClientName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientConfirm', N'COLUMN',N'ClientConfirmWay'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回访方式 电话、QQ、MSN等' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientConfirm', @level2type=N'COLUMN',@level2name=N'ClientConfirmWay'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientConfirm', N'COLUMN',N'ClientConfirmType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回访类型 投诉、满意调查等' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientConfirm', @level2type=N'COLUMN',@level2name=N'ClientConfirmType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientConfirm', N'COLUMN',N'ClientConfirmTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回访时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientConfirm', @level2type=N'COLUMN',@level2name=N'ClientConfirmTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientConfirm', N'COLUMN',N'AdminName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回访人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientConfirm', @level2type=N'COLUMN',@level2name=N'AdminName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientConfirm', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientConfirm', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientConfirm', N'COLUMN',N'Resualt'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回访结果' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientConfirm', @level2type=N'COLUMN',@level2name=N'Resualt'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientConfirm', N'COLUMN',N'Progress'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回访进度' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientConfirm', @level2type=N'COLUMN',@level2name=N'Progress'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientConfirm', N'COLUMN',N'RecordType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'结果类型 0客户的意见、1客户的建议' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientConfirm', @level2type=N'COLUMN',@level2name=N'RecordType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientConfirm', N'COLUMN',N'Record'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回访结果' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientConfirm', @level2type=N'COLUMN',@level2name=N'Record'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientConfirm', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户回访表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientConfirm'
GO
/****** Object:  Table [dbo].[PE_ClientAssist]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ClientAssist]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ClientAssist](
	[AssistID] [int] NOT NULL,
	[ClientID] [int] NOT NULL,
	[AdminID] [int] NOT NULL,
 CONSTRAINT [PK_PE_ClientAssist] PRIMARY KEY CLUSTERED 
(
	[AssistID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientAssist', N'COLUMN',N'AssistID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'协销ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientAssist', @level2type=N'COLUMN',@level2name=N'AssistID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientAssist', N'COLUMN',N'ClientID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientAssist', @level2type=N'COLUMN',@level2name=N'ClientID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientAssist', N'COLUMN',N'AdminID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientAssist', @level2type=N'COLUMN',@level2name=N'AdminID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientAssist', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户协销表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientAssist'
GO
/****** Object:  Table [dbo].[PE_ClientAnnal]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_ClientAnnal]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_ClientAnnal](
	[ClientAnnalID] [int] NOT NULL,
	[ClientID] [int] NOT NULL,
	[RelationType] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[RelationTime] [datetime] NULL,
	[Contacter] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[AnnalContent] [nvarchar](1000) COLLATE Chinese_PRC_CI_AS NULL,
	[AnnalTime] [datetime] NULL,
	[Inputer] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_ClientAnnal] PRIMARY KEY CLUSTERED 
(
	[ClientAnnalID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientAnnal', N'COLUMN',N'ClientAnnalID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户记录ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientAnnal', @level2type=N'COLUMN',@level2name=N'ClientAnnalID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientAnnal', N'COLUMN',N'ClientID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientAnnal', @level2type=N'COLUMN',@level2name=N'ClientID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientAnnal', N'COLUMN',N'RelationType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'联系方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientAnnal', @level2type=N'COLUMN',@level2name=N'RelationType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientAnnal', N'COLUMN',N'RelationTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'联系时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientAnnal', @level2type=N'COLUMN',@level2name=N'RelationTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientAnnal', N'COLUMN',N'Contacter'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'联系人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientAnnal', @level2type=N'COLUMN',@level2name=N'Contacter'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientAnnal', N'COLUMN',N'AnnalContent'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'记录内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientAnnal', @level2type=N'COLUMN',@level2name=N'AnnalContent'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientAnnal', N'COLUMN',N'AnnalTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'记录时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientAnnal', @level2type=N'COLUMN',@level2name=N'AnnalTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientAnnal', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'记录人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientAnnal', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_ClientAnnal', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户联系记录表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_ClientAnnal'
GO
/****** Object:  Table [dbo].[PE_Client]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Client]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Client](
	[ClientID] [int] NOT NULL,
	[ParentID] [int] NULL,
	[ClientNum] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[ClientType] [int] NULL,
	[ClientName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[ShortedForm] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[Area] [int] NULL,
	[ClientField] [int] NULL,
	[ValueLevel] [int] NULL,
	[CreditLevel] [int] NULL,
	[Importance] [int] NULL,
	[ConnectionLevel] [int] NULL,
	[GroupID] [int] NULL,
	[SourceType] [int] NULL,
	[PhaseType] [int] NULL,
	[Remark] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[VisitTimes] [int] NULL,
	[ServiceTimes] [int] NULL,
	[ComplainTimes] [int] NULL,
	[LastVisitTime] [datetime] NULL,
	[LastServiceTime] [datetime] NULL,
	[LastComplainTime] [datetime] NULL,
	[CreateTime] [datetime] NULL,
	[UpdateTime] [datetime] NULL,
	[Owner] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Balance] [money] NULL,
	[LastContactedTime] [datetime] NULL,
	[OldOwner] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[IsBusiness] [int] NULL,
	[UpdateOwnerTime] [datetime] NULL,
	[OwnerChanger] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[MaxOrderMoney] [money] NULL,
 CONSTRAINT [PK_PE_Client_ClientID] PRIMARY KEY CLUSTERED 
(
	[ClientID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Client]') AND name = N'IX_PE_Client_ClientNum')
CREATE NONCLUSTERED INDEX [IX_PE_Client_ClientNum] ON [dbo].[PE_Client] 
(
	[ClientNum] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Client]') AND name = N'IX_PE_Client_GroupID')
CREATE NONCLUSTERED INDEX [IX_PE_Client_GroupID] ON [dbo].[PE_Client] 
(
	[GroupID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Client]') AND name = N'IX_PE_Client_ParentID')
CREATE NONCLUSTERED INDEX [IX_PE_Client_ParentID] ON [dbo].[PE_Client] 
(
	[ParentID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'ClientID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'ClientID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'ParentID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上级客户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'ParentID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'ClientNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'ClientNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'ClientType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户类别，0--企业客户，1--个人客户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'ClientType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'ClientName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户名称（姓名）' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'ClientName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'ShortedForm'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'助记名称（简称）' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'ShortedForm'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'Area'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'区域' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'Area'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'ClientField'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'行业' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'ClientField'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'ValueLevel'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'价值评估' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'ValueLevel'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'CreditLevel'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信用等级' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'CreditLevel'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'Importance'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'重要程度' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'Importance'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'ConnectionLevel'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关系等级' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'ConnectionLevel'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'GroupID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户组别' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'GroupID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'SourceType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户来源' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'SourceType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'PhaseType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'阶段' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'PhaseType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'VisitTimes'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回访次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'VisitTimes'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'ServiceTimes'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'服务次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'ServiceTimes'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'ComplainTimes'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'投诉次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'ComplainTimes'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'LastVisitTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上次回访时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'LastVisitTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'LastServiceTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上次服务时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'LastServiceTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'LastComplainTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上次投诉时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'LastComplainTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'CreateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'CreateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'UpdateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'UpdateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'Owner'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所有者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'Owner'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'Balance'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'资金余额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'Balance'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'LastContactedTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最近联系时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'LastContactedTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'OldOwner'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'原所有者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'OldOwner'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'IsBusiness'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否商业用户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'IsBusiness'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'UpdateOwnerTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上一次更换所有者的时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'UpdateOwnerTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'OwnerChanger'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是哪个管理员释放的该客户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'OwnerChanger'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', N'COLUMN',N'MaxOrderMoney'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最大订单金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client', @level2type=N'COLUMN',@level2name=N'MaxOrderMoney'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Client', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Client'
GO
/****** Object:  Table [dbo].[PE_Cards]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Cards]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Cards](
	[CardID] [int] IDENTITY(1,1) NOT NULL,
	[CardType] [int] NULL,
	[ProductID] [int] NULL,
	[TableName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[CardNum] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[Password] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[AgentName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[Money] [money] NULL,
	[ValidNum] [int] NULL,
	[ValidUnit] [int] NULL,
	[EndDate] [datetime] NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[UseTime] [datetime] NULL,
	[CreateTime] [datetime] NULL,
	[OrderItemID] [int] NULL,
	[ProductName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Cards] PRIMARY KEY CLUSTERED 
(
	[CardID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Cards]') AND name = N'IX_PE_Cards_CardID')
CREATE NONCLUSTERED INDEX [IX_PE_Cards_CardID] ON [dbo].[PE_Cards] 
(
	[CardID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Cards]') AND name = N'IX_PE_Cards_CardNum')
CREATE NONCLUSTERED INDEX [IX_PE_Cards_CardNum] ON [dbo].[PE_Cards] 
(
	[CardNum] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Cards]') AND name = N'IX_PE_Cards_CardType')
CREATE NONCLUSTERED INDEX [IX_PE_Cards_CardType] ON [dbo].[PE_Cards] 
(
	[CardType] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Cards]') AND name = N'IX_PE_Cards_OrderItemID')
CREATE NONCLUSTERED INDEX [IX_PE_Cards_OrderItemID] ON [dbo].[PE_Cards] 
(
	[OrderItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Cards]') AND name = N'IX_PE_Cards_Password')
CREATE NONCLUSTERED INDEX [IX_PE_Cards_Password] ON [dbo].[PE_Cards] 
(
	[Password] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Cards]') AND name = N'IX_PE_Cards_ProductID')
CREATE NONCLUSTERED INDEX [IX_PE_Cards_ProductID] ON [dbo].[PE_Cards] 
(
	[ProductID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Cards]') AND name = N'IX_PE_Cards_ValidNum')
CREATE NONCLUSTERED INDEX [IX_PE_Cards_ValidNum] ON [dbo].[PE_Cards] 
(
	[ValidNum] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'CardID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'充值卡ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'CardID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'CardType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'充值卡类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'CardType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'ProductID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'充值卡所属商品' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'ProductID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'TableName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'表名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'TableName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'CardNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'卡号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'CardNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'Password'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'Password'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'AgentName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'代理商' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'AgentName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'Money'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'面值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'Money'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'ValidNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'点数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'ValidNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'ValidUnit'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'点数单位' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'ValidUnit'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'EndDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'截止日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'EndDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'使用者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'UseTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'充值时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'UseTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'CreateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生成时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'CreateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'OrderItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'售出' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'OrderItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', N'COLUMN',N'ProductName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属商品名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards', @level2type=N'COLUMN',@level2name=N'ProductName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Cards', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'充值卡表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Cards'
GO
/****** Object:  Table [dbo].[PE_BankrollItem]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_BankrollItem](
	[ItemID] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[ClientID] [int] NULL,
	[DateAndTime] [datetime] NULL,
	[Money] [money] NULL,
	[MoneyType] [int] NULL,
	[CurrencyType] [int] NULL,
	[eBankID] [int] NULL,
	[Bank] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[OrderID] [int] NULL,
	[PaymentID] [int] NULL,
	[Remark] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[LogTime] [datetime] NULL,
	[Inputer] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[IP] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Status] [int] NULL,
	[Memo] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[IsConsume] [bit] NULL,
 CONSTRAINT [PK_PE_BankrollItem_ItemID] PRIMARY KEY CLUSTERED 
(
	[ItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]') AND name = N'IX_PE_BankrollItem_ClientId')
CREATE NONCLUSTERED INDEX [IX_PE_BankrollItem_ClientId] ON [dbo].[PE_BankrollItem] 
(
	[ClientID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]') AND name = N'IX_PE_BankrollItem_eBankId')
CREATE NONCLUSTERED INDEX [IX_PE_BankrollItem_eBankId] ON [dbo].[PE_BankrollItem] 
(
	[eBankID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]') AND name = N'IX_PE_BankrollItem_OrderFormId')
CREATE NONCLUSTERED INDEX [IX_PE_BankrollItem_OrderFormId] ON [dbo].[PE_BankrollItem] 
(
	[OrderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]') AND name = N'IX_PE_BankrollItem_PaymentId')
CREATE NONCLUSTERED INDEX [IX_PE_BankrollItem_PaymentId] ON [dbo].[PE_BankrollItem] 
(
	[PaymentID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]') AND name = N'IX_PE_BankrollItem_UserName')
CREATE NONCLUSTERED INDEX [IX_PE_BankrollItem_UserName] ON [dbo].[PE_BankrollItem] 
(
	[UserName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'ItemID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'明细ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'ItemID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'ClientID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'ClientID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'DateAndTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发生时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'DateAndTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'Money'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'Money'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'MoneyType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'类型  1--现金 2--汇款 3--在线支付  4--虚拟货币' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'MoneyType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'CurrencyType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'币种  1--人民币  2--美元  3--其他' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'CurrencyType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'eBankID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网上支付平台ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'eBankID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'Bank'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'银行名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'Bank'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'支出时的订单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'PaymentID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'在线支付的支付单ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'PaymentID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'Remark'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'Remark'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'LogTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'记录时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'LogTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'Inputer'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'录入者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'Inputer'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'IP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'IP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'Status'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'资金状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'Status'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'Memo'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内部记录' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'Memo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', N'COLUMN',N'IsConsume'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否消费' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem', @level2type=N'COLUMN',@level2name=N'IsConsume'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_BankrollItem', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'资金明细表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_BankrollItem'
GO
/****** Object:  Table [dbo].[PE_Bank]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Bank]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Bank](
	[BankID] [int] NOT NULL,
	[BankShortName] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[BankName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Accounts] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[CardNum] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[HolderName] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[BankIntro] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[BankPic] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,
	[OrderID] [int] NULL,
	[IsDefault] [bit] NOT NULL,
	[IsDisabled] [bit] NOT NULL,
 CONSTRAINT [PK_PE_Bank_BankID] PRIMARY KEY CLUSTERED 
(
	[BankID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Bank]') AND name = N'IX_PE_Bank_CardNum')
CREATE NONCLUSTERED INDEX [IX_PE_Bank_CardNum] ON [dbo].[PE_Bank] 
(
	[CardNum] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Bank]') AND name = N'IX_PE_Bank_OrderID')
CREATE NONCLUSTERED INDEX [IX_PE_Bank_OrderID] ON [dbo].[PE_Bank] 
(
	[OrderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Bank', N'COLUMN',N'BankID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'银行帐户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Bank', @level2type=N'COLUMN',@level2name=N'BankID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Bank', N'COLUMN',N'BankShortName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'帐户名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Bank', @level2type=N'COLUMN',@level2name=N'BankShortName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Bank', N'COLUMN',N'BankName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'开户行' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Bank', @level2type=N'COLUMN',@level2name=N'BankName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Bank', N'COLUMN',N'Accounts'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'帐号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Bank', @level2type=N'COLUMN',@level2name=N'Accounts'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Bank', N'COLUMN',N'CardNum'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'卡号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Bank', @level2type=N'COLUMN',@level2name=N'CardNum'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Bank', N'COLUMN',N'HolderName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Bank', @level2type=N'COLUMN',@level2name=N'HolderName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Bank', N'COLUMN',N'BankIntro'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'帐户说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Bank', @level2type=N'COLUMN',@level2name=N'BankIntro'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Bank', N'COLUMN',N'BankPic'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'银行图标' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Bank', @level2type=N'COLUMN',@level2name=N'BankPic'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Bank', N'COLUMN',N'OrderID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Bank', @level2type=N'COLUMN',@level2name=N'OrderID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Bank', N'COLUMN',N'IsDefault'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否为默认银行帐户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Bank', @level2type=N'COLUMN',@level2name=N'IsDefault'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Bank', N'COLUMN',N'IsDisabled'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否禁用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Bank', @level2type=N'COLUMN',@level2name=N'IsDisabled'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Bank', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'银行帐户表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Bank'
GO
/****** Object:  Table [dbo].[PE_Author]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Author]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Author](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[UserID] [int] NULL,
	[Type] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Name] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Passed] [bit] NULL,
	[onTop] [bit] NULL,
	[IsElite] [bit] NULL,
	[Hits] [int] NULL,
	[LastUseTime] [datetime] NULL,
	[TemplateID] [int] NULL,
	[Photo] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Intro] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[Address] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Tel] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Fax] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Mail] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[ZipCode] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[HomePage] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Im] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Sex] [smallint] NULL,
	[BirthDay] [datetime] NULL,
	[Company] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Department] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_Author_ID] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'ID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'作者ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'ID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'UserID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'UserID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Type'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'作者类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Type'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Name'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'作者名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Name'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Passed'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N' 是否通过审核' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Passed'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'onTop'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否置顶' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'onTop'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'IsElite'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否推荐' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'IsElite'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Hits'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'点击数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Hits'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'LastUseTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最近登录时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'LastUseTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'TemplateID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'作者模板' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'TemplateID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Photo'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'作者头像' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Photo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Intro'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'作者简介' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Intro'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Address'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'作者地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Address'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Tel'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'电话' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Tel'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Fax'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'传真' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Fax'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Mail'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'通信地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Mail'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Email'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'电子邮件' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Email'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'ZipCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮政编码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'ZipCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'HomePage'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'个人网站' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'HomePage'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Im'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Imeeting' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Im'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Sex'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'性别' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Sex'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'BirthDay'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N' 生日' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'BirthDay'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Company'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'公司名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Company'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', N'COLUMN',N'Department'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author', @level2type=N'COLUMN',@level2name=N'Department'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Author', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'作者表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Author'
GO
/****** Object:  Table [dbo].[PE_AdZone]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_AdZone]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_AdZone](
	[ZoneID] [int] NOT NULL,
	[ZoneName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[ZoneJSName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[ZoneIntro] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ZoneType] [int] NULL,
	[DefaultSetting] [bit] NOT NULL,
	[ZoneSetting] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[ZoneWidth] [int] NULL,
	[ZoneHeight] [int] NULL,
	[Active] [bit] NOT NULL,
	[ShowType] [int] NULL,
	[UpdateTime] [datetime] NOT NULL,
 CONSTRAINT [PK_PE_AdZone_ZoneID] PRIMARY KEY CLUSTERED 
(
	[ZoneID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdZone', N'COLUMN',N'ZoneID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'版位ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdZone', @level2type=N'COLUMN',@level2name=N'ZoneID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdZone', N'COLUMN',N'ZoneName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'版位名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdZone', @level2type=N'COLUMN',@level2name=N'ZoneName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdZone', N'COLUMN',N'ZoneJSName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'版位JS文件名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdZone', @level2type=N'COLUMN',@level2name=N'ZoneJSName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdZone', N'COLUMN',N'ZoneIntro'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'版位简介' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdZone', @level2type=N'COLUMN',@level2name=N'ZoneIntro'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdZone', N'COLUMN',N'ZoneType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'版位广告显示类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdZone', @level2type=N'COLUMN',@level2name=N'ZoneType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdZone', N'COLUMN',N'DefaultSetting'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否默认设置' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdZone', @level2type=N'COLUMN',@level2name=N'DefaultSetting'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdZone', N'COLUMN',N'ZoneSetting'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'版位设置参数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdZone', @level2type=N'COLUMN',@level2name=N'ZoneSetting'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdZone', N'COLUMN',N'ZoneWidth'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'版位的宽度' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdZone', @level2type=N'COLUMN',@level2name=N'ZoneWidth'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdZone', N'COLUMN',N'ZoneHeight'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'版位的高度' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdZone', @level2type=N'COLUMN',@level2name=N'ZoneHeight'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdZone', N'COLUMN',N'Active'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N' 是否活跃' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdZone', @level2type=N'COLUMN',@level2name=N'Active'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdZone', N'COLUMN',N'ShowType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'版位的类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdZone', @level2type=N'COLUMN',@level2name=N'ShowType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdZone', N'COLUMN',N'UpdateTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N' 添加版位的时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdZone', @level2type=N'COLUMN',@level2name=N'UpdateTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdZone', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'广告版位表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdZone'
GO
/****** Object:  Table [dbo].[PE_Advertisement]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Advertisement](
	[ADID] [int] NOT NULL,
	[UserID] [int] NULL,
	[ADType] [int] NULL,
	[ADName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[ImgUrl] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ImgWidth] [int] NULL,
	[ImgHeight] [int] NULL,
	[FlashWmode] [int] NULL,
	[ADIntro] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[LinkUrl] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[LinkTarget] [int] NULL,
	[LinkAlt] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[Priority] [int] NULL,
	[Setting] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[CountView] [bit] NOT NULL,
	[Views] [int] NULL,
	[CountClick] [bit] NOT NULL,
	[Clicks] [int] NULL,
	[IsAbsolutePath] [bit] NOT NULL,
	[Passed] [bit] NOT NULL,
	[OverdueDate] [datetime] NULL,
 CONSTRAINT [PK_PE_Advertisement_ADID] PRIMARY KEY CLUSTERED 
(
	[ADID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'ADID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'广告ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'ADID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'UserID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'广告客户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'UserID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'ADType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'广告类型 图片、动画、文本、代码、页面' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'ADType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'ADName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'广告名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'ADName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'ImgUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'图片地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'ImgUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'ImgWidth'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'图片的宽度' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'ImgWidth'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'ImgHeight'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'图片的高度' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'ImgHeight'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'FlashWmode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Flash是否透明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'FlashWmode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'ADIntro'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'广告内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'ADIntro'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'LinkUrl'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'链接网址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'LinkUrl'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'LinkTarget'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否在新窗口打开' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'LinkTarget'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'LinkAlt'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'链接提示' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'LinkAlt'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'Priority'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'广告项目的权重' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'Priority'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'Setting'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N' 其他设定' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'Setting'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'CountView'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否统计浏览数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'CountView'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'Views'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'浏览数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'Views'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'CountClick'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否统计点击数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'CountClick'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'Clicks'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'点击数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'Clicks'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'IsAbsolutePath'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'广告连接路径是否为绝对路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'IsAbsolutePath'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'Passed'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否通过审核' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'Passed'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', N'COLUMN',N'OverdueDate'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'广告过期时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement', @level2type=N'COLUMN',@level2name=N'OverdueDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Advertisement', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'广告表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Advertisement'
GO
/****** Object:  Table [dbo].[PE_AdminShortCutContent]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_AdminShortCutContent]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_AdminShortCutContent](
	[ShortCutID] [int] NOT NULL,
	[AdminName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_ShortCutContent] PRIMARY KEY CLUSTERED 
(
	[ShortCutID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdminShortCutContent', N'COLUMN',N'ShortCutID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'序号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdminShortCutContent', @level2type=N'COLUMN',@level2name=N'ShortCutID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdminShortCutContent', N'COLUMN',N'AdminName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdminShortCutContent', @level2type=N'COLUMN',@level2name=N'AdminName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdminShortCutContent', N'COLUMN',N'Content'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'快捷内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdminShortCutContent', @level2type=N'COLUMN',@level2name=N'Content'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdminShortCutContent', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员快捷录入表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdminShortCutContent'
GO
/****** Object:  Table [dbo].[PE_AdminProfile]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_AdminProfile]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_AdminProfile](
	[AdminName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[WebPartSetting] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[PersonalSetting] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
	[WidgetPara] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_PE_AdminProfile_AdminName] PRIMARY KEY CLUSTERED 
(
	[AdminName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdminProfile', N'COLUMN',N'AdminName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdminProfile', @level2type=N'COLUMN',@level2name=N'AdminName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdminProfile', N'COLUMN',N'WebPartSetting'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'WebPart状态值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdminProfile', @level2type=N'COLUMN',@level2name=N'WebPartSetting'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdminProfile', N'COLUMN',N'PersonalSetting'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'个性化状态值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdminProfile', @level2type=N'COLUMN',@level2name=N'PersonalSetting'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdminProfile', N'COLUMN',N'WidgetPara'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'widget其他参数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdminProfile', @level2type=N'COLUMN',@level2name=N'WidgetPara'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_AdminProfile', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员扩展属性表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_AdminProfile'
GO
/****** Object:  Table [dbo].[PE_Admin_Roles]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Admin_Roles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Admin_Roles](
	[AdminID] [int] NOT NULL,
	[RoleID] [int] NOT NULL,
 CONSTRAINT [PK_PE_Admin_Roles] PRIMARY KEY CLUSTERED 
(
	[AdminID] ASC,
	[RoleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin_Roles', N'COLUMN',N'AdminID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin_Roles', @level2type=N'COLUMN',@level2name=N'AdminID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin_Roles', N'COLUMN',N'RoleID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin_Roles', @level2type=N'COLUMN',@level2name=N'RoleID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin_Roles', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员角色表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin_Roles'
GO
/****** Object:  Table [dbo].[PE_Admin]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Admin]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Admin](
	[AdminID] [int] NOT NULL,
	[AdminName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[AdminPassword] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[EnableMultiLogin] [bit] NOT NULL,
	[RndPassword] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[LoginTimes] [int] NULL,
	[LastLoginIP] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[LastLoginTime] [datetime] NULL,
	[LastLogoutTime] [datetime] NULL,
	[LastModifyPasswordTime] [datetime] NULL,
	[IsLock] [bit] NULL,
	[EnableModifyPassword] [bit] NULL,
	[Hash] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[LoginErrorTimes] [int] NULL,
 CONSTRAINT [PK_PE_Admin_AdminID] PRIMARY KEY CLUSTERED 
(
	[AdminID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'AdminID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'AdminID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'AdminName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'AdminName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'AdminPassword'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'AdminPassword'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'前台用户名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'EnableMultiLogin'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否允许多人登录' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'EnableMultiLogin'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'RndPassword'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'随机密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'RndPassword'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'LoginTimes'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'登录次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'LoginTimes'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'LastLoginIP'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最近登录IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'LastLoginIP'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'LastLoginTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最近登录时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'LastLoginTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'LastLogoutTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最近退出管理后台时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'LastLogoutTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'LastModifyPasswordTime'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最近修改密码时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'LastModifyPasswordTime'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'IsLock'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否锁定' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'IsLock'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'EnableModifyPassword'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否允许修改密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'EnableModifyPassword'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'Hash'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'有效性验证' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'Hash'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', N'COLUMN',N'LoginErrorTimes'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'登录错误次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin', @level2type=N'COLUMN',@level2name=N'LoginErrorTimes'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Admin', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Admin'
GO
/****** Object:  Table [dbo].[PE_Address]    Script Date: 01/19/2017 15:37:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PE_Address]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PE_Address](
	[AddressID] [int] NOT NULL,
	[UserName] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
	[ConsigneeName] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[HomePhone] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Mobile] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[Country] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[Province] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[City] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[Area] [nvarchar](30) COLLATE Chinese_PRC_CI_AS NULL,
	[Address] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ZipCode] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[IsDefault] [bit] NULL,
 CONSTRAINT [PK_PE_Address_AddressID] PRIMARY KEY NONCLUSTERED 
(
	[AddressID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PE_Address]') AND name = N'IX_PE_Address_UserName')
CREATE CLUSTERED INDEX [IX_PE_Address_UserName] ON [dbo].[PE_Address] 
(
	[UserName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Address', N'COLUMN',N'AddressID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'地址ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Address', @level2type=N'COLUMN',@level2name=N'AddressID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Address', N'COLUMN',N'UserName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Address', @level2type=N'COLUMN',@level2name=N'UserName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Address', N'COLUMN',N'ConsigneeName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'收货人姓名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Address', @level2type=N'COLUMN',@level2name=N'ConsigneeName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Address', N'COLUMN',N'HomePhone'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'固定电话' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Address', @level2type=N'COLUMN',@level2name=N'HomePhone'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Address', N'COLUMN',N'Mobile'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'移动电话' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Address', @level2type=N'COLUMN',@level2name=N'Mobile'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Address', N'COLUMN',N'Country'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'国家' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Address', @level2type=N'COLUMN',@level2name=N'Country'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Address', N'COLUMN',N'Province'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'省份' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Address', @level2type=N'COLUMN',@level2name=N'Province'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Address', N'COLUMN',N'City'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'城市' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Address', @level2type=N'COLUMN',@level2name=N'City'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Address', N'COLUMN',N'Area'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'地区' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Address', @level2type=N'COLUMN',@level2name=N'Area'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Address', N'COLUMN',N'Address'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'详细地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Address', @level2type=N'COLUMN',@level2name=N'Address'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Address', N'COLUMN',N'ZipCode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮政编码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Address', @level2type=N'COLUMN',@level2name=N'ZipCode'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Address', N'COLUMN',N'IsDefault'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否默认' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Address', @level2type=N'COLUMN',@level2name=N'IsDefault'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PE_Address', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'地址表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PE_Address'
GO
/****** Object:  StoredProcedure [dbo].[PR_CommonPage]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_CommonPage]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_CommonPage]
    @StrSql NTEXT , --查询字符串
    @CurrentPage INT , --第N页
    @PageSize INT , --每页行数
    @Total INT OUTPUT
AS 
    SET NOCOUNT ON

    DECLARE @P1 INT , --P1是游标的id
        @Rowcount INT
    EXEC sp_cursoropen @P1 OUTPUT, @StrSql, @scrollopt = 1, @ccopt = 1,
        @Rowcount = @Total OUTPUT
    SET @CurrentPage = ( @CurrentPage - 1 ) * @PageSize + 1
    EXEC sp_cursorfetch @P1, 16, @CurrentPage, @PageSize 
    EXEC sp_cursorclose @P1
    RETURN @Total

    SET NOCOUNT OFF' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Common_PagingLarge]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Common_PagingLarge]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Common_PagingLarge]
    @TableNames VARCHAR(4000) ,
    @PrimaryKey VARCHAR(4000) ,
    @Fields VARCHAR(4000) ,
    @PageSize INT ,
    @StartRow INT ,
    @Filter VARCHAR(4000) = '''' ,
    @Group VARCHAR(4000) = '''' ,
    @Order VARCHAR(4000) = ''''
AS 
    BEGIN
        DECLARE @SortColumn VARCHAR(4000)
        DECLARE @DeclareSortType VARCHAR(4000)
        DECLARE @SortColumnBegin VARCHAR(4000)
        DECLARE @SortColumnWhere VARCHAR(4000)
        DECLARE @FirstSortColumnWhere VARCHAR(4000)
        DECLARE @Operator CHAR(2)
        DECLARE @SortTable VARCHAR(4000)
        DECLARE @SortName VARCHAR(4000)
        SET @DeclareSortType = ''''
        SET @SortColumnBegin = ''''
        SET @SortColumnWhere = ''''
        SET @FirstSortColumnWhere = ''''
        IF @Fields = '''' 
            SET @Fields = ''*''
        IF @Filter = '''' 
            SET @Filter = ''Where 1=1''
        ELSE 
            SET @Filter = ''Where '' + @Filter
        IF @Group <> '''' 
            SET @Group = ''GROUP BY '' + @Group
        IF @Order = '''' 
            SET @Order = @PrimaryKey + '' ASC''
        DECLARE @StartRows INT
        SET @StartRows = @StartRow
        IF @StartRows <= 0 
            SET @StartRows = 0
        DECLARE @equalOperator CHAR(2)
        IF @StartRows = 0 
            BEGIN
                SET @equalOperator = ''=''
                SET @StartRows = 1
            END
        ELSE 
            SET @equalOperator = ''''

        DECLARE @pos1 INT ,
            @pos2 INT ,
            @Depth INT
        DECLARE @SubOrder VARCHAR(4000) ,
            @EndOrder VARCHAR(2000) ,
            @PreOrder VARCHAR(2000) ,
            @PreTable VARCHAR(2000) ,
            @PreSortColumn VARCHAR(2000)
        SET @EndOrder = ''''
        SET @Depth = 1
        SET @EndOrder = @Order
        SET @pos1 = 1

        WHILE @pos1 > 0 
            BEGIN
                SET @pos1 = CHARINDEX('','', @EndOrder)
                IF @pos1 > 0 
                    SET @SubOrder = SUBSTRING(@EndOrder, 1, @pos1 - 1)
                ELSE 
                    SET @SubOrder = @EndOrder
                SET @EndOrder = SUBSTRING(@EndOrder, @pos1 + 1,
                                          LEN(@EndOrder) - @pos1)
                SET @SubOrder = REPLACE(REPLACE(@SubOrder, '' asc'', '' ASC''),
                                        '' desc'', '' DESC'')
                IF CHARINDEX('' DESC'', @SubOrder) > 0 
                    IF CHARINDEX('' ASC'', @SubOrder) > 0 
                        BEGIN
                            IF CHARINDEX('' DESC'', @SubOrder) < CHARINDEX('' ASC'',
                                                              @SubOrder) 
                                SET @Operator = ''<''
                            ELSE 
                                SET @Operator = ''>''
                        END
                    ELSE 
                        SET @Operator = ''<''
                ELSE 
                    SET @Operator = ''>''
					      
                SET @SortColumn = REPLACE(REPLACE(REPLACE(@SubOrder, '' ASC'',
                                                          ''''), '' DESC'', ''''),
                                          '' '', '''')
                SET @pos2 = CHARINDEX(''.'', @SortColumn)
			
                DECLARE @dataType VARCHAR(50)
                SET @dataType = NULL
                DECLARE @prec INT
				DECLARE @xscale INT

                IF @pos2 > 0 
                    BEGIN
                        SET @SortTable = SUBSTRING(@SortColumn, 1, @pos2 - 1)
                        SET @SortName = SUBSTRING(@SortColumn, @pos2 + 1,
                                                  LEN(@SortColumn) - @pos2)
                    END
                ELSE 
                    BEGIN
                        SET @SortTable = @TableNames
                        SET @SortName = @SortColumn
                    END
                SELECT  @dataType = t.name ,
                        @prec = c.prec ,
						@xscale = c.xscale
                FROM    sysobjects o
                        JOIN syscolumns c ON o.id = c.id
                        JOIN systypes t ON c.xusertype = t.xusertype
                WHERE   o.name = @SortTable
                        AND c.name = @SortName
                IF @dataType IS NULL 
                    BEGIN
                        DECLARE @posTableName1 INT ,
                            @posTableName2 INT ,
                            @TableNameSubStr VARCHAR(4000)
                        SET @posTableName1 = CHARINDEX('' '' + @SortTable + '' '',
                                                       @TableNames + '' '')
                        IF @posTableName1 > 0 
                            BEGIN
                                SET @TableNameSubStr = SUBSTRING(@TableNames,
                                                              1,
                                                              @posTableName1
                                                              - 1)
                                SET @TableNameSubStr = LTRIM(@TableNameSubStr)
                                SET @TableNameSubStr = RTRIM(@TableNameSubStr)
			              
                                SET @posTableName2 = CHARINDEX('' '',
                                                              @TableNameSubStr)
                                WHILE @posTableName2 > 0 
                                    BEGIN
                                        SET @TableNameSubStr = SUBSTRING(@TableNameSubStr,
                                                              @posTableName2,
                                                              LEN(@TableNameSubStr)
                                                              - 1)
                                        SET @TableNameSubStr = LTRIM(@TableNameSubStr)
                                        SET @TableNameSubStr = RTRIM(@TableNameSubStr)
                                        SET @posTableName2 = CHARINDEX('' '',
                                                              @TableNameSubStr)
                                    END
                            END
                        SELECT  @dataType = t.name ,
                                @prec = c.prec ,
								@xscale = c.xscale
                        FROM    sysobjects o
                                JOIN syscolumns c ON o.id = c.id
                                JOIN systypes t ON c.xusertype = t.xusertype
                        WHERE   o.name = @TableNameSubStr
                                AND c.name = @SortName
                    END
                IF CHARINDEX(''char'', @dataType) > 0 
                    BEGIN
                        SET @dataType = @dataType + ''(''
                            + CAST(@prec AS VARCHAR) + '')''
                    END
				IF CHARINDEX(''numeric'', @dataType) > 0 
                    BEGIN
                        SET @dataType = @dataType + ''(''
                            + CAST(@prec AS VARCHAR) + '','' + CAST(@xscale AS VARCHAR) + '')''
                    END

                SET @DeclareSortType = @DeclareSortType + ''
                DECLARE @SortColumnBegin'' + @SortName + '' '' + @dataType
                IF @Depth <> 1 
                    BEGIN
                        SET @SortColumnBegin = @SortColumnBegin + '',''
                            + ''@SortColumnBegin'' + @SortName + ''=''
                            + @SortColumn
                        IF @pos1 > 0 
							BEGIN
								SET @SortColumnWhere = @SortColumnWhere + '' OR (''
                                + @FirstSortColumnWhere + '' AND '' + @SortColumn
                                + @Operator + ''@SortColumnBegin'' + @SortName
                                + '')'';
                                SET @FirstSortColumnWhere =  @FirstSortColumnWhere + '' AND '' +
									+ @SortColumn + ''=@SortColumnBegin'' + @SortName
                            END
                        ELSE 
							BEGIN
								SET @SortColumnWhere = @SortColumnWhere + '' OR (''
                                + @FirstSortColumnWhere + '' AND '' + @SortColumn
                                + @Operator + @equalOperator
                                + ''@SortColumnBegin'' + @SortName + '')'';
                                SET @FirstSortColumnWhere = @FirstSortColumnWhere+ '' AND '' +
									+ @SortColumn + ''=@SortColumnBegin'' + @SortName
                            END
                    END                    
                ELSE 
                    BEGIN
                        SET @SortColumnBegin = @SortColumnBegin
                            + ''@SortColumnBegin'' + @SortName + ''=''
                            + @SortColumn 
                        IF @pos1 > 0 
							BEGIN
								SET @SortColumnWhere = @SortColumnWhere
									+ @SortColumn + @Operator + ''@SortColumnBegin''
									+ @SortName
									
                                SET @FirstSortColumnWhere = @FirstSortColumnWhere
									+ @SortColumn + ''=@SortColumnBegin''
									+ @SortName
                            END
                        ELSE
							BEGIN
								SET @SortColumnWhere = @SortColumnWhere
									+ @SortColumn + @Operator + @equalOperator
									+ ''@SortColumnBegin'' + @SortName
							    SET @FirstSortColumnWhere = @FirstSortColumnWhere
									+ @SortColumn + ''=@SortColumnBegin''
									+ @SortName
                            END
                    END 
                SET @Depth = @Depth + 1
                SET @PreOrder = @SortName
                SET @PreTable = @SortTable
                SET @PreSortColumn = @SortColumn
            END
        EXEC ( ''
        '' + @DeclareSortType + ''
        SET ROWCOUNT '' + @StartRows + ''
        Select '' + @SortColumnBegin + '' FROM '' + @TableNames + '' '' + @Filter + '' '' + @Group + '' ORDER BY '' + @Order + ''
        SET ROWCOUNT '' + @PageSize + ''
        Select '' + @Fields + '' FROM    '' + @TableNames + '' '' + @Filter + '' AND ('' + @SortColumnWhere + '') '' + @Group + '' ORDER BY '' + @Order + ''    
        ''
        )
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Common_GetListBySortColumn]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Common_GetListBySortColumn]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Common_GetListBySortColumn]
    @StartRows INT ,
    @PageSize INT ,
    @PrimaryColumn VARCHAR(1000) ,
    @SortColumnDbType VARCHAR(100) ,
    @SortColumn VARCHAR(1000) ,
    @StrColumn VARCHAR(1000) ,
    @Sorts VARCHAR(100) ,
    @Filter VARCHAR(MAX) ,
    @TableName VARCHAR(1000) ,
    @Total INT OUTPUT
AS 
    SET NOCOUNT ON

    BEGIN
        DECLARE @equalOperator CHAR(2)
        IF @StartRows <= 0 
            BEGIN
                SET @StartRows = 1
                SET @equalOperator = ''=''
            END
        ELSE 
            BEGIN
                SET @equalOperator = ''''
            END

/*Set sorting variables.*/
        DECLARE @operator CHAR(2)
        DECLARE @Order INT
        SET @Order = CHARINDEX(''DESC'', @Sorts)
        IF @Order > 0 
            BEGIN
                SET @operator = ''<'' + @equalOperator
            END
        ELSE 
            BEGIN
                SET @operator = ''>'' + @equalOperator
            END
        DECLARE @strFilter VARCHAR(MAX)
        DECLARE @strSimpleFilter VARCHAR(MAX)

        IF @Filter IS NOT NULL
            AND @Filter != '''' 
            BEGIN
                SET @strFilter = '' WHERE '' + @Filter + '' ''
                SET @strSimpleFilter = '' AND '' + @Filter + '' ''
            END
        ELSE 
            BEGIN	
                SET @strFilter = ''''
                SET @strSimpleFilter = ''''
            END

        DECLARE @Sql NVARCHAR(MAX)
        SET @Sql = N''SELECT @Total=Count(*) FROM '' + @TableName + @strFilter
        EXEC sp_executesql @Sql, N''@Total Int Out'', @Total OUT 

        IF @PageSize <= 0 
            SET @PageSize = @Total

        IF @PrimaryColumn != @SortColumn 
            BEGIN
                EXEC(
                ''DECLARE @SortId int '' +
                ''DECLARE @SortCol ''+ @SortColumnDbType + '' ''+
                ''SET ROWCOUNT ''+ @StartRows + ''
                SELECT @SortId = ''+ @PrimaryColumn + '',@SortCol=''+ @SortColumn +'' FROM ''+ @TableName + @strFilter +'' ORDER BY ''+ @SortColumn +'' '' +@Sorts + '','' +  @PrimaryColumn + '' '' +@Sorts +''
                IF(@SortCol IS NOT NULL)
                begin
                IF(''+@Order+''>0)
                begin
                SET ROWCOUNT ''+@PageSize+'' 
                SELECT ''+ @StrColumn +'' FROM ''+ @TableName + ''
                WHERE (''+@SortColumn+'' IS NULL OR ''+ @SortColumn  + @operator+''@SortCol OR (''+@SortColumn+''=@SortCol AND ''+ @PrimaryColumn  + @operator +''@SortId ))'' + @strSimpleFilter + '' ORDER BY ''+ @SortColumn + '' '' +@Sorts + '','' + @PrimaryColumn + '' ''+ @Sorts + ''
                end
                ELSE
                BEGIN
                SET ROWCOUNT ''+@PageSize+'' 
                SELECT ''+ @StrColumn +'' FROM ''+ @TableName + ''
                WHERE (''+@SortColumn+'' IS NOT NULL AND (''+ @SortColumn  + @operator+'' @SortCol OR (''+ @SortColumn  + ''= @SortCol AND ''+ @PrimaryColumn  + @operator +''@SortId)))'' + @strSimpleFilter + '' ORDER BY ''+ @SortColumn + '' '' +@Sorts + '','' + @PrimaryColumn + '' ''+ @Sorts + ''
                END
                END
                ELSE
                begin
                IF(''+@Order+''>0)
                begin
                SET ROWCOUNT ''+@PageSize+'' 
                SELECT ''+ @StrColumn +'' FROM ''+ @TableName + ''
                WHERE (''+@SortColumn+'' IS NULL AND ''+ @PrimaryColumn  + @operator +'' @SortId )'' + @strSimpleFilter + '' ORDER BY ''+ @SortColumn + '' '' +@Sorts + '','' + @PrimaryColumn + '' ''+ @Sorts + ''
                END
                else
                begin
                SET ROWCOUNT ''+@PageSize+'' 
                SELECT ''+ @StrColumn +'' FROM ''+ @TableName + ''
                WHERE ((''+@SortColumn+'' IS NULL AND ''+@PrimaryColumn+@operator+''@SortId ) OR ''+@SortColumn+'' IS NOT NULL )'' + @strSimpleFilter + '' ORDER BY ''+ @SortColumn + '' '' +@Sorts + '','' + @PrimaryColumn + '' ''+ @Sorts + ''
                end
                end''
                )
            END
        ELSE 
            BEGIN
                EXEC(
                ''DECLARE @SortId int '' +
                ''SET ROWCOUNT ''+ @StartRows + ''
                SELECT @SortId = ''+ @SortColumn + '' FROM ''+ @TableName + @strFilter +'' ORDER BY ''+ @SortColumn + '' '' +@Sorts +''
                SET ROWCOUNT ''+ @PageSize  + ''
                SELECT ''+ @StrColumn +'' FROM ''+ @TableName + '' 
                WHERE ''+ @SortColumn  + @operator +'' @SortId ''+ @strSimpleFilter + '' ORDER BY ''+ @SortColumn +'' ''+ @Sorts + ''''
                )
            END

        RETURN @Total
    END

    SET ROWCOUNT 0

    SET NOCOUNT OFF' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Common_GetList]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Common_GetList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Common_GetList]
    (
      @StartRows INT ,
      @PageSize INT ,
      @SortColumn VARCHAR(1000) ,
      @StrColumn VARCHAR(1000) ,
      @Sorts VARCHAR(100) ,
      @Filter VARCHAR(4000) ,
      @TableName VARCHAR(1000) ,
      @Total INT OUTPUT
    )
AS 
    SET NOCOUNT ON

    BEGIN
        IF @StartRows <= 0 
            SET @StartRows = 0

        DECLARE @equalOperator CHAR(2)
        IF @StartRows = 0 
            BEGIN
                SET @equalOperator = ''=''
                SET @StartRows = 1
            END
        ELSE 
            SET @equalOperator = ''''

/*Set sorting variables.*/
        DECLARE @operator CHAR(2)
        DECLARE @strSortColumn VARCHAR(10)
	
        IF CHARINDEX(''DESC'', @Sorts) > 0 
            BEGIN
                SET @strSortColumn = REPLACE(@Sorts, ''DESC'', '''')
                SET @operator = ''<'' + @equalOperator
            END
        ELSE 
            BEGIN
                IF CHARINDEX(''ASC'', @Sorts) = 0 
                    SET @strSortColumn = REPLACE(@Sorts, ''ASC'', '''')
                SET @operator = ''>'' + @equalOperator
            END

        DECLARE @strFilter VARCHAR(4000)
        DECLARE @strSimpleFilter VARCHAR(4000)

        IF @Filter IS NOT NULL
            AND @Filter != '''' 
            BEGIN
                SET @strFilter = '' WHERE '' + @Filter + '' ''
                SET @strSimpleFilter = '' AND '' + @Filter + '' ''
            END
        ELSE 
            BEGIN	
                SET @strFilter = ''''
                SET @strSimpleFilter = ''''
            END

        IF @Total <= 0
            OR @Total IS NULL 
            BEGIN	
                DECLARE @Sql NVARCHAR(4000)
                SET @Sql = N''SELECT @Total=Count(*) FROM '' + @TableName
                    + @strFilter
                EXEC sp_executesql @Sql, N''@Total Int Out'', @Total OUT 
            END

        IF @PageSize <= 0 
            SET @PageSize = @Total

        EXEC(
        ''DECLARE @SortId int '' +
        ''SET ROWCOUNT ''+ @StartRows + ''
        SELECT @SortId = ''+ @SortColumn + '' FROM ''+ @TableName + @strFilter +'' ORDER BY ''+ @SortColumn + '' '' +@Sorts +''
        SET ROWCOUNT ''+ @PageSize  + ''
        SELECT ''+ @StrColumn +'' FROM ''+ @TableName + '' 
        WHERE ''+ @SortColumn  + @operator +'' @SortId ''+ @strSimpleFilter + '' ORDER BY ''+ @SortColumn + '' ''+ @Sorts + ''''
        )


        RETURN @Total
    END

    SET ROWCOUNT 0

    SET NOCOUNT OFF' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ClientAnnal_Delete]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ClientAnnal_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_ClientAnnal_Delete]
    (
      @condition VARCHAR(1000)
    )
AS 
    DECLARE @sql VARCHAR(1100)
    SET @sql = ''delete from pe_clientannal where clientannalid in(''
        + @condition + '')''
    EXEC (@sql)' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_Delete]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Producer_Delete]
    (
      @ProducerId NVARCHAR(4000)
    )
AS 
    DECLARE @sql NVARCHAR(4000)
    SET @sql = ''DELETE PE_Producer WHERE ProducerID IN ('' + @ProducerId + '')''
    EXEC(@sql)' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Keywords_Delete]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Keywords_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Keywords_Delete]
    (
      @KeywordId NVARCHAR(4000)
    )
AS 
    DECLARE @sql NVARCHAR(4000)
    SET @sql = ''DELETE PE_Keywords WHERE KeywordId IN ('' + @KeywordId + '')''
    EXEC(@sql)' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_BankroolItem_GetBill]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_BankroolItem_GetBill]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_BankroolItem_GetBill]
    (
      @StartRows INT ,
      @PageSize INT ,
      @SortColumn VARCHAR(1000) ,
      @StrColumn VARCHAR(1000) ,
      @Sorts VARCHAR(100) ,
      @Filter VARCHAR(1000) ,
      @TableName VARCHAR(1000) ,
      @Total INT OUTPUT
    )
AS 
    SET NOCOUNT ON

    BEGIN
        IF @StartRows <= 0 
            SET @StartRows = 0

        DECLARE @equalOperator CHAR(2)
        IF @StartRows = 0 
            BEGIN
                SET @equalOperator = ''=''
                SET @StartRows = 1
            END
        ELSE 
            SET @equalOperator = ''''

/*Set sorting variables.*/
        DECLARE @operator CHAR(2)
        DECLARE @strSortColumn VARCHAR(10)
	
        IF CHARINDEX(''DESC'', @Sorts) > 0 
            BEGIN
                SET @strSortColumn = REPLACE(@Sorts, ''DESC'', '''')
                SET @operator = ''<'' + @equalOperator
            END
        ELSE 
            BEGIN
                IF CHARINDEX(''ASC'', @Sorts) = 0 
                    SET @strSortColumn = REPLACE(@Sorts, ''ASC'', '''')
                SET @operator = ''>'' + @equalOperator
            END

        DECLARE @strFilter VARCHAR(1000)
        DECLARE @strSimpleFilter VARCHAR(1000)

        IF @Filter IS NOT NULL
            AND @Filter != '''' 
            BEGIN
                SET @strFilter = '' WHERE '' + @Filter + '' ''
                SET @strSimpleFilter = '' AND '' + @Filter + '' ''
            END
        ELSE 
            BEGIN	
                SET @strFilter = ''''
                SET @strSimpleFilter = ''''
            END

        DECLARE @Sql NVARCHAR(4000)
        SET @Sql = N''SELECT @Total=Count(Distinct B.OrderID) FROM ''
            + @TableName + @strFilter
        EXEC sp_executesql @Sql, N''@Total Int Out'', @Total OUT 

        IF @PageSize <= 0 
            SET @PageSize = @Total

        EXEC(
        ''DECLARE @SortId int '' +
        ''DECLARE @SortCol DateTime ''+
        ''SET ROWCOUNT ''+ @StartRows + 
        '' SELECT @SortId = ''+ @SortColumn + '',@SortCol=Max(B.DateAndTime) FROM ''+ @TableName + @strFilter +'' Group By B.OrderID Order by Max(B.DateAndTime) '' +@Sorts+ '', B.OrderID '' +@Sorts + 
        '' SET ROWCOUNT ''+ @PageSize +
        '' SELECT ''+ @StrColumn +'' FROM ''+ @TableName +  
        '' WHERE (B.DateAndTime ''+@operator+'' @SortCol OR (B.DateAndTime = @SortCol AND B.OrderID ''+@operator+'' @SortId )) ''+ @strSimpleFilter + '' Group By B.OrderID ORDER BY Max(B.DateAndTime) '' +@Sorts+ '',B.OrderID ''+ @Sorts + ''''
        )


        RETURN @Total
    END

    SET ROWCOUNT 0

    SET NOCOUNT OFF' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Message_Delete]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Message_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Message_Delete]
    (
      @DeleteType INT ,
      @DeleteValue NVARCHAR(100)
    )
AS 
    SET NOCOUNT OFF
    BEGIN
        DECLARE @Sql NVARCHAR(4000)
		
        IF @DeleteType = 0 
            BEGIN
                SET @Sql = N''DELETE PE_Message WHERE MessageID in (''
                    + @DeleteValue + '')''
            END
        ELSE 
            IF @DeleteType = 1 
                BEGIN
                    SET @Sql = N''DELETE PE_Message WHERE Sender in (''
                        + @DeleteValue + '')''
                END
            ELSE 
                BEGIN
                    IF @DeleteValue = 0 
                        SET @Sql = N''DELETE PE_Message''
                    ELSE 
                        SET @Sql = N''DELETE PE_Message WHERE  datediff(day,SendTime,getdate()) >=''
                            + @DeleteValue
                END

        EXEC sp_executesql @Sql
    END
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_WordReplace_Delete]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_WordReplace_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_WordReplace_Delete] ( @ItemID NVARCHAR(4000) )
AS 
    DECLARE @sql NVARCHAR(4000)
    SET @sql = ''DELETE PE_WordReplaceItem WHERE ItemID IN ('' + @ItemID + '')''
    EXEC(@sql)' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_ADZone_GetExportList]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_ADZone_GetExportList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_AD_ADZone_GetExportList] ( @ZoneID NVARCHAR(250) )
AS  
    EXEC('' SELECT ZoneID,ZoneName,ZoneJSName,ZoneIntro,ZoneType,DefaultSetting,ZoneSetting,ZoneWidth,ZoneHeight,ShowType,Active,UpdateTime FROM PE_AdZone WHERE ZoneID in (''+@ZoneID+'')  ORDER BY ZoneID ASC'')' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PaymentLog_Delete]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PaymentLog_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_PaymentLog_Delete]
    (
      @paymentLogId NVARCHAR(4000)
    )
AS 
    DECLARE @sql NVARCHAR(4000)
    SET @sql = ''DELETE [PE_PaymentLog] WHERE [Status]=1 AND [PaymentLogID] IN(''
        + @paymentLogId + '')''
    EXEC(@sql)' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_WordReplace_IsEnabled]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_WordReplace_IsEnabled]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_WordReplace_IsEnabled]
    (
      @ItemID NVARCHAR(4000) ,
      @IsEnabled NVARCHAR(10)
    )
AS 
    DECLARE @sql NVARCHAR(4000)
    SET @sql = ''UPDATE PE_WordReplaceItem SET IsEnabled = '' + @IsEnabled
        + '' WHERE ItemID IN ('' + @ItemID + '')''
    EXEC(@sql)' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_AddNum]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_AddNum]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Analytics_AddNum]
    @TableName VARCHAR(100) ,
    @CompareField VARCHAR(100) ,
    @AddField VARCHAR(100) ,
    @Data VARCHAR(4000)
AS 
    BEGIN
        EXEC(''update '' + @TableName +'' set [''+ @AddField +'']=[''+@AddField+'']+1 where ''+@CompareField +'' = ''''''+@Data+'''''''')
        IF @@ROWCOUNT = 0 
            BEGIN
                EXEC(''insert into ''+@TableName+''([''+@CompareField+''],[''+@AddField+'']) values (''''''+@Data+'''''',1)'')
            END
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_ModelTemplates_GetExportList]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_ModelTemplates_GetExportList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_ModelTemplates_GetExportList]
    (
      @TemplateID NVARCHAR(250)
    )
AS 
    EXEC('' SELECT * FROM PE_ModelTemplates WHERE TemplateID IN (''+@TemplateID+'')  ORDER BY TemplateID ASC'')' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_RemindItem_Delete]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_RemindItem_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_RemindItem_Delete]
    (
      @condition VARCHAR(1000)
    )
AS 
    BEGIN
        DECLARE @sql VARCHAR(1100)
        SET @sql = ''delete from pe_remindItem where remindid in('' + @condition
            + '')''
        EXEC (@sql)
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Product_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Product_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Product_Update]
    (
      @Unit NVARCHAR(20) ,
      @Stocks INT ,
      @Weight FLOAT ,
      @SalePromotionType INT ,
      @MinNumber INT ,
      @PresentNumber INT ,
      @PresentId INT ,
      @PresentExp INT ,
      @PresentMoney DECIMAL ,
      @PresentPoint INT ,
      @EliteLevel INT ,
      @UpdateTime DATETIME ,
      @TemplateFile NVARCHAR(255) = '''' ,
      @TaxRate FLOAT ,
      @GeneralIdList NVARCHAR(1000) ,
      @NodeIdList NVARCHAR(1000) ,
      @ModelIdList NVARCHAR(1000)
    )
AS 
    BEGIN
        DECLARE @sql NVARCHAR(1000)
        DECLARE @sqlChild NVARCHAR(1000)
        DECLARE @FieldStr NVARCHAR(20)
	
        SET @sql = ''Select P.ID From PE_CommonModel M inner join PE_CommonProduct P on M.ItemID=P.ProductID and M.TableName=P.TableName''
        IF @GeneralIdList != '''' 
            BEGIN
                SET @sql = @sql + '' where M.GeneralID IN('' + @GeneralIdList
                    + '')''
                SET @sqlChild = '' ('' + @GeneralIdList + '')''
                SET @FieldStr = ''GeneralID''
            END
        ELSE 
            BEGIN
                SET @FieldStr = ''NodeID''
                SET @sql = @sql + '' Where M.NodeID IN('' + @NodeIdList + '')''
                SET @sqlChild = '' ('' + @NodeIdList + '')''
                IF @ModelIdList != '''' 
                    BEGIN
                        SET @sql = @sql + '' And ModelID IN('' + @ModelIdList
                            + '')''
                        SET @sqlChild = @sqlChild + '' And ModelID IN(''
                            + @ModelIdList + '')''
                    END
                ELSE 
                    BEGIN
                        SET @sql = @sql
                            + '' And ModelID IN(Select ModelID From PE_ContentModel Where IsEShop = 1)''
                        SET @sqlChild = @sqlChild
                            + '' And ModelID IN(Select ModelID From PE_ContentModel Where IsEShop = 1)''
                    END				
            END
		--declare @t table(id int)
		--insert into @t exec(@sql)
        DECLARE @UpdateSql NVARCHAR(1000)
        SET @UpdateSql = ''Update PE_CommonProduct Set ID = ID''
		
        IF @Unit != '''' 
            SET @UpdateSql = @UpdateSql + '',Unit='''''' + @Unit + ''''''''
        IF @Stocks != 0 
            SET @UpdateSql = @UpdateSql + '',Stocks=''
                + CONVERT(CHAR(10), @Stocks)
        IF @Weight != 0 
            SET @UpdateSql = @UpdateSql + '',Weight=''
                + CONVERT(CHAR(10), @Weight)
        IF @SalePromotionType != 0 
            SET @UpdateSql = @UpdateSql + '',SalePromotionType=''
                + CONVERT(CHAR(10), @SalePromotionType)
        IF @MinNumber != 0 
            SET @UpdateSql = @UpdateSql + '',MinNumber=''
                + CONVERT(CHAR(10), @MinNumber)
        IF @PresentId != 0 
            SET @UpdateSql = @UpdateSql + '',PresentId=''
                + CONVERT(CHAR(10), @PresentId)
        IF @PresentExp != 0 
            SET @UpdateSql = @UpdateSql + '',PresentExp=''
                + CONVERT(CHAR(10), @PresentExp)
        IF @PresentMoney != 0 
            SET @UpdateSql = @UpdateSql + '',PresentMoney=''
                + CONVERT(CHAR(10), @PresentMoney)
        IF @PresentPoint != 0 
            SET @UpdateSql = @UpdateSql + '',PresentPoint=''
                + CONVERT(CHAR(10), @PresentPoint)
        IF @TaxRate != 0 
            SET @UpdateSql = @UpdateSql + '',TaxRate=''
                + CONVERT(CHAR(10), @TaxRate)

        SET @UpdateSql = @UpdateSql + ''Where ID IN ('' + @sql + '')''
		
        EXEC(@UpdateSql)
		
        DECLARE @UpdateSql1 NVARCHAR(1000)
        SET @UpdateSql1 = ''Update PE_CommonModel Set GeneralID = GeneralID''
        IF @EliteLevel != 0 
            SET @UpdateSql1 = @UpdateSql1 + '',EliteLevel=''
                + CONVERT(CHAR(10), @EliteLevel)
        IF @UpdateTime != '''' 
            SET @UpdateSql1 = @UpdateSql1 + '',UpdateTime=''''''
                + CONVERT(CHAR(10), @UpdateTime) + ''''''''
        IF @TemplateFile != '''' 
            SET @UpdateSql1 = @UpdateSql1 + '',TemplateFile='''''' + @TemplateFile
                + ''''''''
			
        EXEC(@UpdateSql1+'' WHERE	''+@FieldStr+'' IN''+@sqlChild)
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_SaleCount_GetList]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_SaleCount_GetList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_SaleCount_GetList]
    (
      @StartRows INT ,
      @PageSize INT ,
      @InfoType VARCHAR(100) ,
      @SortColumn VARCHAR(1000) ,
      @StrColumn VARCHAR(1000) ,
      @Sorts VARCHAR(100) ,
      @Filter VARCHAR(1000) ,
      @TableName VARCHAR(1000) ,
      @Total INT OUTPUT
    )
AS 
    SET NOCOUNT ON

    BEGIN
        IF @StartRows <= 0 
            SET @StartRows = 0
        SET @StartRows = @StartRows + 1
        IF @PageSize < 1 
            SET @PageSize = 10
        DECLARE @operator CHAR(2)
        DECLARE @strSortColumn VARCHAR(10)
	
        IF CHARINDEX(''DESC'', @Sorts) > 0 
            BEGIN
                SET @strSortColumn = REPLACE(@Sorts, ''DESC'', '''')
                SET @operator = ''<=''
            END
        ELSE 
            BEGIN
                IF CHARINDEX(''ASC'', @Sorts) = 0 
                    SET @strSortColumn = REPLACE(@Sorts, ''ASC'', '''')
                SET @operator = ''>=''
            END

        DECLARE @strFilter VARCHAR(1000)
        DECLARE @strSimpleFilter VARCHAR(1000)

        IF @InfoType = ''NoDeliver'' 
            SET @Filter = '' I.OrderID in (select OrderID from PE_Orders where (MoneyReceipt>=MoneyTotal or MoneyReceipt>0) And DeliverStatus<>-1 AND DeliverStatus<=4) ''
                + @Filter
        ELSE 
            SET @Filter = '' I.OrderID in (select OrderID from PE_Orders where MoneyReceipt>=MoneyTotal) ''
                + @Filter

        IF @Filter IS NOT NULL
            AND @Filter != '''' 
            BEGIN
                SET @strFilter = '' WHERE '' + @Filter + '' ''
                SET @strSimpleFilter = '' AND '' + @Filter + '' ''
            END
        ELSE 
            BEGIN	
                SET @strFilter = ''''
                SET @strSimpleFilter = ''''
            END


        EXEC(
        ''DECLARE @SortId int '' +
        ''SET ROWCOUNT ''+ @StartRows + ''
        SELECT @SortId = ''+ @SortColumn + '' FROM ''+ @TableName + @strFilter +'' GROUP BY I.ProductID,I.TableName ORDER BY ''+ @SortColumn + '' '' +@Sorts +''
        SET ROWCOUNT ''+ @PageSize  + ''
        SELECT ''+ @StrColumn +'' FROM ''+ @TableName + @strFilter + '' 
        GROUP BY I.ProductID,I.TableName Having '' + @SortColumn  + @operator +'' @SortId  ORDER BY ''+ @SortColumn +'' ''+ @Sorts + ''''
        )


        DECLARE @Sql NVARCHAR(4000)

        SET @Sql = N''SELECT @Total=Count(DISTINCT I.ProductID,I.TableName) FROM ''
            + @TableName + @strFilter
        EXEC sp_executesql @Sql, N''@Total Int Out'', @Total OUT 
        RETURN @Total
    END

    SET ROWCOUNT 0

    SET NOCOUNT OFF' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_BatchMove]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_BatchMove]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_Users_BatchMove]
    (
      @UserType INT = 1 ,
      @GroupId NVARCHAR(500) = '''' ,
      @UserId NVARCHAR(4000) = '''' ,
      @UserName NVARCHAR(255) = '''' ,
      @StartUserId INT = 0 ,
      @EndUserId INT = 0 ,
      @BatchUserGroupId NVARCHAR(500) = ''''
    )
AS 
    BEGIN
        SET NOCOUNT OFF
        IF ( @UserType = 1 ) 
            BEGIN
                EXEC(''Update PE_Users set GroupID= '' + @GroupId +'' Where UserID  in ('' + @UserId + '')'')
            END
        ELSE 
            IF ( @UserType = 2 ) 
                BEGIN
                    EXEC(''Update PE_Users set GroupID= '' + @GroupId +'' Where UserName  in ('''''' + @UserName + '''''')'')	
                END
            ELSE 
                IF ( @UserType = 3 ) 
                    BEGIN
                        EXEC(''Update PE_Users set GroupID= '' + @GroupId +'' Where UserId between '' + @StartUserId + '' and '' + @EndUserId)	
                    END
                ELSE 
                    IF ( @UserType = 4 ) 
                        BEGIN
                            EXEC(''Update PE_Users set GroupID= '' + @GroupId +'' Where GroupID  in ('' + @BatchUserGroupId + '')'')	
                        END
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_ShoppingCart_GetList]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_ShoppingCart_GetList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_ShoppingCart_GetList]
    (
      @StartRows INT ,
      @PageSize INT ,
      @SortColumnDbType VARCHAR(100) , --排序字段的数值类型 如 Int ,DateTime等
      @SortColumn VARCHAR(1000) ,
      @StrColumn VARCHAR(1000) ,
      @Sorts VARCHAR(100) ,
      @Filter VARCHAR(1000) ,
      @TableName VARCHAR(1000) ,
      @Total INT OUTPUT
    )
AS 
    SET NOCOUNT ON

    BEGIN
        IF @StartRows <= 0 
            SET @StartRows = 0

        IF @PageSize < 1 
            SET @PageSize = 10

        DECLARE @equalOperator CHAR(2)
        IF @StartRows = 0 
            BEGIN
                SET @equalOperator = ''=''
                SET @StartRows = 1
            END
        ELSE 
            SET @equalOperator = ''''
        DECLARE @operator CHAR(2)
        DECLARE @strSortColumn VARCHAR(10)
	
        IF CHARINDEX(''DESC'', @Sorts) > 0 
            BEGIN
                SET @strSortColumn = REPLACE(@Sorts, ''DESC'', '''')
                SET @operator = ''<'' + @equalOperator
            END
        ELSE 
            BEGIN
                IF CHARINDEX(''ASC'', @Sorts) = 0 
                    SET @strSortColumn = REPLACE(@Sorts, ''ASC'', '''')
                SET @operator = ''>'' + @equalOperator
            END

        DECLARE @strFilter VARCHAR(1000)
        DECLARE @strSimpleFilter VARCHAR(1000)

        IF @Filter IS NOT NULL
            AND @Filter != '''' 
            BEGIN
                SET @strFilter = '' WHERE '' + @Filter + '' ''
                SET @strSimpleFilter = '' AND '' + @Filter + '' ''
            END
        ELSE 
            BEGIN	
                SET @strFilter = ''''
                SET @strSimpleFilter = ''''
            END

        DECLARE @Sql NVARCHAR(4000)
        SET @Sql = N''SELECT @Total=Count(DISTINCT CartID) FROM '' + @TableName
            + @strFilter
        EXEC sp_executesql @Sql, N''@Total Int Out'', @Total OUT 

        EXEC(
        ''DECLARE @SortId ''+ @SortColumnDbType +
        ''DECLARE @StartId int ''+
        ''SET ROWCOUNT ''+ @StartRows + ''
        SELECT @SortId = ''+ @SortColumn + '' FROM ''+ @TableName + @strFilter +'' GROUP BY CartID ORDER BY MIN(CartItemID) '' +@Sorts +''
        SELECT @StartId = CartItemID FROM ''+ @TableName + '' WHERE CartID = @SortId
        SET ROWCOUNT ''+ @PageSize  + ''
        SELECT ''+ @StrColumn +'' FROM ''+ @TableName + '' 
        WHERE CartItemID ''+ @operator +'' @StartId ''+ @strSimpleFilter + '' GROUP BY CartID,CartItemID ORDER BY MIN(CartItemID) ''+ @Sorts + ''''
        )

        RETURN @Total
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Statistics_GetList]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Statistics_GetList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Statistics_GetList]
    (
      @StartRows INT ,
      @PageSize INT ,
      @SortColumn VARCHAR(1000) ,
      @StrColumn VARCHAR(1000) ,
      @Sorts VARCHAR(100) ,
      @Filter VARCHAR(1000) ,
      @TableName VARCHAR(1000) ,
      @ID VARCHAR(255) , --需要排序的不重复的ID号
      @Group VARCHAR(255) ,
      @Total INT OUTPUT
    )
AS 
    IF @PageSize = 0 
        BEGIN
            SET @PageSize = 20
        END

    DECLARE @strFilter VARCHAR(1000)
    DECLARE @strSimpleFilter VARCHAR(1000)

    IF @Filter IS NOT NULL
        AND @Filter != '''' 
        BEGIN
            SET @strFilter = '' WHERE '' + @Filter + '' ''
            SET @strSimpleFilter = '' AND '' + @Filter + '' ''
        END
    ELSE 
        BEGIN	
            SET @strFilter = ''''
            SET @strSimpleFilter = ''''
        END


    DECLARE @Sql NVARCHAR(4000)

    SET @Sql = N''SELECT @Total=(Count(DISTINCT '' + @ID + '')) FROM ''
        + @TableName + @strFilter 
    EXEC sp_executesql @Sql, N''@Total Int Out'', @Total OUT 

    DECLARE @Str NVARCHAR(4000)
    IF @StartRows = 0 
        BEGIN
            SET @Str = ''SELECT TOP '' + CAST(@PageSize AS VARCHAR(20)) + '' ''
                + @StrColumn + '' FROM 
		'' + @TableName + @strFilter + '' '' + @Group + '' ORDER BY ''
                + @SortColumn + '' '' + @Sorts
        END
    ELSE 
        BEGIN
            SET @Str = ''SELECT TOP '' + CAST(@PageSize AS VARCHAR(20)) + '' ''
                + @StrColumn + '' FROM 
		'' + @TableName + ''  WHERE '' + @ID + '' NOT IN (SELECT TOP ''
                + CAST(( @StartRows ) AS VARCHAR(20)) + '' '' + @ID + '' FROM ''
                + @TableName + @strFilter + '' '' + @Group + '' ORDER BY ''
                + @SortColumn + '' '' + @Sorts + '') '' + @strSimpleFilter + '' ''
                + @Group + '' ORDER BY '' + @SortColumn + '' '' + @Sorts
        END
    EXEC sp_ExecuteSql @Str

    RETURN @Total' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_Delete]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Trademark_Delete]
    (
      @TrademarkId NVARCHAR(4000)
    )
AS 
    DECLARE @sql NVARCHAR(4000)
    SET @sql = ''DELETE PE_Trademark WHERE TrademarkID IN ('' + @TrademarkId
        + '')''
    EXEC(@sql)' 
END
GO
/****** Object:  UserDefinedFunction [dbo].[SplitID]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SplitID]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
BEGIN
execute dbo.sp_executesql @statement = N'CREATE  FUNCTION  [dbo].[SplitID] 
(  
     @String  nvarchar(max),  --格式：“1，2，3，4，”
     @SplitChar  nvarchar(10)  --格式：“，”
)  
RETURNS    @table  Table(ID  varchar(100))  
AS  
BEGIN  
   DECLARE  @Index  INT  
   SET  @Index  =  0  

        IF @String <> ''''
        Begin
            IF RIGHT(@String,1)<> @SplitChar 
                SET @String = @String + @SplitChar
            IF LEFT(@String,1)= @SplitChar 
            SET @String = STUFF(@String, 1, 1, '''')
        End
 
       WHILE  CHARINDEX(@SplitChar,@String,@Index)  >  0    
       BEGIN  
           INSERT INTO @table(ID)
               VALUES (SUBSTRING(@String, @Index, CHARINDEX(@SplitChar, @String,
                @Index) - @Index))
               SET @index = CHARINDEX(@SplitChar, @String, @Index) + 1 END  
RETURN  
END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_Delete]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_Users_Delete] ( @UserId NVARCHAR(4000) )
AS 
    DECLARE @sql NVARCHAR(4000)
    SET @sql = ''DELETE PE_Users WHERE UserID IN ('' + @UserId + '')''
    EXEC(@sql)' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_BatchUnLock]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_BatchUnLock]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_Users_BatchUnLock]
    (
      @strUserID VARCHAR(4000) ,
      @LockState INT ,
      @ApproveState INT
	
    )
AS
    DECLARE @Status BIT
    DECLARE @UserId INT
    DECLARE @split VARCHAR(1)
	
    SET @split = '',''
    SET @strUserId = @strUserId + '',''
	
    WHILE CHARINDEX(@split, @strUserId) > 0 
        BEGIN
            SET @UserId = CONVERT(INT, LEFT(@strUserId,
                                            CHARINDEX(@split, @strUserId) - 1))
            SET @strUserId = STUFF(@strUserId, 1,
                                   CHARINDEX(@split, @strUserId), '''')
	
            UPDATE  PE_Users
            SET     [Status] = @ApproveState
            WHERE   UserId = @UserId
                    AND [Status] = @LockState
        END
	
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserValidLog_Exists]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserValidLog_Exists]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_UserValidLog_Exists]
    (
      @UserName NVARCHAR(100)
    )
AS 
    SELECT  COUNT(*)
    FROM    PE_ValidLog
    WHERE   UserName = @UserName' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserValidLog_DeleteUser]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserValidLog_DeleteUser]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_UserValidLog_DeleteUser]
    (
      @UserName VARCHAR(4000)
    )
AS 
    SET NOCOUNT OFF
    BEGIN 
	 
        DELETE  FROM PE_ValidLog
        WHERE   UserName IN ( @UserName )
	 
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserValidLog_Delete]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserValidLog_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_UserValidLog_Delete] ( @Date DATETIME )
AS 
    SET NOCOUNT OFF
    BEGIN 
	 
        DELETE  FROM PE_ValidLog
        WHERE   LogTime < @Date
	 
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserValidLog_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserValidLog_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_UserValidLog_Add]
    (
      @LogID INT ,
      @UserName NVARCHAR(100) ,
      @ValidNum INT ,
      @IncomePayOut INT ,
      @LogTime DATETIME ,
      @Remark NTEXT ,
      @IP NVARCHAR(100) ,
      @Inputer NVARCHAR(100) ,
      @Memo NTEXT
    )
AS
    INSERT  INTO PE_ValidLog
            ( UserName ,
              ValidNum ,
              IncomePayout ,
              LogTime ,
              Remark ,
              IP ,
              Inputer ,
              Memo
            )
    VALUES  ( @UserName ,
              @ValidNum ,
              @IncomePayout ,
              @LogTime ,
              @Remark ,
              @IP ,
              @Inputer ,
              @Memo
            )  
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_UpdateUserStatus]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_UpdateUserStatus]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_Users_UpdateUserStatus]
    (
      @UserID INT ,
      @Status INT
    )
AS 
    UPDATE  PE_Users
    SET     [Status] = @Status
    WHERE   UserID = @UserID
	
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_Users_Update]
    (
      @UserID INT ,
      @GroupID INT ,
      @CompanyID INT ,
      @ClientID INT ,
      @UserType INT ,
      @UserName NVARCHAR(100) ,
      @UserPassword NVARCHAR(32) ,
      @LastPassword NVARCHAR(32) ,
      @Question NVARCHAR(50) ,
      @Answer NVARCHAR(50) ,
      @Email NVARCHAR(100) ,
      @Sex INT ,
      @RegTime DATETIME ,
      @JoinTime DATETIME ,
      @LoginTimes INT ,
      @LastLoginTime DATETIME ,
      @LastPresentTime DATETIME ,
      @LastLoginIP NVARCHAR(50) ,
      @LastPasswordChangedTime DATETIME ,
      @LastLockoutTime DATETIME ,
      @FailedPasswordAttemptCount INT ,
      @FirstFailedPasswordAttempTime DATETIME ,
      @FailedPasswordAnswerAttempCount INT ,
      @FirstFailedPasswordAnswerAttempTime DATETIME ,
      @Status INT ,
      @CheckNum CHAR(10) ,
      @EnableResetPassword BIT ,
      @UserCultureName NVARCHAR(10) ,
      @UserFace NVARCHAR(255) ,
      @FaceWidth INT ,
      @FaceHeight INT ,
      @Sign NTEXT ,
      @PrivacySetting INT ,
      @Balance MONEY ,
      @UserPoint INT ,
      @UserExp INT ,
      @ConsumeMoney INT ,
      @ConsumePoint INT ,
      @ConsumeExp INT ,
      @PostItems INT ,
      @PassedItems INT ,
      @RejectItems INT ,
      @DelItems INT ,
      @EndTime DATETIME ,
      @IsInheritGroupRole BIT ,
      @TrueName NVARCHAR(255) ,
      @PayPassword NVARCHAR(32) ,
      @IsShowUpgradeTipsFalse BIT ,
      @LastAddPointTime DATETIME ,
      @GetPasswordSid NVARCHAR(32) ,
      @GetPasswordTime DATETIME ,
      @HonorType INT
    )
AS 
    UPDATE  [PE_Users]
    SET     [UserID] = @UserID ,
            [GroupID] = @GroupID ,
            [CompanyID] = @CompanyID ,
            [ClientID] = @ClientID ,
            [UserType] = @UserType ,
            [UserName] = @UserName ,
            [UserPassword] = @UserPassword ,
            [LastPassword] = @LastPassword ,
            [Question] = @Question ,
            [Answer] = @Answer ,
            [Email] = @Email ,
            [Sex] = @Sex ,
            [RegTime] = @RegTime ,
            [JoinTime] = @JoinTime ,
            [LoginTimes] = @LoginTimes ,
            [LastLoginTime] = @LastLoginTime ,
            [LastPresentTime] = @LastPresentTime ,
            [LastLoginIP] = @LastLoginIP ,
            [LastPasswordChangedTime] = @LastPasswordChangedTime ,
            [LastLockoutTime] = @LastLockoutTime ,
            [FailedPasswordAttemptCount] = @FailedPasswordAttemptCount ,
            [FirstFailedPasswordAttempTime] = @FirstFailedPasswordAttempTime ,
            [FailedPasswordAnswerAttempCount] = @FailedPasswordAnswerAttempCount ,
            [FirstFailedPasswordAnswerAttempTime] = @FirstFailedPasswordAnswerAttempTime ,
            [Status] = @Status ,
            [CheckNum] = @CheckNum ,
            [EnableResetPassword] = @EnableResetPassword ,
            [UserCultureName] = @UserCultureName ,
            [UserFace] = @UserFace ,
            [FaceWidth] = @FaceWidth ,
            [FaceHeight] = @FaceHeight ,
            [Sign] = @Sign ,
            [PrivacySetting] = @PrivacySetting ,
            [Balance] = @Balance ,
            [UserPoint] = @UserPoint ,
            [UserExp] = @UserExp ,
            [ConsumeMoney] = @ConsumeMoney ,
            [ConsumePoint] = @ConsumePoint ,
            [ConsumeExp] = @ConsumeExp ,
            [PostItems] = @PostItems ,
            [PassedItems] = @PassedItems ,
            [RejectItems] = @RejectItems ,
            [DelItems] = @DelItems ,
            [EndTime] = @EndTime ,
            [IsInheritGroupRole] = @IsInheritGroupRole ,
            [TrueName] = @TrueName ,
            [PayPassword] = @PayPassword ,
            [IsShowUpgradeTipsFalse] = @IsShowUpgradeTipsFalse ,
            [LastAddPointTime] = @LastAddPointTime ,
            [GetPasswordSid] = @GetPasswordSid ,
            [GetPasswordTime] = @GetPasswordTime ,
            [HonorType] = @HonorType
    WHERE   [UserID] = @UserID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_GetById]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_GetById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_Users_GetById] ( @UserID INT )
AS 
    SELECT  *
    FROM    PE_Users
    WHERE   UserID = @UserID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Trademark_Add]
    (
      @TrademarkName NVARCHAR(200) ,
      @TrademarkType INT ,
      @ProducerID INT ,
      @IsElite BIT ,
      @TrademarkPhoto NVARCHAR(255) ,
      @TrademarkIntro NTEXT,
      @SearchIndex Char(1),
	  @TrademarkShortIntro NVARCHAR(500),
      @TrademarkBeginDate DATETIME,
      @TrademarkAdBannerPhoto NVARCHAR(100) ,
	  @TrademarkAdMultiPhoto NVARCHAR(500) ,
	  @TrademarkAdMiddlePhoto NVARCHAR(100) 
    )
AS 
    INSERT  INTO PE_Trademark
            ( TrademarkName ,
              TrademarkType ,
              ProducerID ,
              IsElite ,
              TrademarkPhoto ,
              TrademarkIntro ,
              Passed,
              SearchIndex,
			  TrademarkShortIntro,
	          TrademarkBeginDate,
              TrademarkAdBannerPhoto,
              TrademarkAdMultiPhoto,
              TrademarkAdMiddlePhoto
            )
    VALUES  ( @TrademarkName ,
              @TrademarkType ,
              @ProducerID ,
              @IsElite ,
              @TrademarkPhoto ,
              @TrademarkIntro ,
              1,
              @SearchIndex,
			  @TrademarkShortIntro,
		      @TrademarkBeginDate,
		      @TrademarkAdBannerPhoto,
		      @TrademarkAdMultiPhoto,
		      @TrademarkAdMiddlePhoto 
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_ShoppingCarts_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_ShoppingCarts_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_ShoppingCarts_Add]
    (
      @UserName NVARCHAR(100) ,
      @CartID NVARCHAR(50) ,
      @ProductID INT ,
      @Quantity INT ,
      @IsPresent BIT ,
      @UpdateTime DATETIME ,
      @TableName NVARCHAR(200) ,
      @Property NVARCHAR(50) ,
      @BelongsToProductID INT,
	  @GroupBuyID INT,
	  @SecondsKillID INT
    )
AS 
    INSERT  INTO PE_ShoppingCarts
            ( UserName ,
              CartID ,
              ProductID ,
              Quantity ,
              IsPresent ,
              UpdateTime ,
              TableName ,
              Property ,
              BelongsToProductID,
              GroupBuyID,
			  SecondsKillID	
	      )
    VALUES  ( @UserName ,
              @CartID ,
              @ProductID ,
              @Quantity ,
              @IsPresent ,
              @UpdateTime ,
              @TableName ,
              @Property ,
              @BelongsToProductID,
              @GroupBuyID,
			  @SecondsKillID	
	      )
	
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_SendBackItem_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_SendBackItem_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_SendBackItem_Add]
    @ItemID INT ,
    @SendBackID INT ,
    @ProductID INT ,
    @Property NVARCHAR(510) ,
    @Amount INT ,
    @Price MONEY ,
    @TableName NVARCHAR(510)
AS 
    INSERT  INTO PE_SendBackItem
            ( ItemID ,
              SendBackID ,
              ProductID ,
              [Property] ,
              Amount ,
              Price ,
              [TableName]
            )
    VALUES  ( @ItemID ,
              @SendBackID ,
              @ProductID ,
              @Property ,
              @Amount ,
              @Price ,
              @TableName
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_SendBack_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_SendBack_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_SendBack_Update]
    @SendBackID INT ,
    @SendBackNum NVARCHAR(40) ,
    @InputTime DATETIME ,
    @Inputer NVARCHAR(100) ,
    @Status INT ,
    @Remark NVARCHAR(510)
AS 
    UPDATE  PE_SendBack
    SET     SendBackNum = @SendBackNum ,
            InputTime = @InputTime ,
            Inputer = @Inputer ,
            Status = @Status ,
            Remark = @Remark
    WHERE   SendBackID = @SendBackID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_SendBack_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_SendBack_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_SendBack_Add]
    @SendBackID INT ,
    @SendBackNum NVARCHAR(40) ,
    @InputTime DATETIME ,
    @Inputer NVARCHAR(100) ,
    @Status INT ,
    @Remark NVARCHAR(510)
AS 
    INSERT  INTO PE_SendBack
            ( SendBackID ,
              SendBackNum ,
              InputTime ,
              Inputer ,
              Status ,
              Remark
            )
    VALUES  ( @SendBackID ,
              @SendBackNum ,
              @InputTime ,
              @Inputer ,
              @Status ,
              @Remark
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_BatchLock]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_BatchLock]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_Users_BatchLock]
    (
      @strUserID VARCHAR(4000) ,
      @LockState INT ,
      @ApproveState INT
    )
AS 
    DECLARE @UserId INT
    DECLARE @split VARCHAR(1)
	
    SET @split = '',''
    SET @strUserId = @strUserId + '',''
	
    WHILE CHARINDEX(@split, @strUserId) > 0 
        BEGIN
            SET @UserId = CONVERT(INT, LEFT(@strUserId,
                                            CHARINDEX(@split, @strUserId) - 1))
            SET @strUserId = STUFF(@strUserId, 1,
                                   CHARINDEX(@split, @strUserId), '''')
	
            UPDATE  PE_Users
            SET     [Status] = @LockState ,
                    LastLockoutTime = GETDATE()
            WHERE   UserId = @UserId
                    AND [Status] = @ApproveState
        END
	
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_BatchInquire]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_BatchInquire]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_Users_BatchInquire]
    (
      @UserType INT ,
      @Id NVARCHAR(4000) ,
      @EndTime DATETIME
    )
AS 
    BEGIN
        SET NOCOUNT OFF
				
        IF ( @UserType = 0 ) 
            BEGIN
                UPDATE  PE_Users
                SET     EndTime = @EndTime 
            END
        ELSE 
            IF ( @UserType = 1 ) 
                BEGIN
                    UPDATE  PE_Users
                    SET     EndTime = @EndTime
                    WHERE   GroupId IN ( @Id )
                END
            ELSE 
                IF ( @UserType = 2 ) 
                    BEGIN
                        UPDATE  PE_Users
                        SET     EndTime = @EndTime
                        WHERE   UserId IN ( @Id )
                    END
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Users_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Users_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_Users_Add]
    (
      @UserID INT ,
      @GroupID INT ,
      @CompanyID INT ,
      @ClientID INT ,
      @UserType INT ,
      @UserName NVARCHAR(100) ,
      @UserPassword NVARCHAR(32) ,
      @LastPassword NVARCHAR(32) ,
      @Question NVARCHAR(50) ,
      @Answer NVARCHAR(50) ,
      @Email NVARCHAR(100) ,
      @Sex INT ,
      @RegTime DATETIME ,
      @JoinTime DATETIME ,
      @LoginTimes INT ,
      @LastLoginTime DATETIME ,
      @LastPresentTime DATETIME ,
      @LastLoginIP NVARCHAR(255) ,
      @LastPasswordChangedTime DATETIME ,
      @LastLockoutTime DATETIME ,
      @FailedPasswordAttemptCount INT ,
      @FirstFailedPasswordAttempTime DATETIME ,
      @FailedPasswordAnswerAttempCount INT ,
      @FirstFailedPasswordAnswerAttempTime DATETIME ,
      @Status INT ,
      @CheckNum CHAR(10) ,
      @EnableResetPassword BIT ,
      @UserCultureName NVARCHAR(10) ,
      @UserFace NVARCHAR(255) ,
      @FaceWidth INT ,
      @FaceHeight INT ,
      @Sign NTEXT ,
      @PrivacySetting INT ,
      @Balance MONEY ,
      @UserPoint INT ,
      @UserExp INT ,
      @ConsumeMoney INT ,
      @ConsumePoint INT ,
      @ConsumeExp INT ,
      @PostItems INT ,
      @PassedItems INT ,
      @RejectItems INT ,
      @DelItems INT ,
      @EndTime DATETIME ,
      @IsInheritGroupRole BIT ,
      @UserFriendGroup NVARCHAR(255) ,
      @TrueName NVARCHAR(255) ,
      @PayPassword NVARCHAR(32) ,
      @IsShowUpgradeTipsFalse BIT ,
      @LastAddPointTime DATETIME ,
      @GetPasswordSid NVARCHAR(32) ,
      @GetPasswordTime DATETIME ,
      @AlipayUserID NVARCHAR(16) ,
      @HonorType INT 
    )
AS 
    INSERT  INTO [PE_Users]
            ( [UserID] ,
              [GroupID] ,
              [CompanyID] ,
              [ClientID] ,
              [UserType] ,
              [UserName] ,
              [UserPassword] ,
              [LastPassword] ,
              [Question] ,
              [Answer] ,
              [Email] ,
              [Sex] ,
              [RegTime] ,
              [JoinTime] ,
              [LoginTimes] ,
              [LastLoginTime] ,
              [LastPresentTime] ,
              [LastLoginIP] ,
              [LastPasswordChangedTime] ,
              [LastLockoutTime] ,
              [FailedPasswordAttemptCount] ,
              [FirstFailedPasswordAttempTime] ,
              [FailedPasswordAnswerAttempCount] ,
              [FirstFailedPasswordAnswerAttempTime] ,
              [Status] ,
              [CheckNum] ,
              [EnableResetPassword] ,
              [UserCultureName] ,
              [UserFace] ,
              [FaceWidth] ,
              [FaceHeight] ,
              [Sign] ,
              [PrivacySetting] ,
              [Balance] ,
              [UserPoint] ,
              [UserExp] ,
              [ConsumeMoney] ,
              [ConsumePoint] ,
              [ConsumeExp] ,
              [PostItems] ,
              [PassedItems] ,
              [RejectItems] ,
              [DelItems] ,
              [EndTime] ,
              [IsInheritGroupRole] ,
              [UserFriendGroup] ,
              [TrueName] ,
              [PayPassword] ,
              [IsShowUpgradeTipsFalse] ,
              [LastAddPointTime] ,
              [GetPasswordSid] ,
              [GetPasswordTime] ,
              [Alipay_UserID] ,
              [HonorType]
		)
    VALUES  ( @UserID ,
              @GroupID ,
              @CompanyID ,
              @ClientID ,
              @UserType ,
              @UserName ,
              @UserPassword ,
              @LastPassword ,
              @Question ,
              @Answer ,
              @Email ,
              @Sex ,
              @RegTime ,
              @JoinTime ,
              @LoginTimes ,
              @LastLoginTime ,
              @LastPresentTime ,
              @LastLoginIP ,
              @LastPasswordChangedTime ,
              @LastLockoutTime ,
              @FailedPasswordAttemptCount ,
              @FirstFailedPasswordAttempTime ,
              @FailedPasswordAnswerAttempCount ,
              @FirstFailedPasswordAnswerAttempTime ,
              @Status ,
              @CheckNum ,
              @EnableResetPassword ,
              @UserCultureName ,
              @UserFace ,
              @FaceWidth ,
              @FaceHeight ,
              @Sign ,
              @PrivacySetting ,
              @Balance ,
              @UserPoint ,
              @UserExp ,
              @ConsumeMoney ,
              @ConsumePoint ,
              @ConsumeExp ,
              @PostItems ,
              @PassedItems ,
              @RejectItems ,
              @DelItems ,
              @EndTime ,
              @IsInheritGroupRole ,
              @UserFriendGroup ,
              @TrueName ,
              @PayPassword ,
              @IsShowUpgradeTipsFalse ,
              @LastAddPointTime ,
              @GetPasswordSid ,
              @GetPasswordTime ,
              @AlipayUserID ,
              @HonorType
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserPointLog_UserPointSum]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserPointLog_UserPointSum]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_UserPointLog_UserPointSum]
    (
      @SumType INT ,
      @UserName NVARCHAR(100)
    )
AS 
    SET NOCOUNT OFF
    IF ( @SumType = 1 ) 
        BEGIN
            SELECT  SUM(Point)
            FROM    PE_PointLog
            WHERE   IncomePayout = 1
                    AND UserName = @UserName
        END
    ELSE 
        BEGIN
            SELECT  SUM(Point)
            FROM    PE_PointLog
            WHERE   IncomePayout = 2
                    AND UserName = @UserName
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserPointLog_UpdateTimes]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserPointLog_UpdateTimes]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_UserPointLog_UpdateTimes]
    (
      @Id INT ,
      @Ip NVARCHAR(100)
    )
AS 
    SET NOCOUNT OFF

    BEGIN
        UPDATE  PE_PointLog
        SET     Times = Times + 1 ,
                IP = @Ip
        WHERE   LogID = @Id 
    END

    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserPointLog_PointSum]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserPointLog_PointSum]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_UserPointLog_PointSum] ( @SumType INT )
AS 
    SET NOCOUNT OFF
    IF ( @SumType = 1 ) 
        BEGIN
            SELECT  SUM(Point)
            FROM    PE_PointLog
            WHERE   IncomePayout = 1
        END
    ELSE 
        BEGIN
            SELECT  SUM(Point)
            FROM    PE_PointLog
            WHERE   IncomePayout = 2
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserPointLog_Exists]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserPointLog_Exists]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_UserPointLog_Exists]
    (
      @UserName NVARCHAR(100)
    )
AS 
    SELECT  UserName
    FROM    PE_PointLog
    WHERE   UserName = @UserName' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserPointLog_DeleteUser]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserPointLog_DeleteUser]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_UserPointLog_DeleteUser]
    (
      @UserName VARCHAR(4000)
    )
AS 
    SET NOCOUNT OFF
    BEGIN 
	 
        DELETE  FROM PE_PointLog
        WHERE   UserName IN ( @UserName )
	 
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserPointLog_Delete]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserPointLog_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_UserPointLog_Delete]
    (
      @Date DATETIME ,
      @IsDelConsume BIT
	
    )
AS 
    SET NOCOUNT OFF
    BEGIN  
        DELETE  PE_PointLog
        WHERE   LogTime < @Date
                AND ( IsConsume IS NULL
                      OR IsConsume <= @IsDelConsume
                    )
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserPointLog_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserPointLog_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_UserPointLog_Add]
    (
      @LogID INT ,
      @UserName NVARCHAR(100) ,
      @ModuleType INT ,
      @InfoID INT ,
      @Point REAL ,
      @LogTime DATETIME ,
      @Times INT ,
      @IncomePayOut INT ,
      @Remark NTEXT ,
      @IP NVARCHAR(100) ,
      @Inputer NVARCHAR(100) ,
      @Memo NTEXT ,
      @IsConsume BIT
    )
AS
    INSERT  INTO PE_PointLog
            ( UserName ,
              ModuleType ,
              InfoID ,
              Point ,
              LogTime ,
              Times ,
              IncomePayOut ,
              Remark ,
              IP ,
              Inputer ,
              Memo ,
              IsConsume
            )
    VALUES  ( @UserName ,
              @ModuleType ,
              @InfoID ,
              @Point ,
              @LogTime ,
              @Times ,
              @IncomePayOut ,
              @Remark ,
              @IP ,
              @Inputer ,
              @Memo ,
              @IsConsume
            )  
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserNameIsRepeat]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserNameIsRepeat]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_UserNameIsRepeat]
    (
      @UserName NVARCHAR(4000)
    )
AS 
    BEGIN
        SET NOCOUNT ON
        DECLARE @Total INT 
	
        SELECT  @Total = COUNT(*)
        FROM    PE_Users
        WHERE   UserName = @UserName
	
        RETURN @Total
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserGroups_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserGroups_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_UserGroups_Update]
    (
      @GroupID INT ,
      @GroupName NVARCHAR(20) ,
      @Description NTEXT ,
      @Settings NTEXT ,
      @GroupType INT ,
      @GroupSetting NTEXT ,
      @UpgradeSetting NTEXT  
    )
AS 
    UPDATE  [PE_UserGroups]
    SET     [GroupName] = @GroupName ,
            [Description] = @Description ,
            [Settings] = @Settings ,
            [GroupType] = @GroupType ,
            [GroupSetting] = @GroupSetting ,
            [UpgradeSetting] = @UpgradeSetting
    WHERE   [GroupID] = @GroupID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_UserGroups_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_UserGroups_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_UserGroups_Add]
    (
      @GroupID INT ,
      @GroupName NVARCHAR(20) ,
      @Description NTEXT ,
      @Settings NTEXT ,
      @GroupType INT ,
      @GroupSetting NTEXT ,
      @UpgradeSetting NTEXT
    )
AS 
    INSERT  INTO [PE_UserGroups]
            ( [GroupID] ,
              [GroupName] ,
              [Description] ,
              [Settings] ,
              [GroupType] ,
              [GroupSetting] ,
              [UpgradeSetting]
		)
    VALUES  ( @GroupID ,
              @GroupName ,
              @Description ,
              @Settings ,
              @GroupType ,
              @GroupSetting ,
              @UpgradeSetting
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_User_Exists]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_User_Exists]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_User_Exists]
    (
      @UserName NVARCHAR(250)
    )
AS 
    SELECT  COUNT(*)
    FROM    PE_Users
    WHERE   UserName = @UserName' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Cards_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Cards_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_Cards_Update]
    (
      @CardID INT ,    --充值卡ID
      @CardType INT ,    --充值卡类型
      @ProductID INT ,    --充值卡所属商品
      @TableName NVARCHAR(255) ,
      @CardNum NVARCHAR(30) ,    --卡号
      @Password NVARCHAR(50) ,    --密码
      @AgentName NVARCHAR(100) ,    --代理商
      @Money MONEY ,    --面值
      @ValidNum INT ,    --点数
      @ValidUnit INT ,    --点数单位
      @EndDate DATETIME ,    --截止日期
      @UserName NVARCHAR(100) ,    --使用者
      @UseTime DATETIME ,    --充值时间
      @CreateTime DATETIME ,    --生成时间
      @OrderItemID INT    --售出
    )
AS 
    UPDATE  [PE_Cards]
    SET     [CardType] = @CardType ,    --充值卡类型
            [ProductID] = @ProductID ,    --充值卡所属商品
            [TableName] = @TableName ,
            [CardNum] = @CardNum ,    --卡号
            [Password] = @Password ,    --密码
            [AgentName] = @AgentName ,    --代理商
            [Money] = @Money ,    --面值
            [ValidNum] = @ValidNum ,    --点数
            [ValidUnit] = @ValidUnit ,    --点数单位
            [EndDate] = @EndDate ,    --截止日期
            [UserName] = @UserName ,    --使用者
            [UseTime] = @UseTime ,    --充值时间
            [CreateTime] = @CreateTime ,    --生成时间
            [OrderItemID] = @OrderItemID    --售出
    WHERE   [CardID] = @CardID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_UserManage_Cards_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_UserManage_Cards_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_UserManage_Cards_Add]
    (
      @CardType INT ,
      @ProductID INT ,
      @TableName NVARCHAR(255) = '''' ,
      @CardNum NVARCHAR(30) ,
      @Password NVARCHAR(50) ,
      @AgentName NVARCHAR(100) ,
      @Money MONEY ,
      @ValidNum INT ,
      @ValidUnit INT ,
      @EndDate DATETIME ,
      @UserName NVARCHAR(100) ,
      @CreateTime DATETIME ,
      @OrderItemID INT ,
      @ProductName NVARCHAR(255)
    )
AS 
    IF EXISTS ( SELECT  *
                FROM    PE_Cards
                WHERE   CardNum = @CardNum
                        AND Password = @Password
                        AND ProductID = @ProductID ) 
        BEGIN
            RETURN 0 --存在着相同的充值卡,不添加记录,返回 0
        END
    ELSE 
        BEGIN
            INSERT  INTO [PE_Cards]
                    ( [CardType] ,
                      [ProductID] ,
                      [TableName] ,
                      [CardNum] ,
                      [Password] ,
                      [AgentName] ,
                      [Money] ,
                      [ValidNum] ,
                      [ValidUnit] ,
                      [EndDate] ,
                      [UserName] ,
                      [CreateTime] ,
                      [OrderItemID] ,
                      [ProductName]
                    )
            VALUES  ( @CardType ,
                      @ProductID ,
                      @TableName ,
                      @CardNum ,
                      @Password ,
                      @AgentName ,
                      @Money ,
                      @ValidNum ,
                      @ValidUnit ,
                      @EndDate ,
                      @UserName ,
                      @CreateTime ,
                      @OrderItemID ,
                      @ProductName
                    ) 
            RETURN @@ROWCOUNT
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Survey_SurveyVote_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Survey_SurveyVote_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Survey_SurveyVote_Add]
    (
      @SurveyId INT ,
      @QuestionId INT ,
      @OptionCount INT 
    )
AS 
    DECLARE @option INT
    SET @option = 0

    WHILE ( @option < @OptionCount ) 
        BEGIN
            INSERT  INTO [PE_SurveyVote]
                    ( SurveyId, QuestionId, OptionId )
            VALUES  ( @SurveyId, @QuestionId, @option )
            SET @option = @option + 1
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Survey_SurveyManager_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Survey_SurveyManager_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Survey_SurveyManager_Update]
    (
      @SurveyID INT ,
      @SurveyName NVARCHAR(50) ,
      @Description NTEXT ,
      @FileName NVARCHAR(50) ,
      @IPRepeat INT ,
      @CreateDate DATETIME ,
      @EndTime DATETIME ,
      @IsOpen INT ,
      @NeedLogin INT ,
      @PresentPoint INT ,
      @LockIPType INT ,
      @SetIPLock NTEXT ,
      @LockUrl NTEXT ,
      @SetPassword NVARCHAR(50) ,
      @Template NVARCHAR(255),
      @QuestionField NTEXT,
      @QuestionMaxID INT,
      @IsResultPublic BIT      
    )
AS 
    UPDATE  [PE_Survey]
    SET     [SurveyName] = @SurveyName ,
            [Description] = @Description ,
            [FileName] = @FileName ,
            [IPRepeat] = @IPRepeat ,
            [CreateDate] = @CreateDate ,
            [EndTime] = @EndTime ,
            [IsOpen] = @IsOpen ,
            [NeedLogin] = @NeedLogin ,
            [PresentPoint] = @PresentPoint ,
            [LockIPType] = @LockIPType ,
            [SetIPLock] = @SetIPLock ,
            [LockUrl] = @LockUrl ,
            [SetPassword] = @SetPassword ,
            [Template] = @Template,
            [QuestionField] = @QuestionField,
            [QuestionMaxID] = @QuestionMaxID,
            [IsResultPublic] = @IsResultPublic
    WHERE   [SurveyID] = @SurveyID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Survey_SurveyManager_SetPassed]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Survey_SurveyManager_SetPassed]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Survey_SurveyManager_SetPassed]
    (
      @SurveyID INT ,
      @TableName NVARCHAR(50)
    )
AS 
    UPDATE  PE_Survey
    SET     IsOpen = 1
    WHERE   SurveyID = @SurveyID
        
    IF OBJECT_ID(@TableName) IS NOT NULL
        BEGIN
            EXEC(''drop table '' +@TableName)
        END
    EXEC(''CREATE TABLE ''+ @TableName+'' ([RecordID] [int] IDENTITY (1, 1) PRIMARY KEY,[SurveyID] [int],[UserName] [nvarchar](255),[IP] [nvarchar](255),[SubmitTime] [datetime])'')' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Survey_SurveyManager_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Survey_SurveyManager_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Survey_SurveyManager_Add]
    (
      @SurveyID INT ,
      @SurveyName NVARCHAR(50) ,
      @Description NTEXT ,
      @FileName NVARCHAR(50) ,
      @IPRepeat INT ,
      @CreateDate DATETIME ,
      @EndTime DATETIME ,
      @IsOpen INT ,
      @NeedLogin INT ,
      @PresentPoint INT ,
      @LockIPType INT ,
      @SetIPLock NTEXT ,
      @LockUrl NTEXT ,
      @SetPassword NVARCHAR(50) ,
      @Template NVARCHAR(255),
      @QuestionField NTEXT,
      @QuestionMaxID INT,
      @IsResultPublic BIT
    )
AS 
    INSERT  INTO [PE_Survey]
            ( [SurveyID] ,
              [SurveyName] ,
              [Description] ,
              [FileName] ,
              [IPRepeat] ,
              [CreateDate] ,
              [EndTime] ,
              [IsOpen] ,
              [NeedLogin] ,
              [PresentPoint] ,
              [LockIPType] ,
              [SetIPLock] ,
              [LockUrl] ,
              [SetPassword] ,
              [Template],
              [QuestionField],
              [QuestionMaxID],
              [IsResultPublic]    
		)
    VALUES  ( @SurveyID ,
              @SurveyName ,
              @Description ,
              @FileName ,
              @IPRepeat ,
              @CreateDate ,
              @EndTime ,
              @IsOpen ,
              @NeedLogin ,
              @PresentPoint ,
              @LockIPType ,
              @SetIPLock ,
              @LockUrl ,
              @SetPassword ,
              @Template,
              @QuestionField,
              @QuestionMaxID,
              @IsResultPublic
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_TransferLog_GetList]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_TransferLog_GetList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_TransferLog_GetList]
AS 
    BEGIN
        SELECT  [TransferLogID] ,    --订单过户记录ID
                [OrderID] ,    --订单ID
                [TransferTime] ,    --过户时间
                [OwnerUserName] ,    --过户人
                [PayerUserName] ,    --付款人
                [TargetUserName] ,    --过户给
                [Poundage] ,    --过户费
                [Inputer] ,    --经手人
                [Remark]    --备注
        FROM    [PE_TransferLog]
        ORDER BY [TransferLogID] DESC

    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_TransferLog_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_TransferLog_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_TransferLog_Add]
    (
      --@TransferLogID int,    --订单过户记录ID
      @OrderID INT ,    --订单ID
      @TransferTime DATETIME ,    --过户时间
      @OwnerUserName NVARCHAR(20) ,    --过户人
      @PayerUserName NVARCHAR(20) ,    --付款人
      @TargetUserName NVARCHAR(20) ,    --过户给
      @Poundage MONEY ,    --过户费
      @Inputer NVARCHAR(20) ,    --经手人
      @Remark NVARCHAR(50)    --备注
	
    )
AS 
    INSERT  INTO [PE_TransferLog]
            ( --[TransferLogID],    --订单过户记录ID
              [OrderID] ,    --订单ID
              [TransferTime] ,    --过户时间
              [OwnerUserName] ,    --过户人
              [PayerUserName] ,    --付款人
              [TargetUserName] ,    --过户给
              [Poundage] ,    --过户费
              [Inputer] ,    --经手人
              [Remark]    --备注
	      )
    VALUES  ( --@TransferLogID,
              @OrderID ,
              @TransferTime ,
              @OwnerUserName ,
              @PayerUserName ,
              @TargetUserName ,
              @Poundage ,
              @Inputer ,
              @Remark
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Trademark_Update]
    (
      @TrademarkID INT ,
      @TrademarkName NVARCHAR(200) ,
      @TrademarkType INT ,
      @ProducerId INT ,
      @IsElite BIT ,
      @TrademarkPhoto NVARCHAR(255) ,
      @TrademarkIntro NTEXT	,
      @SearchIndex Char(1),
	  @TrademarkShortIntro NVARCHAR(500),
      @TrademarkBeginDate DATETIME,
      @TrademarkAdBannerPhoto NVARCHAR(100) ,
	  @TrademarkAdMultiPhoto NVARCHAR(500) ,
	  @TrademarkAdMiddlePhoto NVARCHAR(100) 
    )
AS 
    UPDATE  PE_Trademark
    SET     TrademarkName = @TrademarkName ,
            TrademarkType = @TrademarkType ,
            ProducerID = @ProducerId ,
            IsElite = @IsElite ,
            TrademarkPhoto = @TrademarkPhoto ,
            TrademarkIntro = @TrademarkIntro,
            SearchIndex=@SearchIndex,
			TrademarkShortIntro=@TrademarkShortIntro,
	        TrademarkBeginDate=@TrademarkBeginDate,
            TrademarkAdBannerPhoto=@TrademarkAdBannerPhoto,
            TrademarkAdMultiPhoto=@TrademarkAdMultiPhoto,
            TrademarkAdMiddlePhoto=@TrademarkAdMiddlePhoto
    WHERE   TrademarkID = @TrademarkID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_TrademarkNameExists]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_TrademarkNameExists]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Trademark_TrademarkNameExists]
    (
      @TrademarkName NVARCHAR(200)
    )
AS 
    DECLARE @result INT

    SELECT  *
    FROM    PE_Trademark
    WHERE   TrademarkName = @TrademarkName

    IF @@rowcount > 0 
        SET @result = 1
    ELSE 
        SET @result = 0

    RETURN @result' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_SetPassed]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_SetPassed]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Trademark_SetPassed]
    (
      @TrademarkID INT ,
      @Passed BIT
    )
AS 
    UPDATE  PE_Trademark
    SET     Passed = @Passed
    WHERE   TrademarkID = @TrademarkID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_SetOnTop]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_SetOnTop]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Trademark_SetOnTop]
    (
      @TrademarkID INT ,
      @OnTop BIT
    )
AS 
    UPDATE  PE_Trademark
    SET     OnTop = @OnTop
    WHERE   TrademarkID = @TrademarkID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_SetElite]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_SetElite]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Trademark_SetElite]
    (
      @TrademarkID INT ,
      @IsElite BIT
    )
AS 
    UPDATE  PE_Trademark
    SET     IsElite = @IsElite
    WHERE   TrademarkID = @TrademarkID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Trademark_GetById]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Trademark_GetById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Trademark_GetById] ( @TrademarkID INT )
AS 
    SELECT    TrademarkID ,
            TrademarkName ,
            ProducerID ,
            IsElite ,
            TrademarkType ,
            TrademarkPhoto ,
            TrademarkIntro ,
            Passed ,
            OnTop ,
            IsElite,
            SearchIndex
              TrademarkShortIntro,
	          TrademarkBeginDate,
              TrademarkAdBannerPhoto,
              TrademarkAdMultiPhoto,
              TrademarkAdMiddlePhoto          
    FROM    PE_Trademark
    WHERE   TrademarkID = 1' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Remittance_GetByOrderId]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Remittance_GetByOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Remittance_GetByOrderId] ( @OrderId INT )
AS 
    SELECT  O.ClientID ,
            O.OrderID ,
            O.OrderNum ,
            O.UserName ,
            O.Email ,
            C.ShortedForm AS ClientName ,
            O.MoneyTotal ,
            O.MoneyReceipt
    FROM    PE_Orders O
            LEFT JOIN PE_Client C ON O.ClientID = C.ClientID
    WHERE   O.OrderID = @OrderId
            AND MoneyTotal > MoneyReceipt' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Remittance_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Remittance_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Remittance_Add]
    (
      @OrderID INT ,
      @Money MONEY
	
    )
AS 
    UPDATE  PE_Orders
    SET     Status = 1 ,
            MoneyReceipt = MoneyReceipt + @Money
    WHERE   OrderID = @OrderID
            AND MoneyReceipt < MoneyTotal' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Refund_GetByOrderId]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Refund_GetByOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Refund_GetByOrderId] ( @OrderId INT )
AS 
    SELECT  O.OrderNum ,
            O.Email ,
            O.UserName ,
            C.ClientID ,
            C.ClientName ,
            O.MoneyTotal ,
            O.MoneyReceipt
    FROM    PE_Orders O
            LEFT JOIN PE_Client C ON O.ClientID = C.ClientID
    WHERE   O.OrderID = @OrderId
            AND MoneyReceipt > 0' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Refund_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Refund_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Refund_Add]
    (
      @OrderID INT ,
      @Money MONEY ,
      @HandlingCharge MONEY ,
      @RefundType INT
	
    )
AS 
    DECLARE @ClientID INT ,
        @UserName NVARCHAR(100)
    SELECT  @ClientID = ClientID ,
            @UserName = UserName
    FROM    PE_Orders
    WHERE   OrderID = @OrderID
            AND MoneyReceipt >= ( @Money + @HandlingCharge )
	
    IF ( @UserName IS NOT NULL
         OR @ClientID IS NOT NULL
       ) 
        BEGIN	
            UPDATE  PE_Orders
            SET     Status = 1 ,
                    MoneyReceipt = MoneyReceipt - ( @Money + @HandlingCharge )
            WHERE   OrderID = @OrderID 
            IF ( @RefundType = 1 ) 
                BEGIN
                    IF ( @UserName IS NOT NULL
                         OR @ClientID IS NOT NULL
                       ) 
                        BEGIN
                            IF ( @UserName <> '''' ) 
                                BEGIN
                                    UPDATE  PE_Users
                                    SET     Balance = Balance + @Money
                                    WHERE   UserName = @UserName
                                END
                            ELSE 
                                BEGIN
                                    UPDATE  PE_Client
                                    SET     Balance = Balance + @Money
                                    WHERE   ClientID = @ClientID
                                END
                        END
                END 
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Provider_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Provider_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Provider_Update]
    @ProviderID INT ,
    @ProviderName NVARCHAR(100) ,
    @InputTime DATETIME ,
    @Inputer NVARCHAR(100) ,
    @Remark NVARCHAR(510)
AS 
    UPDATE  PE_Provider
    SET     ProviderName = @ProviderName ,
            InputTime = @InputTime ,
            Inputer = @Inputer ,
            Remark = @Remark
    WHERE   ProviderID = @ProviderID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Provider_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Provider_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Provider_Add]
    @ProviderID INT ,
    @ProviderName NVARCHAR(100) ,
    @InputTime DATETIME ,
    @Inputer NVARCHAR(100) ,
    @Remark NVARCHAR(510)
AS 
    INSERT  INTO PE_Provider
            ( ProviderID ,
              ProviderName ,
              InputTime ,
              Inputer ,
              Remark
            )
    VALUES  ( @ProviderID ,
              @ProviderName ,
              @InputTime ,
              @Inputer ,
              @Remark
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_ProductPrice_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_ProductPrice_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_ProductPrice_Update]
    (
      @TableName NVARCHAR(255) ,
      @ProductId INT ,
      @GroupId INT ,
      @Price MONEY ,
      @PropertyValue NVARCHAR(255)
    )
AS 
    IF EXISTS ( SELECT  *
                FROM    PE_ProductPrice
                WHERE   TableName = @TableName
                        AND GroupID = @GroupID
                        AND ProductId = @ProductId
                        AND PropertyValue = @PropertyValue ) 
        BEGIN
            UPDATE  PE_ProductPrice
            SET     Price = @Price
            WHERE   GroupID = @GroupID
                    AND TableName = @TableName
                    AND ProductId = @ProductId
                    AND ( ISNULL(PropertyValue, '''') = @PropertyValue )
        END
    ELSE 
        BEGIN
            INSERT  INTO PE_ProductPrice
                    ( TableName ,
                      ProductID ,
                      GroupID ,
                      Price ,
                      PropertyValue
		        )
            VALUES  ( @TableName ,
                      @ProductId ,
                      @GroupId ,
                      @Price ,
                      @PropertyValue
		        )
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Product_DeleteModel]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Product_DeleteModel]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Product_DeleteModel]
    (
      @TableName NVARCHAR(255)
    )
AS 
    BEGIN

        IF NOT EXISTS ( SELECT  *
                        FROM    PE_OrderItem
                        WHERE   TableName = @TableName ) 
            BEGIN
                DELETE  PE_CommonProduct
                WHERE   TableName = @TableName
                DELETE  PE_ProductData
                WHERE   TableName = @TableName
                DELETE  PE_ProductPrice
                WHERE   TableName = @TableName
                IF EXISTS ( SELECT  *
                            FROM    PE_Cards
                            WHERE   TableName = @TableName ) 
                    BEGIN
                        UPDATE  PE_Cards
                        SET     ProductID = 0 ,
                                TableName = ''''
                        WHERE   TableName = @TableName
                    END
            END
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Product_DeleteAll]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Product_DeleteAll]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Product_DeleteAll]
    (
      @TableName NVARCHAR(255) ,
      @ProductID INT
    )
AS 
    BEGIN

        IF NOT EXISTS ( SELECT  *
                        FROM    PE_OrderItem
                        WHERE   TableName = @TableName
                                AND ProductID = @ProductID ) 
            BEGIN
                DELETE  PE_CommonProduct
                WHERE   TableName = @TableName
                        AND ProductID = @ProductID
                DELETE  PE_ProductData
                WHERE   TableName = @TableName
                        AND ProductID = @ProductID
                DELETE  PE_ProductPrice
                WHERE   TableName = @TableName
                        AND ProductID = @ProductID
                IF EXISTS ( SELECT  *
                            FROM    PE_Cards
                            WHERE   TableName = @TableName
                                    AND ProductID = @ProductID ) 
                    BEGIN
                        UPDATE  PE_Cards
                        SET     ProductID = 0 ,
                                TableName = ''''
                        WHERE   TableName = @TableName
                                AND ProductID = @ProductID
                    END
            END
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Producer_Update]
    (
      @ProducerID INT ,
      @ProducerName NVARCHAR(200) ,
      @ProducerShortName NVARCHAR(50) ,
      @Birthday DATETIME ,
      @Address NVARCHAR(255) ,
      @Phone NVARCHAR(50) ,
      @Fax NVARCHAR(50) ,
      @Postcode NVARCHAR(10) ,
      @Homepage NVARCHAR(50) ,
      @Email NVARCHAR(50) ,
      @ProducerIntro NTEXT ,
      @ProducerPhoto NVARCHAR(255) ,
      @ProducerType INT
	
    )
AS 
    UPDATE  PE_Producer
    SET     ProducerName = @ProducerName ,
            ProducerShortName = @ProducerShortName ,
            BirthDay = @Birthday ,
            Address = @Address ,
            Phone = @Phone ,
            Fax = @Fax ,
            Postcode = @Postcode ,
            Homepage = @Homepage ,
            Email = @Email ,
            ProducerIntro = @ProducerIntro ,
            ProducerPhoto = @ProducerPhoto ,
            ProducerType = @ProducerType
    WHERE   ProducerID = @ProducerID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_SetPassed]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_SetPassed]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Producer_SetPassed]
    (
      @ProducerID INT ,
      @Passed BIT
    )
AS 
    UPDATE  PE_Producer
    SET     Passed = @Passed
    WHERE   ProducerID = @ProducerID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_SetOnTop]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_SetOnTop]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Producer_SetOnTop]
    (
      @ProducerID INT ,
      @OnTop BIT
    )
AS 
    UPDATE  PE_Producer
    SET     OnTop = @OnTop
    WHERE   ProducerID = @ProducerID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_SetElite]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_SetElite]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Producer_SetElite]
    (
      @ProducerID INT ,
      @IsElite BIT
    )
AS 
    UPDATE  PE_Producer
    SET     IsElite = @IsElite
    WHERE   ProducerID = @ProducerID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_ProducerNameExists]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_ProducerNameExists]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Producer_ProducerNameExists]
    (
      @ProducerName NVARCHAR(200)
    )
AS 
    DECLARE @result INT

    SELECT  *
    FROM    PE_Producer
    WHERE   ProducerName = @ProducerName

    IF @@rowcount > 0 
        SET @result = 1
    ELSE 
        SET @result = 0

    RETURN @result' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_GetById]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_GetById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Producer_GetById] ( @ProducerID INT )
AS 
    SELECT  ProducerID ,
            ProducerName ,
            ProducerShortName ,
            BirthDay ,
            Address ,
            Phone ,
            Fax ,
            Postcode ,
            Homepage ,
            Email ,
            ProducerIntro ,
            ProducerPhoto ,
            ProducerType ,
            Passed ,
            onTop ,
            IsElite
    FROM    PE_Producer
    WHERE   ProducerID = @ProducerID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Contacter_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Contacter_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_Contacter_Update]
    (
      @ContacterID INT ,
      @ClientID INT ,
      @ParentID INT ,
      @UserName NVARCHAR(100) ,
      @UserType INT ,
      @TrueName NVARCHAR(20) ,
      @Sex INT ,
      @Title NVARCHAR(50) ,
      @Company NVARCHAR(100) ,
      @Department NVARCHAR(50) ,
      @Position NVARCHAR(50) ,
      @Operation NVARCHAR(50) ,
      @CompanyAddress NVARCHAR(200) ,
      @Email NVARCHAR(100) ,
      @Homepage NVARCHAR(255) ,
      @QQ NVARCHAR(20) ,
      @ICQ NVARCHAR(25) ,
      @MSN NVARCHAR(100) ,
      @Yahoo NVARCHAR(100) ,
      @UC NVARCHAR(100) ,
      @Aim NVARCHAR(100) ,
      @OfficePhone NVARCHAR(30) ,
      @HomePhone NVARCHAR(30) ,
      @PHS NVARCHAR(30) ,
      @Fax NVARCHAR(30) ,
      @Mobile NVARCHAR(30) ,
      @Country NVARCHAR(50) ,
      @Province NVARCHAR(30) ,
      @City NVARCHAR(30) ,
      @Address NVARCHAR(255) ,
      @ZipCode NVARCHAR(10) ,
      @NativePlace NVARCHAR(50) ,
      @Nation NVARCHAR(50) ,
      @Birthday DATETIME ,
      @IDCard NVARCHAR(20) ,
      @Marriage INT ,
      @Family NTEXT ,
      @Income INT ,
      @Education INT ,
      @GraduateFrom NVARCHAR(255) ,
      @InterestsOfLife NVARCHAR(255) ,
      @InterestsOfCulture NVARCHAR(255) ,
      @InterestsOfAmusement NVARCHAR(255) ,
      @InterestsOfSport NVARCHAR(255) ,
      @InterestsOfOther NVARCHAR(255) ,
      @UpdateTime DATETIME
    )
AS 
    UPDATE  [PE_Contacter]
    SET     [ClientID] = @ClientID ,
            [ParentID] = @ParentID ,
            [ContacterID] = @ContacterID ,
            [UserName] = @UserName ,
            [UserType] = @UserType ,
            [TrueName] = @TrueName ,
            [Sex] = @Sex ,
            [Title] = @Title ,
            [Company] = @Company ,
            [Department] = @Department ,
            [Position] = @Position ,
            [Operation] = @Operation ,
            [CompanyAddress] = @CompanyAddress ,
            [Email] = @Email ,
            [Homepage] = @Homepage ,
            [QQ] = @QQ ,
            [ICQ] = @ICQ ,
            [MSN] = @MSN ,
            [Yahoo] = @Yahoo ,
            [UC] = @UC ,
            [Aim] = @Aim ,
            [OfficePhone] = @OfficePhone ,
            [HomePhone] = @HomePhone ,
            [PHS] = @PHS ,
            [Fax] = @Fax ,
            [Mobile] = @Mobile ,
            [Country] = @Country ,
            [Province] = @Province ,
            [City] = @City ,
            [Address] = @Address ,
            [ZipCode] = @ZipCode ,
            [NativePlace] = @NativePlace ,
            [Nation] = @Nation ,
            [Birthday] = @Birthday ,
            [IDCard] = @IDCard ,
            [Marriage] = @Marriage ,
            [Family] = @Family ,
            [Income] = @Income ,
            [Education] = @Education ,
            [GraduateFrom] = @GraduateFrom ,
            [InterestsOfLife] = @InterestsOfLife ,
            [InterestsOfCulture] = @InterestsOfCulture ,
            [InterestsOfAmusement] = @InterestsOfAmusement ,
            [InterestsOfSport] = @InterestsOfSport ,
            [InterestsOfOther] = @InterestsOfOther ,
            [UpdateTime] = @UpdateTime
    WHERE   [ContacterID] = @ContacterID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Contacter_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Contacter_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_Contacter_Add]
    (
      @ContacterID INT ,
      @ClientID INT ,
      @ParentID INT ,
      @UserName NVARCHAR(100) ,
      @UserType INT ,
      @TrueName NVARCHAR(20) ,
      @Sex INT ,
      @Title NVARCHAR(50) ,
      @Company NVARCHAR(100) ,
      @Department NVARCHAR(50) ,
      @Position NVARCHAR(50) ,
      @Operation NVARCHAR(50) ,
      @CompanyAddress NVARCHAR(200) ,
      @Email NVARCHAR(100) ,
      @Homepage NVARCHAR(255) ,
      @QQ NVARCHAR(20) ,
      @ICQ NVARCHAR(25) ,
      @MSN NVARCHAR(100) ,
      @Yahoo NVARCHAR(100) ,
      @UC NVARCHAR(100) ,
      @Aim NVARCHAR(100) ,
      @OfficePhone NVARCHAR(30) ,
      @HomePhone NVARCHAR(30) ,
      @PHS NVARCHAR(30) ,
      @Fax NVARCHAR(30) ,
      @Mobile NVARCHAR(30) ,
      @Country NVARCHAR(50) ,
      @Province NVARCHAR(30) ,
      @City NVARCHAR(30) ,
      @Address NVARCHAR(255) ,
      @ZipCode NVARCHAR(10) ,
      @NativePlace NVARCHAR(50) ,
      @Nation NVARCHAR(50) ,
      @Birthday DATETIME ,
      @IDCard NVARCHAR(20) ,
      @Marriage INT ,
      @Family NTEXT ,
      @Income INT ,
      @Education INT ,
      @GraduateFrom NVARCHAR(255) ,
      @InterestsOfLife NVARCHAR(255) ,
      @InterestsOfCulture NVARCHAR(255) ,
      @InterestsOfAmusement NVARCHAR(255) ,
      @InterestsOfSport NVARCHAR(255) ,
      @InterestsOfOther NVARCHAR(255) ,
      @CreateTime DATETIME ,
      @UpdateTime DATETIME ,
      @Owner NVARCHAR(50) = ''''  
    )
AS 
    INSERT  INTO [PE_Contacter]
            ( [ContacterID] ,
              [ClientID] ,
              [ParentID] ,
              [UserName] ,
              [UserType] ,
              [TrueName] ,
              [Sex] ,
              [Title] ,
              [Company] ,
              [Department] ,
              [Position] ,
              [Operation] ,
              [CompanyAddress] ,
              [Email] ,
              [Homepage] ,
              [QQ] ,
              [ICQ] ,
              [MSN] ,
              [Yahoo] ,
              [UC] ,
              [Aim] ,
              [OfficePhone] ,
              [HomePhone] ,
              [PHS] ,
              [Fax] ,
              [Mobile] ,
              [Country] ,
              [Province] ,
              [City] ,
              [Address] ,
              [ZipCode] ,
              [NativePlace] ,
              [Nation] ,
              [Birthday] ,
              [IDCard] ,
              [Marriage] ,
              [Family] ,
              [Income] ,
              [Education] ,
              [GraduateFrom] ,
              [InterestsOfLife] ,
              [InterestsOfCulture] ,
              [InterestsOfAmusement] ,
              [InterestsOfSport] ,
              [InterestsOfOther] ,
              [CreateTime] ,
              [UpdateTime] ,
              [Owner]    
		)
    VALUES  ( @ContacterID ,
              @ClientID ,
              @ParentID ,
              @UserName ,
              @UserType ,
              @TrueName ,
              @Sex ,
              @Title ,
              @Company ,
              @Department ,
              @Position ,
              @Operation ,
              @CompanyAddress ,
              @Email ,
              @Homepage ,
              @QQ ,
              @ICQ ,
              @MSN ,
              @Yahoo ,
              @UC ,
              @Aim ,
              @OfficePhone ,
              @HomePhone ,
              @PHS ,
              @Fax ,
              @Mobile ,
              @Country ,
              @Province ,
              @City ,
              @Address ,
              @ZipCode ,
              @NativePlace ,
              @Nation ,
              @Birthday ,
              @IDCard ,
              @Marriage ,
              @Family ,
              @Income ,
              @Education ,
              @GraduateFrom ,
              @InterestsOfLife ,
              @InterestsOfCulture ,
              @InterestsOfAmusement ,
              @InterestsOfSport ,
              @InterestsOfOther ,
              @CreateTime ,
              @UpdateTime ,
              @Owner
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ComplainItem_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ComplainItem_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_ComplainItem_Update]
    (
      @ItemID INT ,
      @ClientID INT ,
      @ContacterID INT ,
      @ComplainType INT ,
      @ComplainMode INT ,
      @Title NVARCHAR(50) ,
      @Content NTEXT ,
      @FirstReceiver NVARCHAR(50) ,
      @DateAndTime DATETIME ,
      @MagnitudeOfExigence INT ,
      @Process NTEXT ,
      @Processor NVARCHAR(50) ,
      @Result NVARCHAR(50) ,
      @EndTime DATETIME ,
      @Feedback NVARCHAR(255) ,
      @ConfirmTime DATETIME ,
      @ConfirmCaller NVARCHAR(50) ,
      @ConfirmScore INT ,
      @ConfirmFeedback NVARCHAR(255) ,
      @Status INT ,
      @CurrentOwner NVARCHAR(50) ,
      @Remark NVARCHAR(255) ,
      @Defendant NVARCHAR(50)
    )
AS 
    UPDATE  [PE_ComplainItem]
    SET     [ClientID] = @ClientID ,
            [ContacterID] = @ContacterID ,
            [ComplainType] = @ComplainType ,
            [ComplainMode] = @ComplainMode ,
            [Title] = @Title ,
            [Content] = @Content ,
            [FirstReceiver] = @FirstReceiver ,
            [DateAndTime] = @DateAndTime ,
            [MagnitudeOfExigence] = @MagnitudeOfExigence ,
            [Process] = @Process ,
            [Processor] = @Processor ,
            [Result] = @Result ,
            [EndTime] = @EndTime ,
            [Feedback] = @Feedback ,
            [ConfirmTime] = @ConfirmTime ,
            [ConfirmCaller] = @ConfirmCaller ,
            [ConfirmScore] = @ConfirmScore ,
            [ConfirmFeedback] = @ConfirmFeedback ,
            [Status] = @Status ,
            [CurrentOwner] = @CurrentOwner ,
            [Remark] = @Remark ,
            [Defendant] = @Defendant
    WHERE   [ItemID] = @ItemID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ComplainItem_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ComplainItem_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_ComplainItem_Add]
    (
      @ItemID INT ,
      @ClientID INT ,
      @ContacterID INT ,
      @ComplainType INT ,
      @ComplainMode INT ,
      @Title NVARCHAR(50) ,
      @Content NTEXT ,
      @FirstReceiver NVARCHAR(50) ,
      @DateAndTime DATETIME ,
      @MagnitudeOfExigence INT ,
      @Process NTEXT ,
      @Processor NVARCHAR(50) ,
      @Result NVARCHAR(50) ,
      @EndTime DATETIME ,
      @Feedback NVARCHAR(255) ,
      @ConfirmTime DATETIME ,
      @ConfirmCaller NVARCHAR(50) ,
      @ConfirmScore INT ,
      @ConfirmFeedback NVARCHAR(255) ,
      @Status INT ,
      @CurrentOwner NVARCHAR(50) ,
      @Remark NVARCHAR(255) ,
      @Defendant NVARCHAR(50)
    )
AS 
    INSERT  INTO [PE_ComplainItem]
            ( [ItemID] ,
              [ClientID] ,
              [ContacterID] ,
              [ComplainType] ,
              [ComplainMode] ,
              [Title] ,
              [Content] ,
              [FirstReceiver] ,
              [DateAndTime] ,
              [MagnitudeOfExigence] ,
              [Process] ,
              [Processor] ,
              [Result] ,
              [EndTime] ,
              [Feedback] ,
              [ConfirmTime] ,
              [ConfirmCaller] ,
              [ConfirmScore] ,
              [ConfirmFeedback] ,
              [Status] ,    --记录状态，0为未处理，1为处理中，2为已处理，3为已回访
              [CurrentOwner] ,
              [Remark] ,
              [Defendant]
		)
    VALUES  ( @ItemID ,
              @ClientID ,
              @ContacterID ,
              @ComplainType ,
              @ComplainMode ,
              @Title ,
              @Content ,
              @FirstReceiver ,
              @DateAndTime ,
              @MagnitudeOfExigence ,
              @Process ,
              @Processor ,
              @Result ,
              @EndTime ,
              @Feedback ,
              @ConfirmTime ,
              @ConfirmCaller ,
              @ConfirmScore ,
              @ConfirmFeedback ,
              @Status ,
              @CurrentOwner ,
              @Remark ,
              @Defendant
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Company_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Company_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_Company_Update]
    (
      @CompanyID INT ,
      @ClientID INT ,
      @CompanyName NVARCHAR(200) ,
      @Country NVARCHAR(50) ,
      @Province NVARCHAR(30) ,
      @City NVARCHAR(30) ,
      @Address NVARCHAR(255) ,
      @ZipCode NVARCHAR(50) ,
      @Phone NVARCHAR(50) ,
      @Fax NVARCHAR(30) ,
      @Homepage NVARCHAR(255) ,
      @BankOfDeposit NVARCHAR(50) ,
      @BankAccount NVARCHAR(50) ,
      @TaxNum NVARCHAR(50) ,
      @StatusInField INT ,
      @CompanySize INT ,
      @BusinessScope NVARCHAR(200) ,
      @AnnualSales NVARCHAR(50) ,
      @ManagementForms INT ,
      @RegisteredCapital NVARCHAR(50) ,
      @CompanyIntro NTEXT ,
      @CompanyPic NVARCHAR(255)
    )
AS 
    UPDATE  PE_Company
    SET     ClientID = @ClientID ,
            CompanyName = @CompanyName ,
            Country = @Country ,
            Province = @Province ,
            City = @City ,
            Address = @Address ,
            ZipCode = @ZipCode ,
            Phone = @Phone ,
            Fax = @Fax ,
            Homepage = @Homepage ,
            BankOfDeposit = @BankOfDeposit ,
            BankAccount = @BankAccount ,
            TaxNum = @TaxNum ,
            StatusInField = @StatusInField ,
            CompanySize = @CompanySize ,
            BusinessScope = @BusinessScope ,
            AnnualSales = @AnnualSales ,
            ManagementForms = @ManagementForms ,
            RegisteredCapital = @RegisteredCapital ,
            CompanyIntro = @CompanyIntro ,
            CompanyPic = @CompanyPic
    WHERE   CompanyID = @CompanyID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Company_GetByClientId]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Company_GetByClientId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_Company_GetByClientId] ( @ClientID INT )
AS 
    SELECT  *
    FROM    PE_Company
    WHERE   ClientID = @ClientID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Company_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Company_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_Company_Add]
    (
      @CompanyID INT ,
      @ClientID INT ,
      @CompanyName NVARCHAR(200) ,
      @Country NVARCHAR(50) ,
      @Province NVARCHAR(30) ,
      @City NVARCHAR(30) ,
      @Address NVARCHAR(255) ,
      @ZipCode NVARCHAR(50) ,
      @Phone NVARCHAR(50) ,
      @Fax NVARCHAR(30) ,
      @Homepage NVARCHAR(255) ,
      @BankOfDeposit NVARCHAR(50) ,
      @BankAccount NVARCHAR(50) ,
      @TaxNum NVARCHAR(50) ,
      @StatusInField INT ,
      @CompanySize INT ,
      @BusinessScope NVARCHAR(200) ,
      @AnnualSales NVARCHAR(50) ,
      @ManagementForms INT ,
      @RegisteredCapital NVARCHAR(50) ,
      @CompanyIntro NTEXT ,
      @CompanyPic NVARCHAR(255)
    )
AS 
    INSERT  INTO [PE_Company]
            ( [CompanyID] ,
              [ClientID] ,
              [CompanyName] ,
              [Country] ,
              [Province] ,
              [City] ,
              [Address] ,
              [ZipCode] ,
              [Phone] ,
              [Fax] ,
              [Homepage] ,
              [BankOfDeposit] ,
              [BankAccount] ,
              [TaxNum] ,
              [StatusInField] ,
              [CompanySize] ,
              [BusinessScope] ,
              [AnnualSales] ,
              [ManagementForms] ,
              [RegisteredCapital] ,
              [CompanyIntro] ,
              [CompanyPic] 
            )
    VALUES  ( @CompanyID ,
              @ClientID ,
              @CompanyName ,
              @Country ,
              @Province ,
              @City ,
              @Address ,
              @ZipCode ,
              @Phone ,
              @Fax ,
              @Homepage ,
              @BankOfDeposit ,
              @BankAccount ,
              @TaxNum ,
              @StatusInField ,
              @CompanySize ,
              @BusinessScope ,
              @AnnualSales ,
              @ManagementForms ,
              @RegisteredCapital ,
              @CompanyIntro ,
              @CompanyPic 
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ClientHistoryItem_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ClientHistoryItem_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_ClientHistoryItem_Add]
    (
      @ClientHistoryID INT ,
      @ItemID INT ,
      @FieldName NVARCHAR(50) ,
      @OldValue NVARCHAR(500) ,
      @NewValue NVARCHAR(500)
    )
AS 
    INSERT  INTO pe_ClientHistoryItem
            ( ClientHistoryID ,
              ItemID ,
              FieldName ,
              OldValue ,
              NewValue
            )
    VALUES  ( @ClientHistoryID ,
              @ItemID ,
              @FieldName ,
              @OldValue ,
              @NewValue
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ClientHistory_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ClientHistory_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_ClientHistory_Add]
    (
      @ClientHistoryID INT ,
      @ClientID NVARCHAR(20) ,
      @Actionname NVARCHAR(50) ,
      @ActionTime DATETIME ,
      @UserIp NVARCHAR(50) ,
      @UserName NVARCHAR(100) ,
      @Remark NVARCHAR(200)
    )
AS 
    INSERT  INTO pe_ClientHistory
            ( ClientHistoryID ,
              ClientID ,
              Actionname ,
              ActionTime ,
              UserIp ,
              UserName ,
              Remark 
            )
    VALUES  ( @ClientHistoryID ,
              @ClientID ,
              @Actionname ,
              @ActionTime ,
              @UserIp ,
              @UserName ,
              @Remark 
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ClientAnnal_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ClientAnnal_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_ClientAnnal_Update]
    (
      @ClientAnnalID INT ,
      @ClientID INT ,
      @RelationType NVARCHAR(30) ,
      @Contacter NVARCHAR(50) ,
      @RelationTime DATETIME ,
      @AnnalContent NVARCHAR(1000) ,
      @AnnalTime DATETIME ,
      @Inputer NVARCHAR(20)
    )
AS 
    SET NOCOUNT OFF 

    UPDATE  PE_ClientAnnal
    SET     Contacter = @Contacter ,
            ClientID = @ClientID ,
            RelationTime = @RelationTime ,
            RelationType = @RelationType ,
            AnnalContent = @AnnalContent ,
            Annaltime = @AnnalTime ,
            Inputer = @Inputer
    WHERE   ClientAnnalID = @ClientAnnalID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ClientAnnal_GetClientAnnalByID]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ClientAnnal_GetClientAnnalByID]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROC [dbo].[PR_Crm_ClientAnnal_GetClientAnnalByID] @ClientAnnalID INT
AS 
    SELECT  *
    FROM    PE_ClientAnnal
    WHERE   ClientAnnalID = @ClientAnnalID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_ModelTemplates_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_ModelTemplates_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_ModelTemplates_Add]
    (
      @TemplateId INT ,
      @TemplateName NVARCHAR(255) ,
      @TemplateDescription NTEXT ,
      @Field NTEXT ,
      @IsEshop BIT  
    )
AS 
    INSERT  INTO [PE_ModelTemplates]
            ( [TemplateId] ,
              [TemplateName] ,
              [TemplateDescription] ,
              [Field] ,
              [IsEshop]   
		)
    VALUES  ( @TemplateId ,
              @TemplateName ,
              @TemplateDescription ,
              @Field ,
              @IsEshop
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Model_Update]
    @ModelID INT ,
    @ModelName NVARCHAR(50) ,
    @Description NVARCHAR(250) = '''' ,
    @TableName NVARCHAR(50) ,
    @ItemName NVARCHAR(50) ,
    @ItemUnit NVARCHAR(50) ,
    @ItemIcon NVARCHAR(255) ,
    @IsCountHits BIT ,
    @ModelType INT ,
    @Disabled BIT ,
    @DefaultTemplateFile NVARCHAR(255) = '''' ,
    @EnableCharge BIT ,
    @EnableSignin BIT ,
    @EnableVote BIT ,
    @AddInfoFilePath NVARCHAR(200) ,
    @ManageInfoFilePath NVARCHAR(200) ,
    @PreviewInfoFilePath NVARCHAR(200) ,
    @BatchInfoFilePath NVARCHAR(200) ,
    @MaxPerUser INT ,
    @PrintTemplate NVARCHAR(255) ,
    @SearchTemplate NVARCHAR(255) ,
    @AdvanceSearchFormTemplate NVARCHAR(255) ,
    @AdvanceSearchTemplate NVARCHAR(255) ,
    @ChargeTips NVARCHAR(255) ,
    @NeedPointChargeTips NVARCHAR(255) ,
    @OutTimeChargeTips NVARCHAR(255) ,
    @UsePointChargeTips NVARCHAR(500) ,
    @CommentManageTemplate NVARCHAR(255) ,
    @UserAddContentTemplate NVARCHAR(255) ,
    @AnonymouseTemplate NVARCHAR(255) ,
    @EnableVerificationCode BIT ,
    @EnableWap BIT ,
    @WapField NTEXT ,
	@TitleField NVARCHAR(255)
AS 
    UPDATE  [PE_Model]
    SET     ModelID = @ModelID ,
            ModelName = @ModelName ,
            Description = @Description ,
            TableName = @TableName ,
            ItemName = @ItemName ,
            ItemUnit = @ItemUnit ,
            ItemIcon = @ItemIcon ,
            IsCountHits = @IsCountHits ,
            ModelType = @ModelType ,
            Disabled = @Disabled ,
            DefaultTemplateFile = @DefaultTemplateFile ,
            EnableCharge = @EnableCharge ,
            EnableSignin = @EnableSignin ,
            AddInfoFilePath = @AddInfoFilePath ,
            ManageInfoFilePath = @ManageInfoFilePath ,
            PreviewInfoFilePath = @PreviewInfoFilePath ,
            BatchInfoFilePath = @BatchInfoFilePath ,
            MaxPerUser = @MaxPerUser ,
            PrintTemplate = @PrintTemplate ,
            EnableVote = @EnableVote ,
            SearchTemplate = @SearchTemplate ,
            AdvanceSearchFormTemplate = @AdvanceSearchFormTemplate ,
            AdvanceSearchTemplate = @AdvanceSearchTemplate ,
            ChargeTips = @ChargeTips ,
            NeedPointChargeTips = @NeedPointChargeTips ,
            OutTimeChargeTips = @OutTimeChargeTips ,
            UsePointChargeTips = @UsePointChargeTips ,
            CommentManageTemplate = @CommentManageTemplate ,
            UserAddContentTemplate = @UserAddContentTemplate ,
            AnonymouseTemplate = @AnonymouseTemplate ,
            EnableVerificationCode = @EnableVerificationCode ,
            EnableWap = @EnableWap ,
            WapField = @WapField ,
			TitleField = @TitleField
    WHERE   ModelID = @ModelID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_TemplateIdExists]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_TemplateIdExists]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Model_TemplateIdExists]
    (
      @NodeId INT ,
      @TemplateId INT
    )
AS 
    SELECT  COUNT(*)
    FROM    PE_Nodes_Template
    WHERE   NodeId = @NodeId
            AND TemplateId = @TemplateId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_ModelIdExists]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_ModelIdExists]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Model_ModelIdExists]
    (
      @NodeId INT ,
      @ModelId INT
    )
AS 
    SELECT  COUNT(*)
    FROM    PE_Nodes_Model_Template
    WHERE   NodeId = @NodeId
            AND ModelId = @ModelId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_IsTableNameExists]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_IsTableNameExists]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Model_IsTableNameExists]
    (
      @TableName NVARCHAR(50)
    )
AS 
    BEGIN
        SET NOCOUNT OFF	
        SELECT  COUNT(*)
        FROM    [PE_Model]
        WHERE   TableName = @TableName

    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_IsModelNameExists]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_IsModelNameExists]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Model_IsModelNameExists]
    (
      @ModelName NVARCHAR(50)
    )
AS 
    SELECT  COUNT(*)
    FROM    [PE_Model]
    WHERE   ModelName = @ModelName' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_GetById]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_GetById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Model_GetById] ( @ModelID INT )
AS 
    SELECT  *
    FROM    [PE_Model]
    WHERE   ModelID = @ModelID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_Disabled]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_Disabled]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Model_Disabled]
    (
      @ModelID INT ,
      @Disabled BIT
    )
AS 
    UPDATE  [PE_Model]
    SET     Disabled = @Disabled
    WHERE   ModelID = @ModelID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_AddTemplateForNodes]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_AddTemplateForNodes]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Model_AddTemplateForNodes]
    (
      @NodeId INT ,
      @TemplateId INT ,
      @IsDefault BIT
	
    )
AS 
    INSERT  INTO PE_Nodes_Template
            ( NodeId, TemplateId, IsDefault )
    VALUES  ( @NodeId, @TemplateId, @IsDefault )  
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_AddModelForNodes]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_AddModelForNodes]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Model_AddModelForNodes]
    (
      @NodeId INT ,
      @ModelId INT ,
      @DefaultTemplateFile NVARCHAR(255)
    )
AS 
    INSERT  INTO PE_Nodes_Model_Template
            ( NodeId ,
              ModelId ,
              DefaultTemplateFile
            )
    VALUES  ( @NodeId ,
              @ModelId ,
              @DefaultTemplateFile
            )  
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Model_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Model_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Model_Add]
    @ModelID INT ,
    @ModelName NVARCHAR(50) ,
    @Description NVARCHAR(250) = '''' ,
    @TableName NVARCHAR(50) ,
    @ItemName NVARCHAR(50) ,
    @ItemUnit NVARCHAR(50) ,
    @ItemIcon NVARCHAR(255) ,
    @IsCountHits BIT ,
    @ModelType INT ,
    @Disabled BIT ,
    @Field NTEXT = '''' ,
    @DefaultTemplateFile NVARCHAR(255) = '''' ,
    @EnableCharge BIT ,
    @EnableSignin BIT ,
    @EnableVote BIT ,
    @AddInfoFilePath NVARCHAR(200) ,
    @ManageInfoFilePath NVARCHAR(200) ,
    @PreviewInfoFilePath NVARCHAR(200) ,
    @ChargeTips NVARCHAR(255) ,
    @NeedPointChargeTips NVARCHAR(255) ,
    @OutTimeChargeTips NVARCHAR(255) ,
    @UsePointChargeTips NVARCHAR(500) ,
    @BatchInfoFilePath NVARCHAR(200) ,
    @Character INT ,
    @MaxPerUser INT ,
    @PrintTemplate NVARCHAR(255) ,
    @SearchTemplate NVARCHAR(255) ,
    @AdvanceSearchFormTemplate NVARCHAR(255) ,
    @AdvanceSearchTemplate NVARCHAR(255) ,
    @CommentManageTemplate NVARCHAR(255) ,
    @UserAddContentTemplate NVARCHAR(255) ,
    @AnonymouseTemplate NVARCHAR(255) ,
    @EnableVerificationCode BIT ,
    @EnableWap BIT ,
    @WapField NTEXT,
	@TitleField NVARCHAR(255)
AS 
    INSERT  INTO [PE_Model]
            ( [ModelID] ,
              [ModelName] ,
              [Description] ,
              [TableName] ,
              [ItemName] ,
              [ItemUnit] ,
              [ItemIcon] ,
              [IsCountHits] ,
              [ModelType] ,
              [Disabled] ,
              [Field] ,
              [DefaultTemplateFile] ,
              [EnableCharge] ,
              [EnableSignin] ,
              [EnableVote] ,
              [AddInfoFilePath] ,
              [ManageInfoFilePath] ,
              [PreviewInfoFilePath] ,
              [BatchInfoFilePath] ,
              [Character] ,
              [MaxPerUser] ,
              [PrintTemplate] ,
              [SearchTemplate] ,
              [AdvanceSearchFormTemplate] ,
              [AdvanceSearchTemplate] ,
              [ChargeTips] ,
              [NeedPointChargeTips] ,
              [OutTimeChargeTips] ,
              [UsePointChargeTips] ,
              [CommentManageTemplate] ,
              [UserAddContentTemplate] ,
              [AnonymouseTemplate] ,
              [EnableVerificationCode] ,
              [EnableWap] ,
              [WapField] ,
			  [TitleField]
		)
    VALUES  ( @ModelID ,
              @ModelName ,
              @Description ,
              @TableName ,
              @ItemName ,
              @ItemUnit ,
              @ItemIcon ,
              @IsCountHits ,
              @ModelType ,
              @Disabled ,
              @Field ,
              @DefaultTemplateFile ,
              @EnableCharge ,
              @EnableSignin ,
              @EnableVote ,
              @AddInfoFilePath ,
              @ManageInfoFilePath ,
              @PreviewInfoFilePath ,
              @BatchInfoFilePath ,
              @Character ,
              @MaxPerUser ,
              @PrintTemplate ,
              @SearchTemplate ,
              @AdvanceSearchFormTemplate ,
              @AdvanceSearchTemplate ,
              @ChargeTips ,
              @NeedPointChargeTips ,
              @OutTimeChargeTips ,
              @UsePointChargeTips ,
              @CommentManageTemplate ,
              @UserAddContentTemplate ,
              @AnonymouseTemplate ,
              @EnableVerificationCode ,
              @EnableWap ,
              @WapField ,
			  @TitleField
	      )
    BEGIN
		-- 不存在创建指定数据表
        EXEC(''CREATE TABLE [dbo].''+ @TableName+'' (ID int,CONSTRAINT [PK_''+@TableName+''_ID] PRIMARY KEY CLUSTERED
        (
        [ID] ASC
        ))'')

    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_CommentPK_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_CommentPK_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_CommentPK_Add]
    (
      @PKId INT ,
      @CommentId INT ,
      @Title NVARCHAR(255) ,
      @Content NTEXT ,
      @IP NVARCHAR(50) ,
      @UpdateTime DATETIME ,
      @UserName NVARCHAR(100) ,
      @Position INT
    )
AS 
    INSERT  INTO PE_CommentPK
            ( PKId ,
              CommentId ,
              Title ,
              [Content] ,
              IP ,
              UpdateTime ,
              UserName ,
              [Position]
	      )
    VALUES  ( @PKId ,
              @CommentId ,
              @Title ,
              @Content ,
              @IP ,
              @UpdateTime ,
              @UserName ,
              @Position
	      )
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Comment_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Comment_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Comment_Add]
    (
      @CommentId INT ,
      @GeneralId INT ,
      @TopicId INT ,
      @NodeId INT ,
      @CommentTitle NVARCHAR(255) ,
      @Content NTEXT ,
      @UpdateTime DATETIME ,
      @Score INT ,
      @Position INT ,
      @Status BIT ,
      @Ip NVARCHAR(50) ,
      @IsPrivate BIT ,
      @UserName NVARCHAR(100) ,
      @Face NVARCHAR(255)
    )
AS 
    INSERT  INTO [PE_Comment]
            ( CommentId ,
              GeneralId ,
              TopicId ,
              NodeId ,
              CommentTitle ,
              [Content] ,
              UpdateTime ,
              Score ,
              [Position] ,
              Status ,
              Agree ,
              Oppose ,
              Neutral ,
              IP ,
              IsElite ,
              IsPrivate ,
              UserName ,
              Face
		)
    VALUES  ( @CommentId ,
              @GeneralId ,
              @TopicId ,
              @NodeId ,
              @CommentTitle ,
              @Content ,
              @UpdateTime ,
              @Score ,
              @Position ,
              @Status ,
              0 ,
              0 ,
              0 ,
              @IP ,
              0 ,
              @IsPrivate ,
              @UserName ,
              @Face
		)
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_ADZone_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_ADZone_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_AD_ADZone_Update]
    (
      @ZoneId INT ,
      @ZoneName NVARCHAR(100) ,
      @ZoneJSName NVARCHAR(100) ,
      @ZoneIntro NVARCHAR(255) ,
      @ZoneType INT ,
      @DefaultSetting BIT ,
      @ZoneSetting NVARCHAR(255) ,
      @ZoneWidth INT ,
      @ZoneHeight INT ,
      @Active BIT ,
      @ShowType INT ,
      @UpdateTime DATETIME
    )
AS 
    SET NOCOUNT OFF
    BEGIN
        UPDATE  PE_AdZone
        SET     ZoneName = @ZoneName ,
                ZoneJSName = @ZoneJSName ,
                ZoneIntro = @ZoneIntro ,
                ZoneType = @ZoneType ,
                DefaultSetting = @DefaultSetting ,
                ZoneSetting = @ZoneSetting ,
                ZoneWidth = @ZoneWidth ,
                ZoneHeight = @ZoneHeight ,
                Active = @Active ,
                ShowType = @ShowType
        WHERE   ZoneId = @ZoneId
	
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_ADZone_Pause]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_ADZone_Pause]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_AD_ADZone_Pause]
    (
      @strZoneId VARCHAR(8000)
    )
AS
    DECLARE @active BIT
    DECLARE @zoneId INT
    DECLARE @split VARCHAR(1)
	
    SET @split = '',''
    SET @strZoneId = @strZoneId + '',''
	
    WHILE CHARINDEX(@split, @strZoneId) > 0 
        BEGIN
            SET @zoneId = CONVERT(INT, LEFT(@strZoneId,
                                            CHARINDEX(@split, @strZoneId) - 1))
            SET @strZoneId = STUFF(@strZoneId, 1,
                                   CHARINDEX(@split, @strZoneId), '''')
	
            SELECT  @active = Active
            FROM    PE_ADZone
            WHERE   ZoneId = @zoneId
            IF @active = 1 
                SET @active = 0
            UPDATE  PE_ADZone
            SET     Active = @active
            WHERE   ZoneId = @zoneId
        END
	
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_WordReplace_GetById]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_WordReplace_GetById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_WordReplace_GetById] ( @ItemID INT )
AS 
    SELECT  *
    FROM    PE_WordReplaceItem
    WHERE   ItemID = @ItemID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_WordReplace_Exists]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_WordReplace_Exists]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_WordReplace_Exists]
    (
      @SourceWord NVARCHAR(250)
    )
AS 
    SELECT  COUNT(*)
    FROM    PE_WordReplaceItem
    WHERE   SourceWord = @SourceWord' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Message_GetById]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Message_GetById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Message_GetById] ( @MessageId INT )
AS 
    SET NOCOUNT OFF 
    SELECT  *
    FROM    PE_Message
    WHERE   MessageID = @MessageId
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_ADZone_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_ADZone_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_AD_ADZone_Add]
    (
      @ZoneId INT ,
      @ZoneName NVARCHAR(100) ,
      @ZoneJSName NVARCHAR(100) ,
      @ZoneIntro NVARCHAR(255) ,
      @ZoneType INT ,
      @DefaultSetting BIT ,
      @ZoneSetting NVARCHAR(255) ,
      @ZoneWidth INT ,
      @ZoneHeight INT ,
      @Active BIT ,
      @ShowType INT ,
      @UpdateTime DATETIME
	
    )
AS 
    SET NOCOUNT OFF 
    BEGIN
        INSERT  INTO PE_AdZone
                ( ZoneId ,
                  ZoneName ,
                  ZoneJSName ,
                  ZoneIntro ,
                  ZoneType ,
                  DefaultSetting ,
                  ZoneSetting ,
                  ZoneWidth ,
                  ZoneHeight ,
                  Active ,
                  ShowType ,
                  UpdateTime
                )
        VALUES  ( @ZoneId ,
                  @ZoneName ,
                  @ZoneJSName ,
                  @ZoneIntro ,
                  @ZoneType ,
                  @DefaultSetting ,
                  @ZoneSetting ,
                  @ZoneWidth ,
                  @ZoneHeight ,
                  @Active ,
                  @ShowType ,
                  @UpdateTime
                )
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_ADZone_Active]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_ADZone_Active]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_AD_ADZone_Active]
    (
      @strZoneId VARCHAR(8000)
    )
AS 
    DECLARE @active BIT
    DECLARE @zoneId INT
    DECLARE @split VARCHAR(1)
	
    SET @split = '',''
    SET @strZoneId = @strZoneId + '',''
	
    WHILE CHARINDEX(@split, @strZoneId) > 0 
        BEGIN
            SET @zoneId = CONVERT(INT, LEFT(@strZoneId,
                                            CHARINDEX(@split, @strZoneId) - 1))
            SET @strZoneId = STUFF(@strZoneId, 1,
                                   CHARINDEX(@split, @strZoneId), '''')
	
            SELECT  @active = Active
            FROM    PE_ADZone
            WHERE   ZoneId = @zoneId
            IF @active = 0 
                SET @active = 1
            UPDATE  PE_ADZone
            SET     Active = @active
            WHERE   ZoneId = @zoneId
        END
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_Advertisement_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_Advertisement_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_AD_Advertisement_Update]
    (
      @ADId INT ,
      @strZoneId NVARCHAR(4000) ,
      @UserId INT ,
      @ADType INT ,
      @ADName NVARCHAR(100) ,
      @ImgUrl NVARCHAR(255) ,
      @ImgWidth INT ,
      @ImgHeight INT ,
      @FlashWmode INT ,
      @ADIntro NTEXT ,
      @LinkUrl NVARCHAR(255) ,
      @LinkTarget INT ,
      @LinkAlt NVARCHAR(255) ,
      @Priority INT ,
      @Setting NTEXT ,
      @CountView BIT ,
      @Views INT ,
      @CountClick BIT ,
      @Clicks INT ,
      @IsAbsolutePath BIT ,
      @Passed BIT ,
      @OverdueDate DATETIME 
    )
AS 
    SET NOCOUNT OFF

    DECLARE @active BIT
    DECLARE @zoneId INT
    DECLARE @split VARCHAR(1)
	
    SET @split = '',''
    IF @strZoneId != '''' 
        BEGIN
            SET @strZoneId = @strZoneId + '',''
            DELETE  FROM PE_Zone_Advertisement
            WHERE   ADID = @ADID
            WHILE CHARINDEX(@split, @strZoneId) > 0 
                BEGIN
                    SET @zoneId = CONVERT(INT, LEFT(@strZoneId,
                                                    CHARINDEX(@split,
                                                              @strZoneId) - 1))
                    SET @strZoneId = STUFF(@strZoneId, 1,
                                           CHARINDEX(@split, @strZoneId), '''')
                    INSERT  INTO PE_Zone_Advertisement
                            ( ADID, ZoneID )
                    VALUES  ( @ADID, @ZoneId )
                END
        END
    BEGIN


        UPDATE  [PE_Advertisement]
        SET     [UserId] = @UserId ,
                [ADType] = @ADType ,
                [ADName] = @ADName ,
                [ImgUrl] = @ImgUrl ,
                [ImgWidth] = @ImgWidth ,
                [ImgHeight] = @ImgHeight ,
                [FlashWmode] = @FlashWmode ,
                [ADIntro] = @ADIntro ,
                [LinkUrl] = @LinkUrl ,
                [LinkTarget] = @LinkTarget ,
                [LinkAlt] = @LinkAlt ,
                [Priority] = @Priority ,
                [Setting] = @Setting ,
                [CountView] = @CountView ,
                [Views] = @Views ,
                [CountClick] = @CountClick ,
                [Clicks] = @Clicks ,
                [IsAbsolutePath] = @IsAbsolutePath ,
                [Passed] = @Passed ,
                [OverdueDate] = @OverdueDate
        WHERE   [ADId] = @ADId
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_Advertisement_Passed]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_Advertisement_Passed]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_AD_Advertisement_Passed] ( @strAdId VARCHAR(8000) )
AS
    DECLARE @passed BIT
    DECLARE @adId INT
    DECLARE @split VARCHAR(1)
	
    SET @split = '',''
    SET @strAdId = @strAdId + '',''
	
    WHILE CHARINDEX(@split, @strAdId) > 0 
        BEGIN
            SET @adId = CONVERT(INT, LEFT(@strAdId,
                                          CHARINDEX(@split, @strAdId) - 1))
            SET @strAdId = STUFF(@strAdId, 1, CHARINDEX(@split, @strAdId), '''')
		
            SELECT  @passed = Passed
            FROM    PE_Advertisement
            WHERE   AdID = @adId
            IF @passed = 0 
                SET @passed = 1
            UPDATE  PE_Advertisement
            SET     passed = @passed
            WHERE   ADId = @adId
        END
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_Advertisement_CancelPassed]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_Advertisement_CancelPassed]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_AD_Advertisement_CancelPassed]
    (
      @strAdId NVARCHAR(4000)
    )
AS 
    SET NOCOUNT OFF
    DECLARE @passed BIT
    DECLARE @adId INT
    DECLARE @split VARCHAR(1)
	
    SET @split = '',''
    SET @strAdId = @strAdId + '',''
    WHILE CHARINDEX(@split, @strAdId) > 0 
        BEGIN
            SET @adId = CONVERT(INT, LEFT(@strAdId,
                                          CHARINDEX(@split, @strAdId) - 1))
            SET @strAdId = STUFF(@strAdId, 1, CHARINDEX(@split, @strAdId), '''')
		
            SELECT  @passed = Passed
            FROM    PE_Advertisement
            WHERE   AdID = @adId
            IF @passed = 1 
                SET @passed = 0
            UPDATE  PE_Advertisement
            SET     passed = @passed
            WHERE   ADId = @adId
        END
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_AD_Advertisement_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_AD_Advertisement_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_AD_Advertisement_Add]
    (
      @ADID INT ,
      @strZoneId NVARCHAR(4000) ,
      @UserID INT ,
      @ADType INT ,
      @ADName NVARCHAR(100) ,
      @ImgUrl NVARCHAR(255) ,
      @ImgWidth INT ,
      @ImgHeight INT ,
      @FlashWmode INT ,
      @ADIntro NTEXT ,
      @LinkUrl NVARCHAR(255) ,
      @LinkTarget INT ,
      @LinkAlt NVARCHAR(255) ,
      @Priority INT ,
      @Setting NTEXT ,
      @CountView BIT ,
      @Views INT ,
      @CountClick BIT ,
      @Clicks INT ,
      @IsAbsolutePath BIT ,
      @Passed BIT ,
      @OverdueDate DATETIME 
    )
AS 
    SET NOCOUNT OFF
 
    DECLARE @active BIT
    DECLARE @zoneId INT
    DECLARE @split VARCHAR(1)
	
    SET @split = '',''
    IF @strZoneId != '''' 
        BEGIN
            SET @strZoneId = @strZoneId + '',''
            WHILE CHARINDEX(@split, @strZoneId) > 0 
                BEGIN
                    SET @zoneId = CONVERT(INT, LEFT(@strZoneId,
                                                    CHARINDEX(@split,
                                                              @strZoneId) - 1))
                    SET @strZoneId = STUFF(@strZoneId, 1,
                                           CHARINDEX(@split, @strZoneId), '''')
                    INSERT  INTO PE_Zone_Advertisement
                            ( ADID, ZoneID )
                    VALUES  ( @ADID, @ZoneId )
                END
        END
    BEGIN 
        INSERT  INTO [PE_Advertisement]
                ( [ADID] ,
                  [UserID] ,
                  [ADType] ,
                  [ADName] ,
                  [ImgUrl] ,
                  [ImgWidth] ,
                  [ImgHeight] ,
                  [FlashWmode] ,
                  [ADIntro] ,
                  [LinkUrl] ,
                  [LinkTarget] ,
                  [LinkAlt] ,
                  [Priority] ,
                  [Setting] ,
                  [CountView] ,
                  [Views] ,
                  [CountClick] ,
                  [Clicks] ,
                  [IsAbsolutePath] ,
                  [Passed] ,
                  [OverdueDate]
                )
        VALUES  ( @ADID ,
                  @UserID ,
                  @ADType ,
                  @ADName ,
                  @ImgUrl ,
                  @ImgWidth ,
                  @ImgHeight ,
                  @FlashWmode ,
                  @ADIntro ,
                  @LinkUrl ,
                  @LinkTarget ,
                  @LinkAlt ,
                  @Priority ,
                  @Setting ,
                  @CountView ,
                  @Views ,
                  @CountClick ,
                  @Clicks ,
                  @IsAbsolutePath ,
                  @Passed ,
                  @OverdueDate
                )
    END
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_WordReplace_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_WordReplace_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_WordReplace_Update]
    (
      @ItemID INT ,
      @SourceWord NVARCHAR(250) ,
      @TargetWord NVARCHAR(250) ,
      @ReplaceType INT ,
      @ScopesType INT ,
      @Priority INT ,
      @ReplaceTimes INT ,
      @OpenType BIT ,
      @IsEnabled BIT ,
      @Title NVARCHAR(255)
    )
AS 
    UPDATE  PE_WordReplaceItem
    SET     SourceWord = @SourceWord ,
            TargetWord = @TargetWord ,
            ReplaceType = @ReplaceType ,
            ScopesType = @ScopesType ,
            Priority = @Priority ,
            ReplaceTimes = @ReplaceTimes ,
            OpenType = @OpenType ,
            IsEnabled = @IsEnabled ,
            Title = @Title
    WHERE   ItemID = @ItemID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_WordReplace_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_WordReplace_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_WordReplace_Add]
    (
      @ItemID INT ,
      @SourceWord NVARCHAR(250) ,
      @TargetWord NVARCHAR(250) ,
      @ReplaceType INT ,
      @ScopesType INT ,
      @Priority INT ,
      @ReplaceTimes INT ,
      @OpenType BIT ,
      @IsEnabled BIT ,
      @Title NVARCHAR(255)
    )
AS 
    INSERT  INTO [PE_WordReplaceItem]
            ( [SourceWord] ,
              [TargetWord] ,
              [ReplaceType] ,
              [ScopesType] ,
              [Priority] ,
              [ReplaceTimes] ,
              [OpenType] ,
              [IsEnabled] ,
              [Title]    
		)
    VALUES  ( @SourceWord ,
              @TargetWord ,
              @ReplaceType ,
              @ScopesType ,
              @Priority ,
              @ReplaceTimes ,
              @OpenType ,
              @IsEnabled ,
              @Title
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Source_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Source_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Source_Update]
    (
      @ID INT ,
      @Type VARCHAR(50) ,
      @Name VARCHAR(50) ,
      @Passed BIT ,
      @onTop BIT ,
      @IsElite BIT ,
      @Hits INT ,
      @LastUseTime DATETIME ,
      @Photo VARCHAR(50) ,
      @Intro NVARCHAR(255) ,
      @Address VARCHAR(50) ,
      @Tel VARCHAR(50) ,
      @Fax VARCHAR(50) ,
      @Mail VARCHAR(50) ,
      @Email VARCHAR(50) ,
      @ZipCode NVARCHAR(50) ,
      @HomePage VARCHAR(50) ,
      @Im VARCHAR(50) ,
      @ContacterName VARCHAR(50)
    )
AS 
    IF @ID > 0 
        BEGIN
            UPDATE  PE_Source
            SET     Type = @Type ,
                    [Name] = @Name ,
                    Passed = @Passed ,
                    onTop = @onTop ,
                    IsElite = @IsElite ,
                    Hits = @Hits ,
                    LastUseTime = @LastUseTime ,
                    Photo = @Photo ,
                    Intro = @Intro ,
                    Address = @Address ,
                    Tel = @Tel ,
                    Fax = @Fax ,
                    Mail = @Mail ,
                    Email = @Email ,
                    ZipCode = @ZipCode ,
                    HomePage = @HomePage ,
                    Im = @Im ,
                    Contacter = @ContacterName
            WHERE   ID = @ID
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Source_Insert]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Source_Insert]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Source_Insert]
    (
      @Type VARCHAR(50) ,
      @Name VARCHAR(50) ,
      @Passed BIT ,
      @onTop BIT ,
      @IsElite BIT ,
      @Hits INT ,
      @LastUseTime DATETIME ,
      @Photo VARCHAR(50) ,
      @Intro NVARCHAR(255) ,
      @Address VARCHAR(50) ,
      @Tel VARCHAR(50) ,
      @Fax VARCHAR(50) ,
      @Mail VARCHAR(50) ,
      @Email VARCHAR(50) ,
      @ZipCode NVARCHAR(50) ,
      @HomePage VARCHAR(50) ,
      @Im VARCHAR(50) ,
      @ContacterName VARCHAR(50)
    )
AS 
    INSERT  INTO PE_Source
            ( Type ,
              Name ,
              Passed ,
              onTop ,
              IsElite ,
              Hits ,
              LastUseTime ,
              Photo ,
              Intro ,
              Address ,
              Tel ,
              Fax ,
              Mail ,
              Email ,
              ZipCode ,
              HomePage ,
              Im ,
              Contacter
            )
    VALUES  ( @Type ,
              @Name ,
              @Passed ,
              @onTop ,
              @IsElite ,
              @Hits ,
              @LastUseTime ,
              @Photo ,
              @Intro ,
              @Address ,
              @Tel ,
              @Fax ,
              @Mail ,
              @Email ,
              @ZipCode ,
              @HomePage ,
              @Im ,
              @ContacterName
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Source_GetSourceInfoByType]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Source_GetSourceInfoByType]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Source_GetSourceInfoByType] ( @Type VARCHAR(1000) )
AS 
    SELECT  ID ,
            Type ,
            [Name] ,
            Passed ,
            onTop ,
            IsElite ,
            Hits ,
            LastUseTime ,
            Photo ,
            Intro ,
            Address ,
            Tel ,
            Fax ,
            Mail ,
            Email ,
            ZipCode ,
            HomePage ,
            Im ,
            Contacter
    FROM    PE_Source
    WHERE   Type = @Type
    ORDER BY ID DESC 	
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Source_GetSourceInfoByID]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Source_GetSourceInfoByID]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Source_GetSourceInfoByID] ( @ID INT )
AS 
    IF @ID > 0 
        BEGIN
            SELECT  ID ,
                    Type ,
                    [Name] ,
                    Passed ,
                    onTop ,
                    IsElite ,
                    Hits ,
                    LastUseTime ,
                    Photo ,
                    Intro ,
                    Address ,
                    Tel ,
                    Fax ,
                    Mail ,
                    Email ,
                    ZipCode ,
                    HomePage ,
                    Im ,
                    Contacter
            FROM    PE_Source
            WHERE   ID = @ID
        END
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Source_GetSourceInfo]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Source_GetSourceInfo]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Source_GetSourceInfo]
AS 
    SELECT  ID ,
            Type ,
            [Name] ,
            Passed ,
            onTop ,
            IsElite ,
            Hits ,
            LastUseTime ,
            Photo ,
            Intro ,
            Address ,
            Tel ,
            Fax ,
            Mail ,
            Email ,
            ZipCode ,
            HomePage ,
            Im ,
            Contacter
    FROM    PE_Source
    ORDER BY ID DESC 	
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Source_Delete]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Source_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Source_Delete] ( @ID NVARCHAR(100) )
AS 
    IF @ID IS NOT NULL 
        BEGIN
            DELETE  FROM PE_Source
            WHERE   ID IN ( @ID )
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Region_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Region_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Region_Update]
    (
      @RegionID INT ,
      @Country NVARCHAR(20) ,
      @Province NVARCHAR(25) ,
      @City NVARCHAR(30) ,
      @Area VARCHAR(25) ,
      @PostCode VARCHAR(10) ,
      @AreaCode NVARCHAR(8)
    )
AS 
    SET NOCOUNT OFF
    UPDATE  PE_Region
    SET     Country = @Country ,
            Province = @Province ,
            City = @City ,
            Area = @Area ,
            PostCode = @PostCode ,
            AreaCode = @AreaCode
    WHERE   RegionID = @RegionID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Region_GetProvinceList]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Region_GetProvinceList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Region_GetProvinceList]
AS 
    SET NOCOUNT ON
    SELECT DISTINCT
            Province
    FROM    PE_Region' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Region_GetByID]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Region_GetByID]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Region_GetByID] ( @RegionId INT )
AS 
    SELECT  *
    FROM    PE_Region
    WHERE   RegionID = @RegionId  
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Region_Delete]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Region_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Region_Delete] ( @RegionID VARCHAR(10) )
AS 
    SET NOCOUNT OFF 
    DELETE  PE_Region
    WHERE   [RegionID] = @RegionID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Region_CheckArea]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Region_CheckArea]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Region_CheckArea]
    (
      @Area VARCHAR(25) ,
      @Province VARCHAR(30) ,
      @City VARCHAR(25)
    )
AS 
    SET NOCOUNT ON
    SELECT  COUNT(*)
    FROM    PE_Region
    WHERE   Area = @Area
            AND Province = @Province
            AND City = @City
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Region_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Region_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Region_Add]
    (
      @Country NVARCHAR(20) ,
      @Province NVARCHAR(25) ,
      @City NVARCHAR(30) ,
      @Area VARCHAR(25) ,
      @PostCode VARCHAR(10) ,
      @AreaCode NVARCHAR(8)
    )
AS 
    SET NOCOUNT OFF
    INSERT  INTO PE_Region
            ( Country ,
              Province ,
              City ,
              Area ,
              PostCode ,
              AreaCode
            )
    VALUES  ( @Country ,
              @Province ,
              @City ,
              @Area ,
              @PostCode ,
              @AreaCode
            )
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_PayPlatform_Update]
    (
      @PayPlatformID INT ,
      @PayPlatformName NVARCHAR(100) ,
      @AccountsID NVARCHAR(100) ,
      @MD5 NVARCHAR(200) ,
      @Rate DECIMAL(18, 10) ,
      @OrderID INT ,
      @IsDisabled BIT ,
      @IsDefault BIT,
      @PayPlatformIcon NVARCHAR(255),
      @Remark NTEXT
    )
AS 
    IF @IsDefault = 1 
        BEGIN
            UPDATE  PE_PayPlatform
            SET     [IsDefault] = 0
            WHERE   [IsDefault] = 1
        END
 
    UPDATE  PE_PayPlatform
    SET     [PayPlatformName] = @PayPlatformName ,
            [AccountsID] = @AccountsID ,
            [MD5] = @MD5 ,
            [Rate] = @Rate ,
            [OrderID] = @OrderID ,
            [IsDisabled] = @IsDisabled ,
            [IsDefault] = @IsDefault,
            [PayPlatformIcon] = @PayPlatformIcon,
            [Remark] = @Remark
    WHERE   [PayPlatformID] = @PayPlatformID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_SetOrderId]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_SetOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_PayPlatform_SetOrderId]
    (
      @PayPlatformID INT ,
      @OrderID INT
    )
AS 
    IF NOT EXISTS ( SELECT  OrderID
                    FROM    PE_PayPlatform
                    WHERE   OrderID = @OrderID
                            AND [PayPlatformID] = @PayPlatformID ) 
        BEGIN
            UPDATE  PE_PayPlatform
            SET     [OrderID] = @OrderID
            WHERE   [PayPlatformID] = @PayPlatformID
        END	
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_SetDefault]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_SetDefault]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_PayPlatform_SetDefault] ( @PayPlatformId INT )
AS 
    UPDATE  PE_PayPlatForm
    SET     [IsDefault] = 0
		
    UPDATE  PE_PayPlatForm
    SET     [IsDefault] = 1
    WHERE   [PayPlatformId] = @PayPlatformId
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_GetListOfdisabled]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_GetListOfdisabled]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_PayPlatform_GetListOfdisabled] ( @isdisabled BIT )
AS 
    SELECT  *
    FROM    PE_PayPlatform
    WHERE   IsDisabled = @isdisabled
    ORDER BY OrderID ASC
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_GetList]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_GetList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_PayPlatform_GetList]
AS 
    SELECT  *
    FROM    PE_PayPlatform
    ORDER BY OrderID ASC' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_GetInfoById]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_GetInfoById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_PayPlatform_GetInfoById] ( @PayPlatformID INT )
AS 
    SELECT  *
    FROM    PE_PayPlatform
    WHERE   [PayPlatformID] = @PayPlatformID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_DisablePayPlatform]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_DisablePayPlatform]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_PayPlatform_DisablePayPlatform]
    (
      @PayPlatformID INT ,
      @IsDisabled BIT
    )
AS 
    SET NOCOUNT OFF
    UPDATE  PE_PayPlatform
    SET     [IsDisabled] = @IsDisabled
    WHERE   [PayPlatformID] = @PayPlatformID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_Delete]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_PayPlatform_Delete] ( @PayPlatformID INT )
AS 
    SET NOCOUNT OFF
    DELETE  PE_PayPlatform
    WHERE   [PayPlatformID] = @PayPlatformID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PayPlatform_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PayPlatform_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_PayPlatform_Add]
    (
      @PayPlatformID INT ,
      @PayPlatformName NVARCHAR(100) ,
      @AccountsID NVARCHAR(100) ,
      @MD5 NVARCHAR(200) ,
      @Rate NUMERIC(18, 2) ,
      @IsDisabled BIT ,
      @IsDefault BIT,
      @PayPlatformIcon nvarchar(255),
      @Remark NTEXT
    )
AS 
    DECLARE @TempID INT
    SELECT  @TempID = ( ISNULL(MAX(OrderId), 0) + 1 )
    FROM    PE_PayPlatform
    IF @IsDefault = 1 
        BEGIN
            UPDATE  PE_PayPlatform
            SET     [IsDefault] = 0
            WHERE   [IsDefault] = 1
        END	
    SET NOCOUNT OFF 
    INSERT  INTO PE_PayPlatform
            ( [PayPlatformID] ,
              [PayPlatformName] ,
              [AccountsID] ,
              [MD5] ,
              [Rate] ,
              [OrderID] ,
              [IsDisabled] ,
              [IsDefault],
              [PayPlatformIcon],
              [Remark]
		)
    VALUES  ( @PayPlatformID ,
              @PayPlatformName ,
              @AccountsID ,
              @MD5 ,
              @Rate ,
              @TempID ,
              @IsDisabled ,
              @IsDefault,
              @PayPlatformIcon,
              @Remark
		)
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PaymentLog_Update2]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PaymentLog_Update2]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_PaymentLog_Update2]
    (
      @PaymentLogID INT ,
      @UserName NVARCHAR(100) ,
      @OrderID INT ,
      @PaymentNum NVARCHAR(50) ,
      @PlatformID INT ,
      @MoneyPay MONEY ,
      @MoneyTrue MONEY ,
      @PayTime DATETIME ,
      @SuccessTime DATETIME ,
      @Status INT ,
      @PlatformInfo NVARCHAR(200) ,
      @Remark NVARCHAR(255) ,
      @Point INT ,
      @TradeNum NVARCHAR(50)
    )
AS 
    UPDATE  [PE_PaymentLog]
    SET     [UserName] = @UserName ,
            [OrderID] = @OrderID ,
            [PaymentNum] = @PaymentNum ,
            [PlatformID] = @PlatformID ,
            [MoneyPay] = @MoneyPay ,
            [MoneyTrue] = @MoneyTrue ,
            [PayTime] = @PayTime ,
            [SuccessTime] = @SuccessTime ,
            [Status] = @Status ,
            [PlatformInfo] = @PlatformInfo ,
            [Remark] = @Remark ,
            [Point] = @Point ,
            [TradeNum] = @TradeNum
    WHERE   [PaymentLogID] = @PaymentLogID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PaymentLog_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PaymentLog_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_PaymentLog_Update] 
    @paymentLogId INT ,
    @Status INT ,
    @PlatformInfo NVARCHAR(200) ,
    @Remark NVARCHAR(255)
AS 
    DECLARE @foundStatus INT
    SELECT  @foundStatus = Status
    FROM    PE_PaymentLog
    WHERE   PaymentLogId = @paymentLogId
    IF @foundStatus IS NOT NULL 
        IF ( @foundStatus > 1 ) 
            RETURN 1
        ELSE 
            BEGIN
                UPDATE  PE_PaymentLog
                SET     Status = @Status ,
                        PlatformInfo = @PlatformInfo ,
                        Remark = @Remark
                WHERE   PaymentLogId = @paymentLogId
                RETURN 2
            END
    ELSE 
        RETURN 0' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_PaymentLog_GetList]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_PaymentLog_GetList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_PaymentLog_GetList] 
AS
BEGIN
	SELECT * FROM [PE_PaymentLog] ORDER BY [PaymentLogID] DESC
END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Message_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Message_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Message_Add]
    (
      @Title NVARCHAR(100) ,
      @Content NTEXT ,
      @Sender NVARCHAR(20) ,
      @Incept NVARCHAR(4000) ,
      @SendTime DATETIME ,
      @IsSend INT ,
      @IsDelInbox INT ,
      @IsDelSendbox INT ,
      @IsRead INT
    )
AS 
    DECLARE @Index INT 
    DECLARE @SplitChar NVARCHAR(2) --分隔符，格式：“，”

    SET @Index = 0
    SET @SplitChar = '',''   
    IF CHARINDEX(@SplitChar, @Incept, @Index) = 0 
        BEGIN
            INSERT  INTO [PE_Message]
                    ( [Title] ,
                      [Content] ,
                      [Sender] ,
                      [Incept] ,
                      [SendTime] ,
                      [IsSend] ,
                      [IsDelInbox] ,
                      [IsDelSendbox] ,
                      [IsRead]
				
                    )
            VALUES  ( @Title ,
                      @Content ,
                      @Sender ,
                      @Incept ,
                      @SendTime ,
                      @IsSend ,
                      @IsDelInbox ,
                      @IsDelSendbox ,
                      @IsRead
			  )
        END
    ELSE 
        BEGIN
            WHILE CHARINDEX(@SplitChar, @Incept, @Index) > 0 
                BEGIN
                    INSERT  INTO [PE_Message]
                            ( [Title] ,
                              [Content] ,
                              [Sender] ,
                              [Incept] ,
                              [SendTime] ,
                              [IsSend] ,
                              [IsDelInbox] ,
                              [IsDelSendbox] ,
                              [IsRead]
                            )
                    VALUES  ( @Title ,
                              @Content ,
                              @Sender ,
                              SUBSTRING(@Incept, @Index,
                                        CHARINDEX(@SplitChar, @Incept, @Index)
                                        - @Index) ,
                              @SendTime ,
                              @IsSend ,
                              @IsDelInbox ,
                              @IsDelSendbox ,
                              @IsRead
					
                            )
                    SET @Index = CHARINDEX(@SplitChar, @Incept, @Index) + 1 
                END
            INSERT  INTO [PE_Message]
                    ( [Title] ,
                      [Content] ,
                      [Sender] ,
                      [Incept] ,
                      [SendTime] ,
                      [IsSend] ,
                      [IsDelInbox] ,
                      [IsDelSendbox] ,
                      [IsRead]
						
                    )
            VALUES  ( @Title ,
                      @Content ,
                      @Sender ,
                      SUBSTRING(@Incept, @Index, LEN(@Incept) - @Index + 1) ,
                      @SendTime ,
                      @IsSend ,
                      @IsDelInbox ,
                      @IsDelSendbox ,
                      @IsRead
                    )
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Log_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Log_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Log_Update]
    (
      @LogID INT ,
      @Category INT ,
      @Priority INT ,
      @Title NVARCHAR(255) ,
      @Message TEXT ,
      @Timestamp DATETIME ,
      @UserName NVARCHAR(255) ,
      @UserIP NVARCHAR(50) ,
      @Source TEXT ,
      @ScriptName NVARCHAR(255) ,
      @PostString TEXT    
    )
AS 
    UPDATE  [PE_Log]
    SET     [Category] = @Category ,
            [Priority] = @Priority ,
            [Title] = @Title ,
            [Message] = @Message ,
            [Timestamp] = @Timestamp ,
            [UserName] = @UserName ,
            [UserIP] = @UserIP ,
            [Source] = @Source ,
            [ScriptName] = @ScriptName ,
            [PostString] = @PostString
    WHERE   LogID = @LogID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Log_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Log_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Log_Add]
    (
      @Category INT ,
      @Priority INT ,
      @Title NVARCHAR(255) ,
      @Message TEXT ,
      @Timestamp DATETIME ,
      @UserName NVARCHAR(255) ,
      @UserIP NVARCHAR(50) ,
      @Source TEXT ,
      @ScriptName NVARCHAR(255) ,
      @PostString TEXT    
    )
AS 
    INSERT  INTO [PE_Log]
            ( Category ,
              Priority ,
              Title ,
              [Message] ,
              [Timestamp] ,
              UserName ,
              UserIP ,
              Source ,
              ScriptName ,
              PostString    
		)
    VALUES  ( @Category ,
              @Priority ,
              @Title ,
              @Message ,
              @Timestamp ,
              @UserName ,
              @UserIP ,
              @Source ,
              @ScriptName ,
              @PostString     
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Keywords_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Keywords_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Keywords_Update]
    (
      @KeywordID INT ,
      @KeywordText NVARCHAR(200) ,
      @KeywordType INT ,
      @Priority INT ,
      @LastUseTime DATETIME ,
      @QuoteTimes INT
    )
AS 
    UPDATE  PE_Keywords
    SET     KeywordText = @KeywordText ,
            KeywordType = @KeywordType ,
            Priority = @Priority ,
            LastUseTime = @LastUseTime ,
            QuoteTimes = @QuoteTimes
    WHERE   KeywordID = @KeywordID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Keywords_SearchKeyword]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Keywords_SearchKeyword]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Keywords_SearchKeyword]
    @KeywordText NVARCHAR(200)
AS 
    IF EXISTS ( SELECT  *
                FROM    PE_Keywords
                WHERE   KeywordText = @KeywordText ) 
        UPDATE  PE_Keywords
        SET     Hits = Hits + 1 ,
                LastUseTime = GETDATE()
        WHERE   KeywordText = @KeywordText

    ELSE 
        INSERT  PE_Keywords
                ( KeywordText, Hits, LastUseTime )
        VALUES  ( @KeywordText, 1, GETDATE() )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Keywords_GetById]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Keywords_GetById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Keywords_GetById] ( @KeywordID INT )
AS 
    SELECT  KeywordID ,
            KeywordText ,
            KeywordType ,
            Priority ,
            Hits ,
            LastUseTime ,
            QuoteTimes
    FROM    PE_Keywords
    WHERE   KeywordID = @KeywordID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Keywords_Exists]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Keywords_Exists]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Keywords_Exists]
    (
      @KeywordText NVARCHAR(200)
    )
AS 
    SELECT  COUNT(*)
    FROM    PE_Keywords
    WHERE   KeywordText = @KeywordText' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_BankrollItem_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_BankrollItem_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_BankrollItem_Update]
    @ItemId INT ,
    @UserName NVARCHAR(100) ,
    @ClientId INT ,
    @DateAndTime DATETIME ,
    @Money MONEY ,
    @MoneyType INT ,
    @CurrencyType INT ,
    @eBankId INT ,
    @Bank NVARCHAR(50) ,
    @OrderID INT ,
    @PaymentId INT ,
    @Remark NVARCHAR(255) ,
    @LogTime DATETIME ,
    @Inputer NVARCHAR(50) ,
    @IP NVARCHAR(50) ,
    @Status INT ,
    @IsConsume BIT
AS 
    SET NOCOUNT OFF

    UPDATE  [dbo].[PE_BankrollItem]
    SET     [UserName] = @UserName ,
            [ClientId] = @ClientId ,
            [DateAndTime] = @DateAndTime ,
            [Money] = @Money ,
            [MoneyType] = @MoneyType ,
            [CurrencyType] = @CurrencyType ,
            [eBankId] = @eBankId ,
            [Bank] = @Bank ,
            [OrderId] = @OrderId ,
            [PaymentId] = @PaymentId ,
            [Remark] = @Remark ,
            [LogTime] = @LogTime ,
            [Inputer] = @Inputer ,
            [IP] = @IP ,
            [Status] = @Status ,
            [IsConsume] = @IsConsume
    WHERE   [ItemId] = @ItemId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_BankrollItem_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_BankrollItem_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_BankrollItem_Add]
    @UserName NVARCHAR(100) = NULL ,
    @ClientID INT = 0 ,
    @DateAndTime DATETIME = 0 ,
    @Money MONEY = 0 ,
    @MoneyType INT = 0 ,
    @CurrencyType INT = 0 ,
    @eBankID INT = 0 ,
    @Bank NVARCHAR(50) = NULL ,
    @OrderID INT = 0 ,
    @PaymentID INT = 0 ,
    @Remark NVARCHAR(255) = NULL ,
    @LogTime DATETIME = 0 ,
    @Inputer NVARCHAR(50) = NULL ,
    @IP NVARCHAR(50) = NULL ,
    @Status INT ,
    @Memo NTEXT ,
    @IsConsume BIT
AS 
    SET NOCOUNT OFF

    INSERT  INTO [dbo].[PE_BankrollItem]
            ( [UserName] ,
              [ClientID] ,
              [DateAndTime] ,
              [Money] ,
              [MoneyType] ,
              [CurrencyType] ,
              [eBankID] ,
              [Bank] ,
              [OrderID] ,
              [PaymentID] ,
              [Remark] ,
              [LogTime] ,
              [Inputer] ,
              [IP] ,
              [Status] ,
              [Memo] ,
              [IsConsume]
            )
    VALUES  ( @UserName ,
              @ClientID ,
              @DateAndTime ,
              @Money ,
              @MoneyType ,
              @CurrencyType ,
              @eBankID ,
              @Bank ,
              @OrderID ,
              @PaymentID ,
              @Remark ,
              @LogTime ,
              @Inputer ,
              @IP ,
              @Status ,
              @Memo ,
              @IsConsume
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Bank_Update]
    (
      @BankID INT ,
      @BankShortName NVARCHAR(100) ,
      @BankName NVARCHAR(100) ,
      @Accounts NVARCHAR(100) ,
      @CardNum NVARCHAR(100) ,
      @HolderName NVARCHAR(100) ,
      @BankIntro NVARCHAR(510) ,
      @BankPic NVARCHAR(400) ,
      @IsDefault BIT ,
      @IsDisabled BIT ,
      @OrderID INT
    )
AS 
    IF ( @IsDisabled = 1 ) 
        BEGIN
            UPDATE  [PE_Bank]
            SET     IsDefault = 0
            WHERE   IsDefault = 1
        END
    IF @orderId <> 0 
        BEGIN
            DECLARE @oldOrderId INT
            DECLARE @max INT
            DECLARE @min INT
            DECLARE @count INT
            DECLARE @icount INT
            DECLARE @offset1 INT
            DECLARE @offset2 INT

            SET @icount = 1
            DECLARE @tmp TABLE
                (
                  Row INT IDENTITY(1, 1)
                          PRIMARY KEY ,
                  id INT ,
                  oid INT
                )
            SELECT  @oldOrderId = OrderId
            FROM    [PE_Bank]
            WHERE   BankID = @BankId
            IF ( @orderId <> @oldOrderId ) 
                BEGIN
                    IF ( @orderId > @oldOrderId ) 
                        BEGIN
                            SET @max = @orderId
                            SET @min = @oldOrderId
                            SET @offset1 = 0
                            SET @offset2 = 1
                        END
                    ELSE 
                        BEGIN
                            SET @max = @oldOrderId
                            SET @min = @orderId
                            SET @offset1 = 1
                            SET @offset2 = 0
                        END
                    INSERT  INTO @tmp
                            ( id ,
                              oid
                            )
                            SELECT  BankId ,
                                    OrderId
                            FROM    [PE_Bank]
                            WHERE   OrderId BETWEEN @min AND @max
                            ORDER BY orderId
                    SELECT  @count = COUNT(*)
                    FROM    @tmp

                    WHILE ( @icount < @count ) 
                        BEGIN
                            UPDATE  [PE_Bank]
                            SET     OrderId = ( SELECT  oid
                                                FROM    @tmp
                                                WHERE   Row = @icount
                                                        + @offset1
                                              )
                            WHERE   BankId = ( SELECT   Id
                                               FROM     @tmp
                                               WHERE    Row = @icount
                                                        + @offset2
                                             )
                            SET @icount = @icount + 1
                        END 
                END
            UPDATE  [PE_Bank]
            SET     [BankShortName] = @BankShortName ,
                    [BankName] = @BankName ,
                    [Accounts] = @Accounts ,
                    [CardNum] = @CardNum ,
                    [HolderName] = @HolderName ,
                    [BankIntro] = @BankIntro ,
                    [BankPic] = @BankPic ,
                    [IsDefault] = @IsDefault ,
                    [IsDisabled] = @IsDisabled ,
                    [OrderID] = @OrderID
            WHERE   [BankID] = @BankID
        END
    ELSE 
        BEGIN
            UPDATE  [PE_Bank]
            SET     [BankShortName] = @BankShortName ,
                    [BankName] = @BankName ,
                    [Accounts] = @Accounts ,
                    [CardNum] = @CardNum ,
                    [HolderName] = @HolderName ,
                    [BankIntro] = @BankIntro ,
                    [BankPic] = @BankPic ,
                    [IsDefault] = @IsDefault ,
                    [IsDisabled] = @IsDisabled ,
                    [OrderID] = @OrderID
            WHERE   [BankID] = @BankID
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_SetOrderID]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_SetOrderID]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Bank_SetOrderID]
    (
      @BankID INT ,
      @OrderID INT
    )
AS 
    IF NOT EXISTS ( SELECT  OrderID
                    FROM    PE_Bank
                    WHERE   OrderID = @OrderID
                            AND BankID <> @BankID ) 
        BEGIN
            UPDATE  PE_Bank
            SET     [OrderID] = @OrderID
            WHERE   [BankID] = @BankID
        END	
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_SetDisabled]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_SetDisabled]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Bank_SetDisabled]
    (
      @BankID INT ,
      @IsDisabled BIT
    )
AS 
    SET NOCOUNT OFF
    UPDATE  PE_Bank
    SET     [IsDisabled] = @IsDisabled
    WHERE   [BankID] = @BankID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_SetDefault]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_SetDefault]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Bank_SetDefault] ( @BankID INT )
AS 
    UPDATE  PE_Bank
    SET     [IsDefault] = 0
		
    UPDATE  PE_Bank
    SET     [IsDefault] = 1
    WHERE   [BankID] = @BankID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_GetList]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_GetList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Bank_GetList]
AS 
    SET NOCOUNT OFF	
    SELECT  [BankID] ,
            [BankShortName] ,
            [BankName] ,
            [Accounts] ,
            [CardNum] ,
            [HolderName] ,
            [BankIntro] ,
            [BankPic] ,
            [IsDefault] ,
            [IsDisabled] ,
            [OrderID]
    FROM    PE_Bank
    ORDER BY IsDefault DESC ,
            OrderID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_GetBankInfoByID]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_GetBankInfoByID]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Bank_GetBankInfoByID] ( @BankID INT )
AS 
    SET NOCOUNT OFF
    SELECT  [BankID] ,
            [BankShortName] ,
            [BankName] ,
            [Accounts] ,
            [CardNum] ,
            [HolderName] ,
            [BankIntro] ,
            [BankPic] ,
            [IsDefault] ,
            [IsDisabled] ,
            [OrderID]
    FROM    PE_Bank
    WHERE   [BankID] = @BankID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_Delete]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Bank_Delete] ( @BankID INT )
AS 
    SET NOCOUNT OFF
    DELETE  PE_Bank
    WHERE   [BankID] = @BankID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Bank_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Bank_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Bank_Add]
    (
      @BankID INT ,
      @BankShortName NVARCHAR(100) ,
      @BankName NVARCHAR(100) ,
      @Accounts NVARCHAR(100) ,
      @CardNum NVARCHAR(100) ,
      @HolderName NVARCHAR(100) ,
      @BankIntro NVARCHAR(510) ,
      @BankPic NVARCHAR(400) ,
      @IsDefault BIT ,
      @IsDisabled BIT 
    )
AS 
    SET NOCOUNT OFF 
    DECLARE @TempID INT

    SELECT  @TempID = ( ISNULL(MAX(OrderId), 0) + 1 )
    FROM    PE_Bank

    INSERT  INTO PE_Bank
            ( [BankID] ,
              [BankShortName] ,
              [BankName] ,
              [Accounts] ,
              [CardNum] ,
              [HolderName] ,
              [BankIntro] ,
              [BankPic] ,
              [IsDefault] ,
              [IsDisabled] ,
              [OrderID]
	      )
    VALUES  ( @BankID ,
              @BankShortName ,
              @BankName ,
              @Accounts ,
              @CardNum ,
              @HolderName ,
              @BankIntro ,
              @BankPic ,
              @IsDefault ,
              @IsDisabled ,
              @TempID
	      )
    IF @IsDefault = 1 
        UPDATE  PE_Bank
        SET     IsDefault = 0
        WHERE   BankShortName != @BankShortName
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Author_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Author_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Author_Update]
    (
      @ID INT ,
      @UserId INT ,
      @Name VARCHAR(50) ,
      @Type VARCHAR(50) ,
      @Passed BIT ,
      @onTop BIT ,
      @IsElite BIT ,
      @Hits INT ,
      @LastUseTime DATETIME ,
      @TemplateID INT ,
      @Photo VARCHAR(255) ,
      @Intro NTEXT ,
      @Address VARCHAR(50) ,
      @Tel VARCHAR(50) ,
      @Fax VARCHAR(50) ,
      @Mail VARCHAR(50) ,
      @Email VARCHAR(50) ,
      @ZipCode NVARCHAR(50) ,
      @HomePage VARCHAR(50) ,
      @Im VARCHAR(50) ,
      @Sex SMALLINT ,
      @BirthDay DATETIME ,
      @Company VARCHAR(50) ,
      @Department VARCHAR(50)
    )
AS 
    IF @ID > 0 
        BEGIN

            UPDATE  PE_Author
            SET     UserID = @UserId ,
                    Type = @Type ,
                    [Name] = @Name ,
                    Passed = @Passed ,
                    onTop = @onTop ,
                    IsElite = @IsElite ,
                    Hits = @Hits ,
                    LastUseTime = @LastUseTime ,
                    TemplateID = @TemplateID ,
                    Photo = @Photo ,
                    Intro = @Intro ,
                    Address = @Address ,
                    Tel = @Tel ,
                    Fax = @Fax ,
                    Mail = @Mail ,
                    Email = @Email ,
                    ZipCode = @ZipCode ,
                    HomePage = @HomePage ,
                    Im = @Im ,
                    Sex = @Sex ,
                    BirthDay = @BirthDay ,
                    Company = @Company ,
                    Department = @Department
            WHERE   ID = @ID
		
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Author_GetAuthorInfoByID]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Author_GetAuthorInfoByID]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Author_GetAuthorInfoByID] ( @ID INT )
AS 
    IF @ID > 0 
        BEGIN
            SELECT  ID ,
                    UserID ,
                    Type ,
                    [Name] ,
                    Passed ,
                    onTop ,
                    IsElite ,
                    Hits ,
                    LastUseTime ,
                    TemplateID ,
                    Photo ,
                    Intro ,
                    Address ,
                    Tel ,
                    Fax ,
                    Mail ,
                    Email ,
                    ZipCode ,
                    HomePage ,
                    Im ,
                    Sex ,
                    BirthDay ,
                    Company ,
                    Department
            FROM    PE_Author
            WHERE   ID = @ID
        END
	
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Author_Delete]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Author_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Author_Delete] ( @ID NVARCHAR(100) )
AS 
    IF @ID IS NOT NULL 
        BEGIN
            DELETE  FROM PE_Author
            WHERE   ID IN ( @ID ) 
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Author_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Author_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Author_Add]
    (
      @UserId INT ,
      @Name VARCHAR(50) ,
      @Type VARCHAR(50) ,
      @Passed BIT ,
      @onTop BIT ,
      @IsElite BIT ,
      @Hits INT ,
      @LastUseTime DATETIME ,
      @TemplateID INT ,
      @Photo VARCHAR(255) ,
      @Intro NTEXT ,
      @Address VARCHAR(50) ,
      @Tel VARCHAR(50) ,
      @Fax VARCHAR(50) ,
      @Mail VARCHAR(50) ,
      @Email VARCHAR(50) ,
      @ZipCode NVARCHAR(50) ,
      @HomePage VARCHAR(50) ,
      @Im VARCHAR(50) ,
      @Sex SMALLINT ,
      @BirthDay DATETIME ,
      @Company VARCHAR(50) ,
      @Department VARCHAR(50)
    )
AS 
    INSERT  INTO PE_Author
            ( UserID ,
              Type ,
              [Name] ,
              Passed ,
              onTop ,
              IsElite ,
              Hits ,
              LastUseTime ,
              TemplateID ,
              Photo ,
              Intro ,
              Address ,
              Tel ,
              Fax ,
              Mail ,
              Email ,
              ZipCode ,
              HomePage ,
              Im ,
              Sex ,
              BirthDay ,
              Company ,
              Department
            )
    VALUES  ( @UserId ,
              @Type ,
              @Name ,
              @Passed ,
              @onTop ,
              @IsElite ,
              @Hits ,
              @LastUseTime ,
              @TemplateID ,
              @Photo ,
              @Intro ,
              @Address ,
              @Tel ,
              @Fax ,
              @Mail ,
              @Email ,
              @ZipCode ,
              @HomePage ,
              @Im ,
              @Sex ,
              @BirthDay ,
              @Company ,
              @Department
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Keywords_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Keywords_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Keywords_Add]
    (
      @KeywordText NVARCHAR(200) ,
      @KeywordType INT ,
      @Priority INT ,
      @QuoteTimes INT
    )
AS 
    INSERT  INTO PE_Keywords
            ( KeywordText ,
              KeywordType ,
              Priority ,
              QuoteTimes
            )
    VALUES  ( @KeywordText ,
              @KeywordType ,
              @Priority ,
              @QuoteTimes
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_UpdateOrderId]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_UpdateOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_UpdateOrderId]
    (
      @ServerID INT ,
      @OrderID INT
    )
AS 
    UPDATE  PE_DownServer
    SET     OrderID = @OrderID
    WHERE   ServerID = @ServerID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_Update]
    (
      @ServerID INT ,
      @ServerName NVARCHAR(50) ,
      @ServerUrl NVARCHAR(50) ,
      @ServerLogo NVARCHAR(255) ,
      @OrderID INT ,
      @ShowType INT
	
    )
AS 
    UPDATE  PE_DownServer
    SET     ServerName = @ServerName ,
            ServerUrl = @ServerUrl ,
            ServerLogo = @ServerLogo ,
            OrderID = @OrderID ,
            ShowType = @ShowType
    WHERE   ServerID = @ServerID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_SetShowType]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_SetShowType]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_SetShowType]
    (
      @ServerID NVARCHAR(4000) ,--格式：“1，2，3，4，”
      @ShowType INT ,
      @SplitChar NVARCHAR(10)--格式：“，”
	
    )
AS
    DECLARE @TemptTable TABLE ( ID INT )   
    DECLARE @Index INT   
    SET @Index = 0   
    IF CHARINDEX(@SplitChar, @ServerID, @Index) = 0 
        UPDATE  PE_DownServer
        SET     ShowType = @ShowType
        WHERE   ServerID = @ServerID
    ELSE 
        WHILE CHARINDEX(@SplitChar, @ServerID, @Index) > 0   --循环   
            BEGIN   
                INSERT  INTO @TemptTable
                        ( ID
                        )
                VALUES  ( SUBSTRING(@ServerID, @Index,
                                    CHARINDEX(@SplitChar, @ServerID, @Index)
                                    - @Index)
                        )     
                SET @Index = CHARINDEX(@SplitChar, @ServerID, @Index) + 1   
            END   

    UPDATE  PE_DownServer
    SET     ShowType = @ShowType
    WHERE   ( ServerID IN ( SELECT  ID
                            FROM    @TemptTable ) )  
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_MoveUpOrderId]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_MoveUpOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_MoveUpOrderId] ( @OrderID INT )
AS 
    SET NOCOUNT ON
    UPDATE  PE_DownServer
    SET     OrderID = OrderID + 1
    WHERE   OrderID = @OrderID 
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_MoveOrderId]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_MoveOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_MoveOrderId]
    (
      @ServerID INT ,
      @AddNum INT
	
    )
AS
    UPDATE  PE_DownServer
    SET     OrderID = OrderID + @AddNum
    WHERE   ServerID = @ServerID 
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_MoveDownOrderId]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_MoveDownOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_MoveDownOrderId] ( @OrderID INT )
AS 
    SET NOCOUNT ON
    UPDATE  PE_DownServer
    SET     OrderID = OrderID - 1
    WHERE   OrderID = @OrderID 
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_GetUpOrderId]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_GetUpOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_GetUpOrderId] ( @OrderID INT )
AS 
    SET NOCOUNT ON
    SELECT  ServerID ,
            ServerName ,
            ServerUrl ,
            ServerLogo ,
            OrderID ,
            ShowType
    FROM    PE_DownServer
    WHERE   OrderID < @OrderID
    ORDER BY OrderID DESC  
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_GetServerUrlByServerId]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_GetServerUrlByServerId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_GetServerUrlByServerId] ( @ServerID INT )
AS 
    SET NOCOUNT ON
    SELECT  ServerID ,
            ServerUrl
    FROM    PE_DownServer
    WHERE   ServerID = @ServerID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_GetMaxOrderId]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_GetMaxOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_GetMaxOrderId]
AS 
    SET NOCOUNT ON  
    SELECT  ISNULL(MAX(OrderID), 0)
    FROM    PE_DownServer
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_GetList]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_GetList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_GetList]
AS 
    SET NOCOUNT ON
    SELECT  ServerID ,
            ServerName ,
            ServerUrl ,
            ServerLogo ,
            OrderID ,
            ShowType
    FROM    PE_DownServer
    ORDER BY OrderID ASC 
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_GetDownOrderId]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_GetDownOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_GetDownOrderId] ( @OrderID INT )
AS 
    SET NOCOUNT ON
    SELECT  ServerID ,
            ServerName ,
            ServerUrl ,
            ServerLogo ,
            OrderID ,
            ShowType
    FROM    PE_DownServer
    WHERE   OrderID > @OrderID
    ORDER BY OrderID ASC 
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_GetCountOrderId]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_GetCountOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_GetCountOrderId]
AS 
    SET NOCOUNT ON  
    SELECT  ISNULL(COUNT(ServerID), 0)
    FROM    PE_DownServer
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_GetById]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_GetById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_GetById] ( @ServerID INT )
AS 
    SET NOCOUNT ON
    SELECT  ServerID ,
            ServerName ,
            ServerUrl ,
            ServerLogo ,
            OrderID ,
            ShowType
    FROM    PE_DownServer
    WHERE   ServerID = @ServerID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_Delete]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_Delete] ( @ServerID INT )
AS 
    DECLARE @oldOrderId INT
    SELECT  @oldOrderId = OrderId
    FROM    PE_DownServer
    WHERE   ServerID = @ServerID
    IF ( @oldOrderId >= 0 ) 
        BEGIN
            UPDATE  PE_DownServer
            SET     OrderID = OrderID - 1
            WHERE   OrderID > @oldOrderId 
        END
    DELETE  PE_DownServer
    WHERE   [ServerID] = @ServerID  
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownServer_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownServer_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownServer_Add]
    (
      @ServerID INT ,
      @ServerName NVARCHAR(50) ,
      @ServerUrl NVARCHAR(50) ,
      @ServerLogo NVARCHAR(255) ,
      @OrderID INT ,
      @ShowType INT
	
    )
AS 
    INSERT  INTO PE_DownServer
            ( ServerID ,
              ServerName ,
              ServerUrl ,
              ServerLogo ,
              OrderID ,
              ShowType
            )
    VALUES  ( @ServerID ,
              @ServerName ,
              @ServerUrl ,
              @ServerLogo ,
              @OrderID ,
              @ShowType
            )  
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownloadError_Delete]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownloadError_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownloadError_Delete]
    (
      @ErrorID NVARCHAR(4000) ,--格式：“1，2，3，4，”
      @SplitChar NVARCHAR(10)--格式：“，”
	
    )
AS
    DECLARE @TemptTable TABLE ( ID INT )   
    DECLARE @Index INT   
    SET @Index = 0   
    IF CHARINDEX(@SplitChar, @ErrorID, @Index) = 0 
        DELETE  FROM PE_DownloadError
        WHERE   ErrorID = @ErrorID
    ELSE 
        WHILE CHARINDEX(@SplitChar, @ErrorID, @Index) > 0 
            BEGIN   
                INSERT  INTO @TemptTable
                        ( ID
                        )
                VALUES  ( SUBSTRING(@ErrorID, @Index,
                                    CHARINDEX(@SplitChar, @ErrorID, @Index)
                                    - @Index)
                        )     
                SET @Index = CHARINDEX(@SplitChar, @ErrorID, @Index) + 1   
            END  
		 
    DELETE  FROM PE_DownloadError
    WHERE   ( ErrorID IN ( SELECT   ID
                           FROM     @TemptTable ) )  
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownloadError_Clear]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownloadError_Clear]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownloadError_Clear]
AS
    DELETE  FROM PE_DownloadError 
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_DownloadError_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_DownloadError_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_DownloadError_Add]
    (
      @ErrorID INT ,
      @InfoID INT ,
      @ErrorUrl NVARCHAR(255) ,
      @ErrorTimes INT ,
      @ErrorDate DATETIME
	
    )
AS
    INSERT  INTO PE_DownloadError
            ( ErrorID ,
              InfoID ,
              ErrorUrl ,
              ErrorTimes ,
              ErrorDate
            )
    VALUES  ( @ErrorID ,
              @InfoID ,
              @ErrorUrl ,
              @ErrorTimes ,
              @ErrorDate
            )  
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Choiceset_SetFieldValue]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Choiceset_SetFieldValue]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Choiceset_SetFieldValue]
    (
      @FieldValue NTEXT ,
      @TableName NVARCHAR(30) ,
      @FieldName NVARCHAR(30)
    )
AS
    UPDATE  PE_Dictionary
    SET     FieldValue = @FieldValue
    WHERE   TableName = @TableName
            AND FieldName = @FieldName
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Choiceset_GetList]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Choiceset_GetList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Choiceset_GetList]
AS 
    SET NOCOUNT ON
    SELECT  FieldID ,
            Title ,
            TableName ,
            FieldName ,
            FieldValue
    FROM    PE_Dictionary
    ORDER BY TableName ,
            FieldID ASC 
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Accessories_Choiceset_GetChoicesetFieldValueByName]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Accessories_Choiceset_GetChoicesetFieldValueByName]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Accessories_Choiceset_GetChoicesetFieldValueByName]
    (
      @TableName NVARCHAR(30) ,
      @FieldName NVARCHAR(30)
    )
AS 
    SET NOCOUNT ON 
    SELECT  *
    FROM    PE_Dictionary
    WHERE   TableName = @TableName
            AND FieldName = @FieldName
    ORDER BY FieldID ASC
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Producer_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Producer_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Producer_Add]
    (
      @ProducerID INT ,
      @ProducerName NVARCHAR(200) ,
      @ProducerShortName NVARCHAR(50) ,
      @Birthday DATETIME ,
      @Address NVARCHAR(255) ,
      @Phone NVARCHAR(50) ,
      @Fax NVARCHAR(50) ,
      @Postcode NVARCHAR(10) ,
      @Homepage NVARCHAR(50) ,
      @Email NVARCHAR(50) ,
      @ProducerIntro NTEXT ,
      @ProducerPhoto NVARCHAR(255) ,
      @ProducerType INT
	
    )
AS 
    INSERT  INTO PE_Producer
            ( ProducerID ,
              ProducerName ,
              ProducerShortName ,
              BirthDay ,
              Address ,
              Phone ,
              Fax ,
              Postcode ,
              Homepage ,
              Email ,
              ProducerIntro ,
              ProducerPhoto ,
              ProducerType ,
              Passed ,
              LastUseTime
            )
    VALUES  ( @ProducerID ,
              @ProducerName ,
              @ProducerShortName ,
              @Birthday ,
              @Address ,
              @Phone ,
              @Fax ,
              @Postcode ,
              @Homepage ,
              @Email ,
              @ProducerIntro ,
              @ProducerPhoto ,
              @ProducerType ,
              1 ,
              GETDATE()
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PresentProject_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PresentProject_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_PresentProject_Update]
    (
      @ProjectId INT ,
      @ProjectName NVARCHAR(50) ,
      @BeginDate DATETIME ,
      @EndDate DATETIME ,
      @MinMoney MONEY ,
      @MaxMoney MONEY ,
      @PresentContent NVARCHAR(50) ,
      @Price MONEY ,
      @PresentID NTEXT ,
      @Cash INT ,
      @PresentExp INT ,
      @PresentPoint INT ,
      @Disabled BIT
	
    )
AS 
    SET IDENTITY_INSERT PE_PresentProject ON
    UPDATE  PE_PresentProject
    SET     ProjectName = @ProjectName ,
            BeginDate = @BeginDate ,
            EndDate = @EndDate ,
            MinMoney = @MinMoney ,
            MaxMoney = @MaxMoney ,
            PresentContent = @PresentContent ,
            Price = @Price ,
            PresentID = @PresentID ,
            Cash = @Cash ,
            PresentExp = @PresentExp ,
            PresentPoint = @PresentPoint
    WHERE   ProjectId = @ProjectId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PresentProject_Locked]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PresentProject_Locked]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_PresentProject_Locked]
    (
      @ProjectId INT ,
      @Disabled BIT
	
    )
AS 
    UPDATE  PE_PresentProject
    SET     [Disabled] = @Disabled
    WHERE   [ProjectID] = @ProjectId
		
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PresentProject_List]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PresentProject_List]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_PresentProject_List] ( @id INT = 0 )
AS 
    IF ( @id = 0 ) 
        BEGIN
            SELECT  [ProjectID] ,
                    [ProjectName] ,
                    [BeginDate] ,
                    [EndDate] ,
                    [MinMoney] ,
                    [MaxMoney] ,
                    [PresentContent] ,
                    [Price] ,
                    [PresentID] ,
                    [Cash] ,
                    [PresentExp] ,
                    [PresentPoint] ,
                    [Disabled]
            FROM    PE_PresentProject
            ORDER BY ProjectID ASC
        END
    ELSE 
        BEGIN
            SELECT  [ProjectID] ,
                    [ProjectName] ,
                    [BeginDate] ,
                    [EndDate] ,
                    [MinMoney] ,
                    [MaxMoney] ,
                    [PresentContent] ,
                    [Price] ,
                    [PresentID] ,
                    [Cash] ,
                    [PresentExp] ,
                    [PresentPoint] ,
                    [Disabled]
            FROM    PE_PresentProject
            WHERE   ProjectID = @id
        END 
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PresentProject_Delete]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PresentProject_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_PresentProject_Delete] ( @ProjectId INT )
AS 
    DELETE  PE_PresentProject
    WHERE   [ProjectID] = @ProjectId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PresentProject_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PresentProject_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_PresentProject_Add]
    (
      @ProjectName NVARCHAR(50) ,
      @BeginDate DATETIME ,
      @EndDate DATETIME ,
      @MinMoney MONEY ,
      @MaxMoney MONEY ,
      @PresentContent NVARCHAR(50) ,
      @Price MONEY ,
      @PresentID NTEXT ,
      @Cash INT ,
      @PresentExp INT ,
      @PresentPoint INT ,
      @Disabled BIT
	
    )
AS
    INSERT  INTO PE_PresentProject
            ( [ProjectName] ,
              [BeginDate] ,
              [EndDate] ,
              [MinMoney] ,
              [MaxMoney] ,
              [PresentContent] ,
              [Price] ,
              [PresentID] ,
              [Cash] ,
              [PresentExp] ,
              [PresentPoint] ,
              [Disabled]
            )
    VALUES  ( @ProjectName ,
              @BeginDate ,
              @EndDate ,
              @MinMoney ,
              @MaxMoney ,
              @PresentContent ,
              @Price ,
              @PresentID ,
              @Cash ,
              @PresentExp ,
              @PresentPoint ,
              @Disabled
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PaymentType_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PaymentType_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_PaymentType_Update]
    @typeId INT ,
    @typeName NVARCHAR(50) ,
    @intro NVARCHAR(50) = NULL ,
    @discount FLOAT = 100.0 ,
    @orderId INT = 0 ,
    @category INT = 0 ,
    @isDefault BIT ,
    @isDisabled BIT
AS
    IF ( @isDefault = 1 ) 
        BEGIN
            UPDATE  PE_PaymentType
            SET     IsDefault = 0
            WHERE   IsDefault = 1
        END
    IF @orderId <> 0 
        BEGIN
            DECLARE @oldOrderId INT
            DECLARE @max INT
            DECLARE @min INT
            DECLARE @count INT
            DECLARE @icount INT
            DECLARE @offset1 INT
            DECLARE @offset2 INT

            SET @icount = 1
            DECLARE @tmp TABLE
                (
                  Row INT IDENTITY(1, 1)
                          PRIMARY KEY ,
                  id INT ,
                  oid INT
                )
            SELECT  @oldOrderId = OrderId
            FROM    PE_PaymentType
            WHERE   TypeID = @typeId
            IF ( @orderId <> @oldOrderId ) 
                BEGIN
                    IF ( @orderId > @oldOrderId ) 
                        BEGIN
                            SET @max = @orderId
                            SET @min = @oldOrderId
                            SET @offset1 = 0
                            SET @offset2 = 1
                        END
                    ELSE 
                        BEGIN
                            SET @max = @oldOrderId
                            SET @min = @orderId
                            SET @offset1 = 1
                            SET @offset2 = 0
                        END
                    INSERT  INTO @tmp
                            ( id ,
                              oid
                            )
                            SELECT  TypeId ,
                                    OrderId
                            FROM    PE_PaymentType
                            WHERE   OrderId BETWEEN @min AND @max
                            ORDER BY orderId
                    SELECT  @count = COUNT(*)
                    FROM    @tmp

                    WHILE ( @icount < @count ) 
                        BEGIN
                            UPDATE  PE_PaymentType
                            SET     OrderId = ( SELECT  oid
                                                FROM    @tmp
                                                WHERE   Row = @icount
                                                        + @offset1
                                              )
                            WHERE   TypeId = ( SELECT   Id
                                               FROM     @tmp
                                               WHERE    Row = @icount
                                                        + @offset2
                                             )
                            SET @icount = @icount + 1
                        END 
                END
            UPDATE  PE_PaymentType
            SET     TypeName = @typeName ,
                    Intro = @intro ,
                    Discount = @discount ,
                    OrderId = @orderId ,
                    IsDefault = @isDefault ,
                    IsDisabled = @isDisabled ,
                    Category = @category
            WHERE   TypeId = @typeId
        END
    ELSE 
        BEGIN
		--不排序的更新
            UPDATE  PE_PaymentType
            SET     TypeName = @typeName ,
                    Intro = @intro ,
                    Discount = @discount ,
                    IsDefault = @isDefault ,
                    IsDisabled = @isDisabled ,
                    Category = @category
            WHERE   TypeId = @typeId
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PaymentType_GetList]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PaymentType_GetList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_PaymentType_GetList]
AS 
    SELECT  *
    FROM    PE_PaymentType
    ORDER BY orderId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PaymentType_GetById]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PaymentType_GetById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_PaymentType_GetById] ( @id INT = 0 )
AS
    SELECT  *
    FROM    PE_PaymentType
    WHERE   TypeId = @id' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PaymentType_Delete]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PaymentType_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_PaymentType_Delete] ( @typeId INT )
AS 
    DECLARE @Oid INT
    SELECT  @Oid = OrderId
    FROM    PE_PaymentType
    WHERE   [TypeId] = @typeId
	
    DELETE  PE_PaymentType
    WHERE   TypeId = @typeId

    UPDATE  PE_PaymentType
    SET     OrderId = OrderId - 1
    WHERE   OrderId > @Oid' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PaymentType_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PaymentType_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_PaymentType_Add]
    (
      @typeName NVARCHAR(50) ,
      @intro NVARCHAR(50) = NULL ,
      @discount FLOAT = 100.0 ,
      @isDefault BIT ,
      @isDisabled BIT ,
      @category INT = 0
	
    )
AS 
    DECLARE @typeId INT
    DECLARE @orderId INT
	
    SELECT  @typeId = ISNULL(MAX(TypeId), 0) + 1 ,
            @orderId = ISNULL(MAX(OrderId), 0) + 1
    FROM    PE_PaymentType
	
    IF ( @typeID = 1 ) 
        BEGIN
            SET @isDefault = 1
        END
    ELSE 
        BEGIN
            IF ( @isDefault = 1 ) 
                BEGIN
                    UPDATE  PE_PaymentType
                    SET     IsDefault = 0
                    WHERE   IsDefault = 1
                END
        END
	
    INSERT  INTO PE_PaymentType
            ( TypeId ,
              TypeName ,
              Intro ,
              Discount ,
              OrderId ,
              IsDefault ,
              IsDisabled ,
              Category
            )
    VALUES  ( @typeId ,
              @typeName ,
              @intro ,
              @discount ,
              @orderId ,
              @isDefault ,
              @isDisabled ,
              @category
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_PaymentLog_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_PaymentLog_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_PaymentLog_Add]
    (
      @PaymentLogID INT ,
      @UserName NVARCHAR(100) ,
      @OrderID INT ,
      @PaymentNum NVARCHAR(50) ,
      @PlatformID INT ,
      @MoneyPay MONEY ,
      @MoneyTrue MONEY ,
      @PayTime DATETIME ,
      @SuccessTime DATETIME ,
      @Status INT ,
      @PlatformInfo NVARCHAR(200) ,
      @Remark NVARCHAR(255) ,
      @Point INT ,
      @TradeNum NVARCHAR(50)
    )
AS 
    INSERT  INTO [PE_PaymentLog]
            ( [PaymentLogID] ,
              [UserName] ,
              [OrderID] ,
              [PaymentNum] ,
              [PlatformID] ,
              [MoneyPay] ,
              [MoneyTrue] ,
              [PayTime] ,
              [SuccessTime] ,
              [Status] ,
              [PlatformInfo] ,
              [Remark] ,
              [Point] ,
              [TradeNum]
		)
    VALUES  ( @PaymentLogID ,
              @UserName ,
              @OrderID ,
              @PaymentNum ,
              @PlatformID ,
              @MoneyPay ,
              @MoneyTrue ,
              @PayTime ,
              @SuccessTime ,
              @Status ,
              @PlatformInfo ,
              @Remark ,
              @Point ,
              @TradeNum
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_OrderItem_UpdateByProductId]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_OrderItem_UpdateByProductId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_OrderItem_UpdateByProductId]
    (
      @ProductId INT ,
      @ProductName NVARCHAR(255)
    )
AS 
    UPDATE  PE_ORDERITEM
    SET     productname = @productname
    WHERE   productid = @productid' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_OrderItem_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_OrderItem_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_OrderItem_Update]
    (
      @ItemID INT ,    --ID
      @OrderID INT ,    --订单ID
      @ProductID INT ,    --产品ID
      @TableName NVARCHAR(255) ,
      @Property NVARCHAR(255) ,
      @SaleType INT ,    --销售类型  1--正常销售  2--换购  3--赠送  4--批发
      @Price_Market MONEY ,    --原价
      @Price MONEY ,    --系统计算出的销售价
      @TruePrice MONEY ,    --实际销售价
      @Amount INT ,    --订购数量
      @SubTotal MONEY ,    --订购金额
      @BeginDate DATETIME ,    --开始计算服务期限日期
      @ServiceTerm INT ,    --服务期限
      @ServiceTermUnit INT ,    --服务年限单位　0－年，1－月，2－日
      @Remark NVARCHAR(255) ,    --备注
      @PresentMoney MONEY ,    --返还的现金券
      @PresentPoint INT ,    --赠送点券
      @PresentExp INT ,   --赠送的积分
      @ProductCharacter INT ,
      @ProductName NVARCHAR(255) ,
      @Unit NVARCHAR(20) ,
      @Weight FLOAT ,
      @TrueAmount INT ,
      @TrueSubTotal MONEY,
      @GroupBuyID INT,
	  @SecondsKillID INT
    )
AS 
    UPDATE  [PE_OrderItem]
    SET     [ItemID] = @ItemID ,    --ID
            [OrderID] = @OrderID ,    --订单ID
            [ProductID] = @ProductID ,    --产品ID
            [TableName] = @TableName ,
            [Property] = @Property ,
            [SaleType] = @SaleType ,    --销售类型  1--正常销售  2--换购  3--赠送  4--批发
            [Price_Market] = @Price_Market ,    --原价
            [Price] = @Price ,    --系统计算出的销售价
            [TruePrice] = @TruePrice ,    --实际销售价
            [Amount] = @Amount ,    --订购数量
            [SubTotal] = @SubTotal ,    --订购金额
            [BeginDate] = @BeginDate ,    --开始计算服务期限日期
            [ServiceTerm] = @ServiceTerm ,    --服务期限
            [ServiceTermUnit] = @ServiceTermUnit ,    --服务年限单位　0－年，1－月，2－日
            [Remark] = @Remark ,    --备注
            [PresentMoney] = @PresentMoney ,    --返还的现金券
            [PresentPoint] = @PresentPoint ,    --赠送点券
            [PresentExp] = @PresentExp ,    --赠送的积分
            [ProductCharacter] = @ProductCharacter ,
            [ProductName] = @ProductName ,
            [Unit] = @Unit ,
            [Weight] = @Weight ,
            [TrueAmount] = @TrueAmount ,
            [TrueSubTotal] = @TrueSubTotal,
            [GroupBuyID]=@GroupBuyID,
			[SecondsKillID]=@SecondsKillID
    WHERE   [ItemID] = @ItemID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_OrderItem_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_OrderItem_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_OrderItem_Add]
    (
      @ItemID INT ,
      @OrderID INT ,
      @ProductID INT ,
      @TableName NVARCHAR(255) ,
      @Property NVARCHAR(255) ,
      @SaleType INT ,
      @Price_Market MONEY ,
      @Price MONEY ,
      @TruePrice MONEY ,
      @Amount INT ,
      @SubTotal MONEY ,
      @BeginDate DATETIME ,
      @ServiceTerm INT ,
      @ServiceTermUnit INT ,
      @Remark NVARCHAR(255) ,
      @PresentMoney MONEY ,
      @PresentPoint INT ,
      @PresentExp INT ,
      @ProductCharacter INT ,
      @ProductName NVARCHAR(255) ,
      @Unit NVARCHAR(20) ,
      @Weight FLOAT ,
      @TrueAmount INT ,
      @TrueSubTotal MONEY,
	  @GroupBuyID INT,
	  @SecondsKillID INT
    )
AS 
    INSERT  INTO PE_OrderItem
            ( [ItemID] ,
              [OrderID] ,
              [ProductID] ,
              [TableName] ,
              [Property] ,
              [SaleType] ,
              [Price_Market] ,
              [Price] ,
              [TruePrice] ,
              [Amount] ,
              [SubTotal] ,
              [BeginDate] ,
              [ServiceTerm] ,
              [ServiceTermUnit] ,
              [Remark] ,
              [PresentMoney] ,
              [PresentPoint] ,
              [PresentExp] ,
              [ProductCharacter] ,
              [ProductName] ,
              [Unit] ,
              [Weight] ,
              [TrueAmount] ,
              [TrueSubTotal],
              [GroupBuyID],
			  [SecondsKillID]
            )
    VALUES  ( @ItemID ,
              @OrderID ,
              @ProductID ,
              @TableName ,
              @Property ,
              @SaleType ,
              @Price_Market ,
              @Price ,
              @TruePrice ,
              @Amount ,
              @SubTotal ,
              @BeginDate ,
              @ServiceTerm ,
              @ServiceTermUnit ,
              @Remark ,
              @PresentMoney ,
              @PresentPoint ,
              @PresentExp ,
              @ProductCharacter ,
              @ProductName ,
              @Unit ,
              @Weight ,
              @TrueAmount ,
              @TrueSubTotal,
              @GroupBuyID,
			  @SecondsKillID
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_OrderHistoryItem_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_OrderHistoryItem_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_OrderHistoryItem_Add]
    (
      @OrderHistoryID INT ,
      @ItemID INT ,
      @FieldName NVARCHAR(50) ,
      @OldValue NVARCHAR(500) ,
      @NewValue NVARCHAR(500)
    )
AS 
    INSERT  INTO pe_OrderHistoryItem
            ( OrderHistoryID ,
              ItemID ,
              FieldName ,
              OldValue ,
              NewValue
            )
    VALUES  ( @OrderHistoryID ,
              @ItemID ,
              @FieldName ,
              @OldValue ,
              @NewValue
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_OrderHistory_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_OrderHistory_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_OrderHistory_Add]
    (
      @OrderHistoryID INT ,
      @Ordernum NVARCHAR(20) ,
      @Actionname NVARCHAR(50) ,
      @ActionTime DATETIME ,
      @UserIp NVARCHAR(50) ,
      @UserName NVARCHAR(100) ,
      @Remark NVARCHAR(200)
    )
AS 
    INSERT  INTO pe_OrderHistory
            ( OrderHistoryID ,
              Ordernum ,
              Actionname ,
              ActionTime ,
              UserIp ,
              UserName ,
              Remark 
            )
    VALUES  ( @OrderHistoryID ,
              @Ordernum ,
              @Actionname ,
              @ActionTime ,
              @UserIp ,
              @UserName ,
              @Remark 
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Order_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Order_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Order_Update]
    (
      @OrderID INT ,
      @UserName NVARCHAR(100) ,
      @AgentName NVARCHAR(50) ,
      @Functionary NVARCHAR(50) ,
      @MoneyTotal MONEY ,
      @MoneyGoods MONEY ,
      @NeedInvoice BIT ,
      @InvoiceContent NTEXT ,
      @BeginDate DATETIME ,
      @Address NVARCHAR(255) ,
      @ZipCode NVARCHAR(10) ,
      @Mobile NVARCHAR(50) ,
      @Phone NVARCHAR(50) ,
      @Email NVARCHAR(50) ,
      @PaymentType INT ,
      @DeliverType INT ,
      @Status INT ,
      @Discount_Payment FLOAT ,
      @MoneyReceipt MONEY ,
      @EnableDownload BIT ,
      @DeliverStatus INT ,
      @Charge_Deliver MONEY ,
      @Memo NTEXT ,
      @PresentMoney MONEY ,
      @PresentPoint INT ,
      @PresentExp INT ,
      @OrderType INT ,
      @CouponID INT ,
      @InputTime DATETIME ,
      @ContacterName NVARCHAR(50) ,
      @OrderKind INT,
	  @GroupBuyID INT,
      @IsNotice BIT,
	  @SecondsKillID INT
    )
AS 
    UPDATE  [PE_Orders]
    SET     [UserName] = @UserName ,
            [AgentName] = @AgentName ,
            [Functionary] = @Functionary ,
            [MoneyTotal] = @MoneyTotal ,
            [MoneyGoods] = @MoneyGoods ,
            [NeedInvoice] = @NeedInvoice ,
            [InvoiceContent] = @InvoiceContent ,
            [BeginDate] = @BeginDate ,
            [Address] = @Address ,
            [ZipCode] = @ZipCode ,
            [Mobile] = @Mobile ,
            [Phone] = @Phone ,
            [Email] = @Email ,
            [PaymentType] = @PaymentType ,
            [DeliverType] = @DeliverType ,
            [Status] = @Status ,
            [Discount_Payment] = @Discount_Payment ,
            [Charge_Deliver] = @Charge_Deliver ,
            [MoneyReceipt] = @MoneyReceipt ,
            [EnableDownload] = @EnableDownload ,
            [DeliverStatus] = @DeliverStatus ,
            [Memo] = @Memo ,
            [PresentMoney] = @PresentMoney ,
            [PresentPoint] = @PresentPoint ,
            [PresentExp] = @PresentExp ,
            [OrderType] = @OrderType ,
            [CouponID] = @CouponID ,
            [InputTime] = @InputTime ,
            [ContacterName] = @ContacterName ,
            [OrderKind] = @OrderKind,
            [GroupBuyID]=@GroupBuyID,
            [IsNotice]=@IsNotice,
			[SecondsKillID]=@SecondsKillID
    WHERE   OrderID = @OrderID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Order_GetByOrderId]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Order_GetByOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Order_GetByOrderId] ( @OrderId INT )
AS 
    BEGIN
        SELECT  O.* ,
                C.ClientName
        FROM    PE_Orders O
                LEFT JOIN PE_Client C ON O.ClientID = C.ClientID
        WHERE   OrderID = @OrderId 

    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Order_Delete]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Order_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Order_Delete]
    (
      @OrderId NVARCHAR(4000) ,
      @ErrOrderNum NVARCHAR(4000) OUTPUT 
    )
AS 
    BEGIN

        DECLARE @UserName NVARCHAR(100) ,
            @ClientID INT ,
            @MoneyReceipt MONEY ,
            @Status INT ,
            @ID INT ,
            @OrderNum NVARCHAR(20)
        DECLARE cur1 CURSOR FOR SELECT UserName,ClientID,MoneyReceipt,Status,OrderID,OrderNum FROM PE_Orders WHERE CHARINDEX('','' + RTRIM(OrderID) + '','', '','' + CAST ((@OrderId) AS NVARCHAR(100)) + '','') > 0
        OPEN cur1
        FETCH NEXT FROM cur1 INTO @UserName, @ClientID, @MoneyReceipt, @Status, @ID, @OrderNum

        WHILE @@FETCH_STATUS = 0 
            BEGIN
                BEGIN
                    IF @MoneyReceipt > 0
                        OR @Status = 2 
                        BEGIN
                            IF @ErrOrderNum IS NULL 
                                SET @ErrOrderNum = @OrderNum
						--SET @ErrOrderNum = ''dfasdsd''
                            ELSE
						--SET @ErrOrderNum = @ErrOrderNum + ''dfasdsd''
                                SET @ErrOrderNum = @ErrOrderNum + '',''
                                    + @OrderNum
					--ErrMsg = ErrMsg & "<li>订单：" & rsOrder("OrderFormNum") & "已经付款，不能再删除！</li>"
                        END
                    ELSE 
                        BEGIN
                            DECLARE @ProductID INT ,
                                @TableName NVARCHAR(255) ,
                                @Property NVARCHAR(255) ,
                                @Amount INT
                            DECLARE cur2 CURSOR FOR SELECT ProductID,TableName,[Property],Amount FROM PE_OrderItem WHERE OrderID = @ID
                            OPEN cur2
                            FETCH NEXT FROM cur2 INTO @ProductID,@TableName,@Property,@Amount
                            WHILE @@FETCH_STATUS = 0 
                                BEGIN
                                    UPDATE  PE_CommonProduct
                                    SET     OrderNum = OrderNum - @Amount
                                    WHERE   ProductID = @ProductID
                                            AND TableName = @TableName
                                    BEGIN
                                        IF @Property IS NOT NULL 
                                            UPDATE  PE_ProductData
                                            SET     OrderNum = OrderNum
                                                    - @Amount
                                            WHERE   ProductID = @ProductID
                                                    AND TableName = @TableName
                                                    AND PropertyValue = @Property
                                    END
                                    FETCH NEXT FROM cur2 INTO @ProductID,@TableName,@Property,@Amount
                                END
						
                            CLOSE cur2
                            DEALLOCATE cur2

                            DELETE  FROM PE_BankrollItem
                            WHERE   OrderID = @ID
                            DELETE  FROM PE_DeliverItem
                            WHERE   OrderID = @ID
                            DELETE  FROM PE_OrderItem
                            WHERE   OrderID = @ID
					--不能删除在线支付记录，因为有时会员对订单进行在线支付但不是即时成功，此时删除了这个订单，就会造成找不到实际应该成功的在线支付记录
					--DELETE FROM PE_Payment WHERE OrderID = @ID
                            DELETE  FROM PE_TransferLog
                            WHERE   OrderID = @ID
                            DELETE  FROM PE_Orders
                            WHERE   OrderID = @ID
                            DELETE  FROM PE_U_OrderText
                            WHERE   ID = @ID 
                        END
                END
                FETCH NEXT FROM cur1 INTO @UserName, @ClientID, @MoneyReceipt, @Status, @ID, @OrderNum
            END
        CLOSE cur1
        DEALLOCATE cur1

        SELECT  @ErrOrderNum AS N''@ErrOrderNum''
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Order_Confirm]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Order_Confirm]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Order_Confirm] 
    @OrderId INT
AS 
    DECLARE @foundStatus INT ,
        @getMoneyReceipt MONEY
    SELECT  @foundStatus = Status ,
            @getMoneyReceipt = MoneyReceipt
    FROM    PE_Orders
    WHERE   OrderID = @OrderId

    IF @foundStatus IS NOT NULL 
        IF ( @foundStatus > 1 ) 
            RETURN 1
        ELSE 
            BEGIN
                UPDATE  PE_Orders
                SET     Status = 1
                WHERE   OrderID = @OrderId
                RETURN 2
            END
    ELSE 
        RETURN 0' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Order_AgentPayment]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Order_AgentPayment]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Order_AgentPayment]
    (
      @OrderID INT ,
      @Money MONEY ,
      @RefundType INT
    )
AS 
    DECLARE @AgentBalance MONEY ,
        @AgentClientID INT ,
        @UserName NVARCHAR(4000)
    SELECT  AgentName ,
            MoneyReceipt ,
            MoneyTotal
    FROM    PE_Orders
    WHERE   OrderID = @OrderID
            AND MoneyReceipt < MoneyTotal' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Order_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Order_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Order_Add]
    (
      @OrderID INT ,
      @OrderNum NVARCHAR(20) ,
      @UserName NVARCHAR(100) ,
      @AgentName NVARCHAR(50) ,
      @Functionary NVARCHAR(50) ,
      @ClientID INT ,
      @MoneyTotal MONEY ,
      @MoneyGoods MONEY ,
      @NeedInvoice BIT ,
      @InvoiceContent NTEXT ,
      @Invoiced BIT ,
      @MoneyReceipt MONEY ,
      @BeginDate DATETIME ,
      @InputTime DATETIME ,
      @ContacterName NVARCHAR(50) ,
      @Address NVARCHAR(255) ,
      @ZipCode NVARCHAR(10) ,
      @Mobile NVARCHAR(50) ,
      @Phone NVARCHAR(50) ,
      @Email NVARCHAR(50) ,
      @PaymentType INT ,
      @DeliverType INT ,
      @Status INT ,
      @DeliverStatus INT ,
      @EnableDownload BIT ,
      @PresentMoney MONEY ,
      @PresentPoint INT ,
      @PresentExp INT ,
      @Discount_Payment FLOAT ,
      @Charge_Deliver MONEY ,
      @Memo NTEXT ,
      @OrderType INT ,
      @CouponID INT ,
      @OrderKind INT,
      @GroupBuyID INT,
      @IsNotice BIT,
	  @SecondsKillID INT
    )
AS 
    INSERT  INTO [PE_Orders]
            ( [OrderID] ,
              [OrderNum] ,
              [UserName] ,
              [AgentName] ,
              [Functionary] ,
              [ClientID] ,
              [MoneyTotal] ,
              [MoneyGoods] ,
              [NeedInvoice] ,
              [InvoiceContent] ,
              [Invoiced] ,
              [MoneyReceipt] ,
              [BeginDate] ,
              [InputTime] ,
              [ContacterName] ,
              [Address] ,
              [ZipCode] ,
              [Mobile] ,
              [Phone] ,
              [Email] ,
              [PaymentType] ,
              [DeliverType] ,
              [Status] ,
              [DeliverStatus] ,
              [EnableDownload] ,
              [PresentMoney] ,
              [PresentPoint] ,
              [PresentExp] ,
              [Discount_Payment] ,
              [Charge_Deliver] ,
              [Memo] ,
              [OrderType] ,
              [CouponID] ,
              [OrderKind],
              [GroupBuyID],
              [IsNotice],
			  [SecondsKillID]
		)
    VALUES  ( @OrderID ,
              @OrderNum ,
              @UserName ,
              @AgentName ,
              @Functionary ,
              @ClientID ,
              @MoneyTotal ,
              @MoneyGoods ,
              @NeedInvoice ,
              @InvoiceContent ,
              @Invoiced ,
              @MoneyReceipt ,
              @BeginDate ,
              @InputTime ,
              @ContacterName ,
              @Address ,
              @ZipCode ,
              @Mobile ,
              @Phone ,
              @Email ,
              @PaymentType ,
              @DeliverType ,
              @Status ,
              @DeliverStatus ,
              @EnableDownload ,
              @PresentMoney ,
              @PresentPoint ,
              @PresentExp ,
              @Discount_Payment ,
              @Charge_Deliver ,
              @Memo ,
              @OrderType ,
              @CouponID ,
              @OrderKind,
              @GroupBuyID,
              @IsNotice,
			  @SecondsKillID
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Invoice_GetByOrderId]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Invoice_GetByOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Invoice_GetByOrderId] ( @OrderId INT )
AS 
    SELECT  O.* ,
            C.ShortedForm AS ClientName
    FROM    PE_Orders O
            LEFT JOIN PE_Client C ON O.ClientID = C.ClientID
    WHERE   OrderID = @OrderId
            AND NeedInvoice = 1' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Invoice_GetById]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Invoice_GetById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Invoice_GetById] ( @InvoiceId INT )
AS 
    SELECT  I.* ,
            O.OrderNum ,
            O.MoneyTotal ,
            O.MoneyReceipt ,
            C.ShortedForm AS ClientName
    FROM    PE_InvoiceItem I
            LEFT JOIN ( PE_Orders O
                        LEFT JOIN PE_Client C ON O.ClientID = C.ClientID
                      ) ON I.OrderID = O.OrderID
    WHERE   InvoiceID = @InvoiceID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Invoice_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Invoice_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Invoice_Add]
    (
      @ClientId INT ,
      @UserName NVARCHAR(100) ,
      @OrderId INT ,
      @InvoiceType INT ,
      @InvoiceDate DATETIME ,
      @InvoiceNum NVARCHAR(50) ,
      @InvoiceTitle NVARCHAR(50) ,
      @InvoiceContent NTEXT ,
      @Memo NTEXT ,
      @TotalMoney MONEY ,
      @Drawer NVARCHAR(50) ,
      @Inputer NVARCHAR(50)
    )
AS 
    INSERT  INTO PE_InvoiceItem
            ( ClientID ,
              UserName ,
              OrderID ,
              InvoiceType ,
              InvoiceDate ,
              InvoiceNum ,
              InvoiceTitle ,
              InvoiceContent ,
              Memo ,
              TotalMoney ,
              Drawer ,
              Inputer ,
              InputTime
            )
    VALUES  ( @ClientId ,
              @UserName ,
              @OrderId ,
              @InvoiceType ,
              @InvoiceDate ,
              @InvoiceNum ,
              @InvoiceTitle ,
              @InvoiceContent ,
              @Memo ,
              @TotalMoney ,
              @Drawer ,
              @Inputer ,
              GETDATE()
            )
    
    UPDATE  PE_Orders
    SET     Invoiced = 1
    WHERE   OrderID = @OrderId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_IndentItem_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_IndentItem_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_IndentItem_Add]
    @ItemID INT ,
    @IndentID INT ,
    @ProductID INT ,
    @Property NVARCHAR(510) ,
    @Price MONEY ,
    @Amount INT ,
    @TableName NVARCHAR(510)
AS 
    INSERT  INTO PE_IndentItem
            ( ItemID ,
              IndentID ,
              ProductID ,
              [Property] ,
              Price ,
              Amount ,
              [TableName]
            )
    VALUES  ( @ItemID ,
              @IndentID ,
              @ProductID ,
              @Property ,
              @Price ,
              @Amount ,
              @TableName
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Indent_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Indent_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Indent_Update]
    @IndentID INT ,
    @IndentNum NVARCHAR(40) ,
    @InputTime DATETIME ,
    @Inputer NVARCHAR(100) ,
    @Status INT ,
    @Remark NVARCHAR(510)
AS 
    UPDATE  PE_Indent
    SET     IndentNum = @IndentNum ,
            InputTime = @InputTime ,
            Inputer = @Inputer ,
            Status = @Status ,
            Remark = @Remark
    WHERE   IndentID = @IndentID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Indent_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Indent_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Indent_Add]
    @IndentID INT ,
    @IndentNum NVARCHAR(40) ,
    @InputTime DATETIME ,
    @Inputer NVARCHAR(100) ,
    @Status INT ,
    @Remark NVARCHAR(510)
AS 
    INSERT  INTO PE_Indent
            ( IndentID ,
              IndentNum ,
              InputTime ,
              Inputer ,
              Status ,
              Remark
            )
    VALUES  ( @IndentID ,
              @IndentNum ,
              @InputTime ,
              @Inputer ,
              @Status ,
              @Remark
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverType_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverType_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverType_Update]
    (
      @typeId INT ,
      @typeName NVARCHAR(50) ,
      @intro NVARCHAR(50) ,
      @chargeType INT ,
      @isDefault BIT ,
      @isDisabled BIT ,
      @orderId INT ,
      @releaseType INT = 0 ,
      @minMoney1 MONEY = 0 ,
      @releaseCharge MONEY = 0 ,
      @minmoney2 MONEY = 0 ,
      @maxCharge MONEY = 0 ,
      @minMoney3 MONEY = 0 ,
      @charge_Min MONEY = 0 ,
      @charge_Max MONEY = 0 ,
      @includeTax INT = 0 ,
      @taxRate FLOAT = 0 ,
      @charge_Percent SMALLINT = 0
	
    )
AS --处理 默认值
    IF ( @isDefault = 1 ) 
        BEGIN
            UPDATE  [PE_DeliverType]
            SET     IsDefault = 0
            WHERE   IsDefault = 1
        END
	
	--处理 排序
    DECLARE @oldOrderId INT
    DECLARE @max INT
    DECLARE @min INT
    DECLARE @count INT
    DECLARE @icount INT
    DECLARE @offset1 INT
    DECLARE @offset2 INT

    SET @icount = 1
    DECLARE @tmp TABLE
        (
          Row INT IDENTITY(1, 1)
                  PRIMARY KEY ,
          id INT ,
          oid INT
        )
    SELECT  @oldOrderId = OrderId
    FROM    [PE_DeliverType]
    WHERE   TypeID = @typeId
    IF ( @orderId <> @oldOrderId ) 
        BEGIN
            IF ( @orderId > @oldOrderId ) 
                BEGIN
                    SET @max = @orderId
                    SET @min = @oldOrderId
                    SET @offset1 = 0
                    SET @offset2 = 1
                END
            ELSE 
                BEGIN
                    SET @max = @oldOrderId
                    SET @min = @orderId
                    SET @offset1 = 1
                    SET @offset2 = 0
                END
            INSERT  INTO @tmp
                    ( id ,
                      oid
                    )
                    SELECT  TypeId ,
                            OrderId
                    FROM    [PE_DeliverType]
                    WHERE   OrderId BETWEEN @min AND @max
                    ORDER BY orderId
            SELECT  @count = COUNT(*)
            FROM    @tmp

            WHILE ( @icount < @count ) 
                BEGIN
                    UPDATE  [PE_DeliverType]
                    SET     OrderId = ( SELECT  oid
                                        FROM    @tmp
                                        WHERE   Row = @icount + @offset1
                                      )
                    WHERE   TypeId = ( SELECT   Id
                                       FROM     @tmp
                                       WHERE    Row = @icount + @offset2
                                     )
                    SET @icount = @icount + 1
                END 
        END
	
    UPDATE  [PE_DeliverType]
    SET     [TypeName] = @typeName ,
            [Intro] = @intro ,
            [ChargeType] = @chargeType ,
            [IsDefault] = @isDefault ,
            [IsDisabled] = @isDisabled ,
            [OrderId] = @orderId ,
            [ReleaseType] = @releaseType ,
            [MinMoney1] = @minMoney1 ,
            [ReleaseCharge] = @releaseCharge ,
            [Minmoney2] = @minmoney2 ,
            [MaxCharge] = @maxCharge ,
            [MinMoney3] = @minMoney3 ,
            [Charge_Min] = @charge_Min ,
            [Charge_Max] = @charge_Max ,
            [IncludeTax] = @includeTax ,
            [TaxRate] = @taxRate ,
            [Charge_Percent] = @charge_Percent
    WHERE   TypeId = @typeId
    IF NOT ( @@error > 0 ) 
        BEGIN
            RETURN 1
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverType_GetMaxId]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverType_GetMaxId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverType_GetMaxId]
AS 
    SELECT  ISNULL(MAX(TypeId), 0)
    FROM    PE_DeliverType' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverType_GetList]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverType_GetList]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverType_GetList]
AS 
    SELECT  *
    FROM    PE_DeliverType
    ORDER BY orderId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverType_GetById]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverType_GetById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverType_GetById] ( @typeId INT )
AS 
    SELECT  *
    FROM    [PE_DeliverType]
    WHERE   TypeId = @typeId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverType_Delete]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverType_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverType_Delete] ( @typeId INT )
AS 
    DECLARE @Oid INT
    SELECT  @Oid = OrderId
    FROM    PE_DeliverType
    WHERE   TypeId = @typeId

    DELETE  PE_DeliverType
    WHERE   TypeId = @typeId

    UPDATE  PE_DeliverType
    SET     OrderId = OrderId - 1
    WHERE   OrderId > @Oid
	
    DELETE  PE_DeliverCharge
    WHERE   DeliverTypeId = @typeId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverType_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverType_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverType_Add]
    (
      @typeId INT ,
      @typeName NVARCHAR(50) ,
      @intro NVARCHAR(50) ,
      @chargeType INT ,
      @isDefault BIT = 0 ,
      @isDisabled BIT = 0 ,
      @releaseType INT = 0 ,
      @minMoney1 MONEY = 0 ,
      @releaseCharge MONEY = 0 ,
      @minmoney2 MONEY = 0 ,
      @maxCharge MONEY = 0 ,
      @minMoney3 MONEY = 0 ,
      @charge_Min MONEY = 0 ,
      @charge_Max MONEY = 0 ,
      @includeTax INT = 0 ,
      @taxRate FLOAT = 0 ,
      @charge_Percent SMALLINT = 0
     
    )
AS 
    DECLARE @orderId INT
    SELECT  @orderId = ( ISNULL(MAX(OrderId), 0) + 1 )
    FROM    PE_DeliverType
	
    IF ( @typeId = 1 ) 
        BEGIN
			
            SET @isDefault = 1
        END
    ELSE 
        BEGIN
            IF ( @isDefault = 1 ) 
                BEGIN
                    UPDATE  PE_DeliverType
                    SET     IsDefault = 0
                    WHERE   IsDefault = 1
                END
        END

    INSERT  INTO [PE_DeliverType]
            ( [TypeId] ,
              [TypeName] ,
              [Intro] ,
              [ChargeType] ,
              [IsDefault] ,
              [IsDisabled] ,
              [OrderId] ,
              [ReleaseType] ,
              [MinMoney1] ,
              [ReleaseCharge] ,
              [Minmoney2] ,
              [MaxCharge] ,
              [MinMoney3] ,
              [Charge_Min] ,
              [Charge_Max] ,
              [IncludeTax] ,
              [TaxRate] ,
              [Charge_Percent]
		   
            )
    VALUES  ( @typeId ,
              @typeName ,
              @intro ,
              @chargeType ,
              @isDefault ,
              @isDisabled ,
              @orderId ,
              @releaseType ,
              @minMoney1 ,
              @releaseCharge ,
              @minmoney2 ,
              @maxCharge ,
              @minMoney3 ,
              @charge_Min ,
              @charge_Max ,
              @includeTax ,
              @taxRate ,
              @charge_Percent
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverItemDetails_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverItemDetails_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROC [dbo].[PR_Shop_DeliverItemDetails_Add]
    (
      @DeliverItemDetailsID INT ,
      @OrderID INT ,
      @DeliverID INT ,
      @productID INT ,
      @ProductNum INT ,
      @Property NVARCHAR(255)
    )
AS 
    INSERT  INTO PE_DeliverItemDetails
            ( DeliverItemDetailsID ,
              OrderID ,
              DeliverID ,
              productID ,
              ProductNum ,
              [property]
            )
    VALUES  ( @DeliverItemDetailsID ,
              @OrderID ,
              @DeliverID ,
              @productID ,
              @ProductNum ,
              @property 
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverItem_SignIn]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverItem_SignIn]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROC [dbo].[PR_Shop_DeliverItem_SignIn]
    (
      @DeliverID INT ,
      @OrderID INT
    )
AS 
    DECLARE @noReceivedCount INT
    UPDATE  pe_deliverItem
    SET     Received = 1
    WHERE   DeliverId = @DeliverID
    SELECT  @noReceivedCount = COUNT(OrderID)
    FROM    Pe_deliveritem
    WHERE   orderid = @OrderID
            AND Received = 0
    IF ( @noReceivedCount = 0 ) 
        BEGIN
            UPDATE  Pe_orders
            SET     DeliverStatus = 5
            WHERE   orderid = @OrderID
                    AND DeliverStatus = 4
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverItem_GetByOrderId]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverItem_GetByOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverItem_GetByOrderId] ( @OrderId INT )
AS 
    SELECT  O.OrderNum ,
            O.ContacterName ,
            O.Email ,
            O.UserName ,
            C.ClientName ,
            O.Status ,
            O.MoneyTotal ,
            O.MoneyReceipt ,
            O.DeliverType ,
            O.Memo ,
            D.TypeName AS DeliverTypeName
    FROM    PE_Orders O
            LEFT JOIN PE_DeliverType D ON O.DeliverType = D.TypeID
            LEFT JOIN PE_Client C ON O.ClientID = C.ClientID
    WHERE   O.OrderID = @OrderId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverItem_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverItem_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverItem_Add]
    (
      @DeliverID INT ,
      @OrderID INT ,
      @DeliverDate DATETIME ,
      @DeliverDirection INT ,
      @HandlerName NVARCHAR(20) ,
      @CourierId INT ,
      @ExpressNumber NVARCHAR(50) ,
      @Inputer NVARCHAR(20) ,
      @Remark NVARCHAR(255) ,
      @Memo NTEXT
	
    )
AS 
    INSERT  INTO PE_DeliverItem
            ( DeliverID ,
              OrderID ,
              DeliverDate ,
              DeliverDirection ,
              HandlerName ,
              CourierId ,
              ExpressNumber ,
              Inputer ,
              Remark ,
              Memo
            )
    VALUES  ( @DeliverID ,
              @OrderID ,
              @DeliverDate ,
              @DeliverDirection ,
              @HandlerName ,
              @CourierId ,
              @ExpressNumber ,
              @Inputer ,
              @Remark ,
              @Memo
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverCharge_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverCharge_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverCharge_Update]
    (
      @id INT ,
      @areaType INT = 0 ,
      @arrArea NTEXT ,
      @charge_Min MONEY = 0 ,
      @weight_Min FLOAT = 0 ,
      @chargePerUnit MONEY = 0 ,
      @weightPerUnit FLOAT = 0 ,
      @charge_Max MONEY = 0
    )
AS 
    UPDATE  [PE_DeliverCharge]
    SET     [AreaType] = @areaType ,
            [arrArea] = @arrArea ,
            [Charge_Min] = @charge_Min ,
            [Weight_Min] = @weight_Min ,
            [ChargePerUnit] = @chargePerUnit ,
            [WeightPerUnit] = @weightPerUnit ,
            [Charge_Max] = @charge_Max
    WHERE   [Id] = @id' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverCharge_GetListByAreaType]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverCharge_GetListByAreaType]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverCharge_GetListByAreaType]
    (
      @typeId INT ,
      @areaType INT
    )
AS 
    SELECT  [Id] ,
            [DeliverTypeId] ,
            [AreaType] ,
            [arrArea] ,
            [Charge_Min] ,
            [Weight_Min] ,
            [ChargePerUnit] ,
            [WeightPerUnit] ,
            [Charge_Max]
    FROM    [PE_DeliverCharge]
    WHERE   [DeliverTypeId] = @typeId
            AND [AreaType] = @areaType

    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverCharge_GetChargeParmOfWeight]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverCharge_GetChargeParmOfWeight]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverCharge_GetChargeParmOfWeight]
    @AreaType INT ,
    @DeliverType INT
AS 
    SET NOCOUNT OFF
    SELECT  [Charge_Min] ,
            [Weight_Min] ,
            [ChargePerUnit] ,
            [WeightPerUnit] ,
            [Charge_Max] ,
            [arrArea]
    FROM    PE_DeliverCharge
    WHERE   [AreaType] = @AreaType
            AND [DeliverTypeID] = @DeliverType
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverCharge_GetByTypeId]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverCharge_GetByTypeId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverCharge_GetByTypeId] ( @typeId INT )
AS 
    SELECT  [Id] ,
            [DeliverTypeId] ,
            [AreaType] ,
            [arrArea] ,
            [Charge_Min] ,
            [Weight_Min] ,
            [ChargePerUnit] ,
            [WeightPerUnit] ,
            [Charge_Max]
    FROM    [PE_DeliverCharge]
    WHERE   [DeliverTypeId] = @typeId

    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverCharge_GetById]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverCharge_GetById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverCharge_GetById] ( @id INT )
AS 
    SELECT  [Id] ,
            [DeliverTypeId] ,
            [AreaType] ,
            [arrArea] ,
            [Charge_Min] ,
            [Weight_Min] ,
            [ChargePerUnit] ,
            [WeightPerUnit] ,
            [Charge_Max]
    FROM    [PE_DeliverCharge]
    WHERE   [Id] = @id

    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverCharge_Delete]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverCharge_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverCharge_Delete] ( @id INT )
AS 
    BEGIN

        DELETE  PE_DeliverCharge
        WHERE   ID = @id
	
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_DeliverCharge_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_DeliverCharge_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_DeliverCharge_Add]
    (
      @deliverTypeID INT ,
      @areaType INT = 0 ,
      @arrArea NTEXT ,
      @charge_Min MONEY = 0 ,
      @weight_Min FLOAT = 0 ,
      @chargePerUnit MONEY = 0 ,
      @weightPerUnit FLOAT = 0 ,
      @charge_Max MONEY = 0
    )
AS 
    SET NOCOUNT OFF
 
    INSERT  INTO PE_DeliverCharge
            ( [DeliverTypeID] ,
              [AreaType] ,
              [arrArea] ,
              [Charge_Min] ,
              [Weight_Min] ,
              [ChargePerUnit] ,
              [WeightPerUnit] ,
              [Charge_Max]
            )
    VALUES  ( @deliverTypeID ,
              @areaType ,
              @arrArea ,
              @charge_Min ,
              @weight_Min ,
              @chargePerUnit ,
              @weightPerUnit ,
              @charge_Max
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Shop_Courier_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Shop_Courier_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Shop_Courier_Update]
    (
      @courierId INT ,
      @shortName NVARCHAR(64) ,
      @fullName NVARCHAR(256) ,
      @address NVARCHAR(512) ,
      @telePhone NVARCHAR(64) ,
      @Contacter NVARCHAR(64) ,
      @searchUrl NVARCHAR(256) ,
      @status INT ,
      @orderId INT
	
    )
AS --处理 排序
    DECLARE @oldOrderId INT
    DECLARE @max INT
    DECLARE @min INT
    DECLARE @count INT
    DECLARE @icount INT
    DECLARE @offset1 INT
    DECLARE @offset2 INT

    SET @icount = 1
    DECLARE @tmp TABLE
        (
          Row INT IDENTITY(1, 1)
                  PRIMARY KEY ,
          id INT ,
          oid INT
        )
    SELECT  @oldOrderId = OrderId
    FROM    [PE_Courier]
    WHERE   CourierID = @courierId
    IF ( @orderId <> @oldOrderId ) 
        BEGIN
            IF ( @orderId > @oldOrderId ) 
                BEGIN
                    SET @max = @orderId
                    SET @min = @oldOrderId
                    SET @offset1 = 0
                    SET @offset2 = 1
                END
            ELSE 
                BEGIN
                    SET @max = @oldOrderId
                    SET @min = @orderId
                    SET @offset1 = 1
                    SET @offset2 = 0
                END
            INSERT  INTO @tmp
                    ( id ,
                      oid
                    )
                    SELECT  CourierId ,
                            OrderId
                    FROM    [PE_Courier]
                    WHERE   OrderId BETWEEN @min AND @max
                    ORDER BY OrderId
            SELECT  @count = COUNT(*)
            FROM    @tmp

            WHILE ( @icount < @count ) 
                BEGIN
                    UPDATE  [PE_Courier]
                    SET     OrderId = ( SELECT  oid
                                        FROM    @tmp
                                        WHERE   Row = @icount + @offset1
                                      )
                    WHERE   CourierId = ( SELECT    Id
                                          FROM      @tmp
                                          WHERE     Row = @icount + @offset2
                                        )
                    SET @icount = @icount + 1
                END 
        END
	
    UPDATE  [PE_Courier]
    SET     [ShortName] = @shortName ,
            [FullName] = @fullName ,
            [Address] = @address ,
            [Telephone] = @telePhone ,
            [Contacter] = @Contacter ,
            [SearchUrl] = @searchUrl ,
            [Status] = @status ,
            [OrderId] = @orderId
    WHERE   CourierId = @courierId
    IF NOT ( @@error > 0 ) 
        BEGIN
            RETURN 1
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Department_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Department_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Department_Update]
    @DepartmentId INT ,
    @DepartmentName NVARCHAR(30) ,
    @CategoryName NVARCHAR(30) ,
    @UploadDir NVARCHAR(255) ,
    @Number NVARCHAR(255) ,
    @Priority INT ,
    @Template NVARCHAR(255) ,
    @SerialNumber NVARCHAR(50) ,
    @Abbreviation NVARCHAR(50)
AS 
    UPDATE  [PE_Department]
    SET     [DepartmentName] = @DepartmentName ,    --部门名称
            [CategoryName] = @CategoryName ,    --所属分类
            [UploadDir] = @UploadDir ,    --上传文件目录
            [Number] = @Number ,          --编号
            [Priority] = @Priority ,        --权重
            [Template] = @Template ,      -- 部门模板路径
            [SerialNumber] = @SerialNumber ,
            [Abbreviation] = @Abbreviation
    WHERE   [DepartmentId] = @DepartmentId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Department_Members_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Department_Members_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Department_Members_Add]
    @AdminId INT ,
    @DepartmentId INT
AS 
    IF NOT EXISTS ( SELECT  [AdminId]
                    FROM    [PE_Department_Members]
                    WHERE   [AdminID] = @AdminId
                            AND [DepartmentId] = @DepartmentId ) 
        BEGIN
            INSERT  INTO [PE_Department_Members]
                    ( [AdminId],    --管理员ID
                      [DepartmentId]    --部门Id
                      )
            VALUES  ( @AdminId, @DepartmentId )
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Department_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Department_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Department_Add]
    @DepartmentId INT ,
    @DepartmentName NVARCHAR(30) ,
    @CategoryName NVARCHAR(30) ,
    @UploadDir NVARCHAR(255) ,
    @Number NVARCHAR(255) ,
    @Priority INT ,
    @Template NVARCHAR(255) ,
    @SerialNumber NVARCHAR(50) ,
    @Abbreviation NVARCHAR(50)
AS 
    INSERT  INTO [PE_Department]
            ( [DepartmentId] ,    --部门ID
              [DepartmentName] ,    --部门名称
              [CategoryName] ,    --所属分类
              [UploadDir] ,    --上传文件目录
              [Number] ,       --编号
              [Priority] ,        --权重
              [Template] ,      --部门模板路径
              [SerialNumber] ,
              [Abbreviation]
		)
    VALUES  ( @DepartmentId ,
              @DepartmentName ,
              @CategoryName ,
              @UploadDir ,
              @Number ,
              @Priority ,
              @Template ,
              @SerialNumber ,
              @Abbreviation
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Service_Update]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Service_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_Service_Update]
    (
      @ItemId INT ,    --明细ID
      @ClientId INT ,    --客户ID
      @ContacterId INT ,    --联系人ID
      @OrderId INT ,    --订单ID
      @ServiceTime DATETIME ,    --服务时间
      @ServiceType NVARCHAR(50) ,    --服务类型
      @ServiceMode NVARCHAR(50) ,    --服务方式
      @ServiceTitle NVARCHAR(50) ,    --服务主题
      @ServiceContent NTEXT ,    --服务内容
      @ServiceResult INT ,    --服务结果，0为未完成，1为完成
      @TakeTime INT ,    --花费时间
      @Processor NVARCHAR(50) ,    --执行人
      @Inputer NVARCHAR(50) ,    --录入者
      @Feedback NTEXT ,    --客户反馈
      @ConfirmTime DATETIME ,    --回访时间
      @ConfirmCaller NVARCHAR(50) ,    --回访人
      @ConfirmScore INT ,    --客户评价
      @ConfirmFeedback NTEXT ,    --客户反馈
      @Remark NTEXT ,    --备注
      @ServicePoint INT --服务积分
    )
AS 
    UPDATE  [PE_ServiceItem]
    SET     
            [ClientId] = @ClientId ,    --客户ID
            [ContacterId] = @ContacterId ,    --联系人ID
            [OrderId] = @OrderId ,    --订单ID
            [ServiceTime] = @ServiceTime ,    --服务时间
            [ServiceType] = @ServiceType ,    --服务类型
            [ServiceMode] = @ServiceMode ,    --服务方式
            [ServiceTitle] = @ServiceTitle ,    --服务主题
            [ServiceContent] = @ServiceContent ,    --服务内容
            [ServiceResult] = @ServiceResult ,    --服务结果，0为未完成，1为完成
            [TakeTime] = @TakeTime ,    --花费时间
            [Processor] = @Processor ,    --执行人
            [Inputer] = @Inputer ,    --录入者
            [Feedback] = @Feedback ,    --客户反馈
            [ConfirmTime] = @ConfirmTime ,    --回访时间
            [ConfirmCaller] = @ConfirmCaller ,    --回访人
            [ConfirmScore] = @ConfirmScore ,    --客户评价
            [ConfirmFeedback] = @ConfirmFeedback ,    --客户反馈
            [Remark] = @Remark ,    --备注
            [ServicePoint] = @ServicePoint
    WHERE   [ItemId] = @ItemId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Service_Add]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Service_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_Service_Add]
    (
      @ClientId INT ,    --客户ID
      @ContacterId INT ,    --联系人ID
      @OrderId INT ,    --订单ID
      @ServiceTime DATETIME ,    --服务时间
      @ServiceType NVARCHAR(50) ,    --服务类型
      @ServiceMode NVARCHAR(50) ,    --服务方式
      @ServiceTitle NVARCHAR(50) ,    --服务主题
      @ServiceContent NTEXT ,    --服务内容
      @ServiceResult INT ,    --服务结果，0为未完成，1为完成
      @TakeTime INT ,    --花费时间
      @Processor NVARCHAR(50) ,    --执行人
      @Inputer NVARCHAR(50) ,    --录入者
      @Feedback NTEXT ,    --客户反馈
      @ConfirmTime DATETIME ,    --回访时间
      @ConfirmCaller NVARCHAR(50) ,    --回访人
      @ConfirmScore INT ,    --客户评价
      @ConfirmFeedback NTEXT ,    --客户反馈
      @Remark NTEXT ,    --备注
      @ServicePoint INT --服务积分
    )
AS 
    INSERT  INTO [PE_ServiceItem]
            ( 
              [ClientId] ,    --客户ID
              [ContacterId] ,    --联系人ID
              [OrderId] ,    --订单ID
              [ServiceTime] ,    --服务时间
              [ServiceType] ,    --服务类型
              [ServiceMode] ,    --服务方式
              [ServiceTitle] ,    --服务主题
              [ServiceContent] ,    --服务内容
              [ServiceResult] ,    --服务结果，0为未完成，1为完成
              [TakeTime] ,    --花费时间
              [Processor] ,    --执行人
              [Inputer] ,    --录入者
              [Feedback] ,    --客户反馈
              [ConfirmTime] ,    --回访时间
              [ConfirmCaller] ,    --回访人
              [ConfirmScore] ,    --客户评价
              [ConfirmFeedback] ,    --客户反馈
              [Remark] ,    --备注
              [ServicePoint] --服务积分
		)
    VALUES  ( --@ItemId,
              @ClientId ,
              @ContacterId ,
              @OrderId ,
              @ServiceTime ,
              @ServiceType ,
              @ServiceMode ,
              @ServiceTitle ,
              @ServiceContent ,
              @ServiceResult ,
              @TakeTime ,
              @Processor ,
              @Inputer ,
              @Feedback ,
              @ConfirmTime ,
              @ConfirmCaller ,
              @ConfirmScore ,
              @ConfirmFeedback ,
              @Remark ,
              @ServicePoint
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_RemindItem_GetInfoByTime]    Script Date: 01/19/2017 15:37:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_RemindItem_GetInfoByTime]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_RemindItem_GetInfoByTime] ( @time INT )
AS 
    BEGIN
        SELECT  R.CREATER ,
                R.REMINDCONTENT ,
                R.REMINDBYEMAIL ,
                R.REMINDBYSMS ,
                U.EMAIL ,
                C.PHS ,
                C.MOBILE
        FROM    PE_REMINDITEM R
                INNER JOIN PE_ADMIN A ON R.CREATER = A.ADMINNAME ,
                PE_USERS U ,
                PE_CONTACTER C
        WHERE   U.USERNAME = A.USERNAME
                AND C.USERNAME = A.USERNAME
                AND r.status = 0
                AND r.remindtime BETWEEN GETDATE()
                                 AND     DATEADD(n, @time, GETDATE())
        SELECT  creater
        FROM    pe_reminditem
        WHERE   status = 0
                AND remindtime BETWEEN GETDATE()
                               AND     DATEADD(n, @time, GETDATE())
        GROUP BY creater 
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_ClientAnnal_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_ClientAnnal_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_ClientAnnal_Add]
    (
      @Contacter NVARCHAR(50) ,
      @ClientAnnalID INT ,
      @ClientID INT ,
      @RelationType NVARCHAR(30) ,
      @RelationTime DATETIME ,
      @AnnalContent NVARCHAR(1000) ,
      @AnnalTime DATETIME ,
      @Inputer NVARCHAR(20)
    )
AS 
    SET NOCOUNT OFF 
    SELECT  @ClientAnnalID = ( ISNULL(MAX(ClientAnnalID), 0) + 1 )
    FROM    PE_ClientAnnal

    INSERT  INTO PE_ClientAnnal
            ( Contacter ,
              ClientAnnalID ,
              ClientID ,
              RelationType ,
              RelationTime ,
              AnnalContent ,
              Annaltime ,
              Inputer
	      )
    VALUES  ( @Contacter ,
              @ClientAnnalID ,
              @ClientID ,
              @RelationType ,
              @RelationTime ,
              @AnnalContent ,
              @AnnalTime ,
              @Inputer
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Client_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Client_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_Client_Update]
    (
      @ClientID INT ,
      @ParentID INT ,
      @ClientNum NVARCHAR(20) ,
      @ClientType INT ,
      @ClientName NVARCHAR(100) ,
      @ShortedForm NVARCHAR(20) ,
      @Area INT ,
      @ClientField INT ,
      @ValueLevel INT ,
      @CreditLevel INT ,
      @Importance INT ,
      @ConnectionLevel INT ,
      @GroupID INT ,
      @SourceType INT ,
      @PhaseType INT ,
      @Remark NTEXT ,
      @UpdateTime DATETIME ,
      @Owner NVARCHAR(50) ,
      @IsBusiness INT,
	  @UpdateOwnerTime DATETIME,
	  @MaxOrderMoney MONEY
    )
AS 
    UPDATE  [PE_Client]
    SET     ParentID = @ParentID ,
            ClientNum = @ClientNum ,
            ClientType = @ClientType ,
            ClientName = @ClientName ,
            ShortedForm = @ShortedForm ,
            Area = @Area ,
            ClientField = @ClientField ,
            ValueLevel = @ValueLevel ,
            CreditLevel = @CreditLevel ,
            Importance = @Importance ,
            ConnectionLevel = @ConnectionLevel ,
            GroupID = @GroupID ,
            SourceType = @SourceType ,
            PhaseType = @PhaseType ,
            Remark = @Remark ,
            UpdateTime = @UpdateTime ,
            Owner = @Owner ,
            IsBusiness = @IsBusiness,
			UpdateOwnerTime = @UpdateOwnerTime,
			MaxOrderMoney=@MaxOrderMoney
    WHERE   ClientID = @ClientID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Client_Merge]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Client_Merge]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROC [dbo].[PR_Crm_Client_Merge]
    (
      @PrincipalClientID INT ,
      @SubordinateClientID INT
    )
AS 
    DECLARE @clienttype1 INT
    DECLARE @clienttype2 INT
    DECLARE @LastContactedTime1 DATETIME
    DECLARE @LastContactedTime2 DATETIME
    SELECT  @clienttype1 = clienttype ,
            @LastContactedTime1 = LastContactedTime
    FROM    pe_client
    WHERE   clientid = @PrincipalClientID
    SELECT  @clienttype2 = clienttype ,
            @LastContactedTime2 = LastContactedTime
    FROM    pe_client
    WHERE   clientid = @SubordinateClientID
    IF @clienttype1 = 0--主客户为企业客户
        BEGIN
            DECLARE ContacterCursor CURSOR 
            FOR
            SELECT contacterid,truename FROM Pe_contacter WHERE clientid=@SubordinateClientID
            DECLARE @contacterid INT
            DECLARE @truename VARCHAR(20)
            OPEN ContacterCursor
            FETCH NEXT FROM ContacterCursor INTO @contacterid,@truename 
            WHILE ( @@fetch_status = 0 ) 
                BEGIN--处理联系信息
                    DECLARE @PrincipalClientcontacterid INT
                    SELECT  @PrincipalClientcontacterid = contacterid
                    FROM    pe_contacter
                    WHERE   truename = @truename
                            AND clientid = @PrincipalClientID
                    IF ( @PrincipalClientcontacterid > 0 ) --判断是否有同名的
                        BEGIN
			--和主客户的联系人的资料同名的联系人id 删除 并更改相应的联系记录内容
                            UPDATE  pe_clientannal
                            SET     clientid = @PrincipalClientID ,
                                    contacter = @PrincipalClientcontacterid
                            WHERE   clientid = @SubordinateClientID
                                    AND contacter = @contacterid
                            UPDATE  pe_reminditem
                            SET     CorrelativeClient = @PrincipalClientID ,
                                    CorrelativeContacter = @PrincipalClientcontacterid
                            WHERE   CorrelativeClient = @SubordinateClientID
                                    AND CorrelativeContacter = @contacterid
                            UPDATE  pe_ComplainItem
                            SET     clientid = @PrincipalClientID ,
                                    contacterid = @PrincipalClientcontacterid
                            WHERE   clientid = @SubordinateClientID
                                    AND contacterid = @contacterid
                            UPDATE  pe_serviceItem
                            SET     clientid = @PrincipalClientID ,
                                    contacterid = @PrincipalClientcontacterid
                            WHERE   clientid = @SubordinateClientID
                                    AND contacterid = @contacterid
                            DELETE  pe_contacter
                            WHERE   contacterid = @contacterid 
                        END
                    ELSE--没有和主客户同名的联系人则只需更改记录的客户ID
                        BEGIN
                            UPDATE  pe_clientannal
                            SET     clientid = @PrincipalClientID
                            WHERE   clientid = @SubordinateClientID
                            UPDATE  pe_reminditem
                            SET     CorrelativeClient = @PrincipalClientID
                            WHERE   CorrelativeClient = @SubordinateClientID 
                            UPDATE  pe_serviceItem
                            SET     clientid = @PrincipalClientID
                            WHERE   clientid = @SubordinateClientID 
                            UPDATE  pe_ComplainItem
                            SET     clientid = @PrincipalClientID
                            WHERE   clientid = @SubordinateClientID
                            UPDATE  pe_contacter
                            SET     clientid = @PrincipalClientID ,
									UserType = 2
                            WHERE   contacterid = @contacterid
                        END
                    FETCH NEXT FROM ContacterCursor INTO @contacterid ,@truename
                END
            CLOSE ContacterCursor
            DEALLOCATE ContacterCursor
        END
    IF @clienttype2 = 1--从客户为个人客户
        BEGIN
            UPDATE  pe_contacter
            SET     usertype = 2
            WHERE   clientid = @PrincipalClientID
                    AND usertype = 0
        END
    IF ( @clienttype2 = 1
         AND @clienttype1 = 1
       )--主从客户都是个人客户
        BEGIN
            SET nocount ON
            DECLARE @contacterid_z INT 
            DECLARE @contacterid_c INT
            SELECT  @contacterid_z = contacterid
            FROM    pe_contacter
            WHERE   clientid = @PrincipalClientID
            SELECT  @contacterid_c = contacterid
            FROM    pe_contacter
            WHERE   clientid = @SubordinateClientID
            UPDATE  pe_clientannal
            SET     clientid = @PrincipalClientID ,
                    contacter = @contacterid_z
            WHERE   clientid = @SubordinateClientID
                    AND contacter = @contacterid_c
            UPDATE  pe_reminditem
            SET     CorrelativeClient = @PrincipalClientID ,
                    CorrelativeContacter = @contacterid_z
            WHERE   CorrelativeClient = @SubordinateClientID
                    AND CorrelativeContacter = @contacterid_c
            UPDATE  pe_ComplainItem
            SET     clientid = @PrincipalClientID ,
                    contacterid = @contacterid_z
            WHERE   clientid = @SubordinateClientID
                    AND contacterid = @contacterid_c
            UPDATE  pe_serviceItem
            SET     clientid = @PrincipalClientID ,
                    contacterid = @contacterid_z
            WHERE   clientid = @SubordinateClientID
                    AND contacterid = @contacterid_c
            DELETE  pe_contacter
            WHERE   contacterid = @contacterid_c 
        END

    UPDATE  PE_Orders
    SET     ClientID = @PrincipalClientID
    WHERE   ClientID = @SubordinateClientID--从客户的订单改为主客户的
    UPDATE  PE_BankrollItem
    SET     ClientID = @PrincipalClientID
    WHERE   ClientID = @SubordinateClientID--资金明细记录
    UPDATE  PE_Client
    SET     Balance = ( SELECT  SUM(Balance)
                        FROM    pe_client
                        WHERE   clientid IN ( @PrincipalClientID,
                                              @SubordinateClientID )
                      )
    WHERE   ClientID = @PrincipalClientID--资金余额相加
    DELETE  PE_Client
    WHERE   ClientID = @SubordinateClientID--删除从客户

    IF @LastContactedTime2 > @LastContactedTime1 
        BEGIN
            UPDATE  PE_Client
            SET     LastContactedTime = @LastContactedTime2
            WHERE   ClientID = @PrincipalClientID
        END

    DECLARE @SubUserID INT
    SELECT  @SubUserID = UserID
    FROM    PE_Users
    WHERE   ClientID = @SubordinateClientID

    IF ( @SubUserID IS NOT NULL ) 
        BEGIN
            UPDATE  PE_Users
            SET     ClientID = @PrincipalClientID
            WHERE   UserID = @SubUserID
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Client_GetById]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Client_GetById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_Client_GetById] ( @ClientID INT )
AS 
    SELECT  *
    FROM    PE_Client
    WHERE   ClientID = @ClientID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Client_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Client_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_Client_Add]
    (
      @ClientID INT ,
      @ParentID INT ,
      @ClientNum NVARCHAR(20) ,
      @ClientType INT ,
      @ClientName NVARCHAR(100) ,
      @ShortedForm NVARCHAR(20) ,
      @Area INT ,
      @ClientField INT ,
      @ValueLevel INT ,
      @CreditLevel INT ,
      @Importance INT ,
      @ConnectionLevel INT ,
      @GroupID INT ,
      @SourceType INT ,
      @PhaseType INT ,
      @Remark NTEXT ,
      @CreateTime DATETIME ,
      @UpdateTime DATETIME ,
      @Owner NVARCHAR(50) ,
      @IsBusiness INT,
	  @UpdateOwnerTime DATETIME,
	  @MaxOrderMoney MONEY
	
    )
AS 
    INSERT  INTO [PE_Client]
            ( [ClientID] ,
              [ParentID] ,
              [ClientNum] ,
              [ClientType] ,
              [ClientName] ,
              [ShortedForm] ,
              [Area] ,
              [ClientField] ,
              [ValueLevel] ,
              [CreditLevel] ,
              [Importance] ,
              [ConnectionLevel] ,
              [GroupID] ,
              [SourceType] ,
              [PhaseType] ,
              [Remark] ,
              [CreateTime] ,
              [UpdateTime] ,
              [Owner] ,
              [LastContactedTime] ,
              [IsBusiness] ,
			  [UpdateOwnerTime],
			  [MaxOrderMoney]
            )
    VALUES  ( @ClientID ,
              @ParentID ,
              @ClientNum ,
              @ClientType ,
              @ClientName ,
              @ShortedForm ,
              @Area ,
              @ClientField ,
              @ValueLevel ,
              @CreditLevel ,
              @Importance ,
              @ConnectionLevel ,
              @GroupID ,
              @SourceType ,
              @PhaseType ,
              @Remark ,
              @CreateTime ,
              @UpdateTime ,
              @Owner ,
              GETDATE() ,
              @IsBusiness,
			  @UpdateOwnerTime,
			  @MaxOrderMoney
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Address_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Address_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_Address_Update]
    (
      @AddressID INT ,    --地址Id
      @UserName NVARCHAR(100) ,    --用户名
      @ConsigneeName NVARCHAR(255) ,
      @HomePhone NVARCHAR(30) ,    --固定电话
      @Mobile NVARCHAR(30) ,    --移动电话
      @Country NVARCHAR(50) ,    --国家
      @Province NVARCHAR(30) ,    --省份
      @City NVARCHAR(30) ,    --城市
      @Area NVARCHAR(30) ,
      @Address NVARCHAR(255) ,    --详细地址
      @ZipCode NVARCHAR(50),    --邮编
	  @IsDefault BIT
    )
AS 
    UPDATE  [PE_Address]
    SET     [AddressID] = @AddressID ,    --地址Id
            [UserName] = @UserName ,    --用户名
            [ConsigneeName] = @ConsigneeName ,
            [HomePhone] = @HomePhone ,    --固定电话
            [Mobile] = @Mobile ,    --移动电话
            [Country] = @Country ,    --国家
            [Province] = @Province ,    --省份	
            [City] = @City ,    --城市
            [Area] = @Area ,
            [Address] = @Address ,    --详细地址
            [ZipCode] = @ZipCode,    --邮编
			[IsDefault] = @IsDefault
    WHERE   [AddressID] = @AddressID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Crm_Address_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Crm_Address_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Crm_Address_Add]
    (
      @AddressID INT ,    --地址Id
      @UserName NVARCHAR(100) ,    --用户名
      @HomePhone NVARCHAR(30) = '''' ,    --固定电话
      @Mobile NVARCHAR(30) = '''' ,    --移动电话
      @Country NVARCHAR(50) ,    --国家
      @Province NVARCHAR(30) ,    --省份
      @City NVARCHAR(30) = '''' ,    --城市
      @Area NVARCHAR(30) = '''' ,
      @Address NVARCHAR(255) ,    --详细地址
      @ZipCode NVARCHAR(50) = '''' ,    --邮编
      @ConsigneeName NVARCHAR(255) = '''',
	  @IsDefault BIT
    )
AS 
    IF @IsDefault<>1 AND NOT EXISTS ( SELECT  *
                    FROM    PE_Address
                    WHERE   UserName = @UserName ) 
        BEGIN
            SET @IsDefault = 1
        END

    INSERT  INTO [PE_Address]
            ( [AddressID] ,    --地址Id
              [UserName] ,    --用户名
              [ConsigneeName] ,
              [HomePhone] ,    --固定电话
              [Mobile] ,    --移动电话
              [Country] ,    --国家
              [Province] ,    --省份
              [City] ,    --城市
              [Area] ,
              [Address] ,    --详细地址
              [ZipCode] ,    --邮编
              [IsDefault]    --是否默认
		)
    VALUES  ( @AddressID ,
              @UserName ,
              @ConsigneeName ,
              @HomePhone ,
              @Mobile ,
              @Country ,
              @Province ,
              @City ,
              @Area ,
              @Address ,
              @ZipCode ,
              @IsDefault
	      )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Tags]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Tags]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Tags]
    @TableName VARCHAR(50) ,
    @ItemID VARCHAR(50)
AS 
    BEGIN
        DECLARE @GetKeywords NVARCHAR(4000)
        DECLARE @String NVARCHAR(4000)
        SET @GetKeywords = ''SELECT @Key=Keyword  FROM '' + @TableName
            + '' WHERE id='' + @ItemID + ''''
        EXEC SP_EXECUTESQL @GetKeywords, N''@Key VARCHAR(4000) OUTPUT'',
            @String OUTPUT
        SELECT  ID
        FROM    dbo.SplitID(@String, ''|'')
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Nodes_UpdateOrderId]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Nodes_UpdateOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Nodes_UpdateOrderId]
    (
      @NodeID INT ,
      @OrderID INT
	
    )
AS
    UPDATE  PE_Nodes
    SET     OrderID = @OrderID
    WHERE   NodeID = @NodeID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Nodes_UpdateNextId]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Nodes_UpdateNextId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Nodes_UpdateNextId]
    (
      @NodeID INT ,
      @NextID INT
	
    )
AS
    UPDATE  PE_Nodes
    SET     NextID = @NextID
    WHERE   NodeID = @NodeID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Nodes_UpdateBasicNodesInfo]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Nodes_UpdateBasicNodesInfo]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Nodes_UpdateBasicNodesInfo]
    (
      @NodeID INT ,
      @RootID INT ,
      @OrderID INT ,
      @ParentID INT ,
      @Child INT ,
      @ParentPath NTEXT ,
      @Depth INT ,
      @PrevID INT ,
      @NextID INT ,
      @ArrChildID NTEXT ,
      @ParentDir NTEXT ,
      @NodeDir NVARCHAR(50) ,
      @PurviewType INT
    )
AS 
    UPDATE  PE_Nodes
    SET     RootID = @RootID ,
            OrderID = @OrderID ,
            ParentID = @ParentID ,
            Child = @Child ,
            ParentPath = @ParentPath ,
            Depth = @Depth ,
            PrevID = @PrevID ,
            NextID = @NextID ,
            arrChildID = @ArrChildID ,
            ParentDir = @ParentDir ,
            NodeDir = @NodeDir ,
            PurviewType = @PurviewType
    WHERE   NodeID = @NodeID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Nodes_UpDate]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Nodes_UpDate]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Nodes_UpDate]
    (
      @NodeId INT ,
      @NodeIdentifier NVARCHAR(50) ,
      @ParentId INT ,
      @ParentPath NTEXT ,
      @Depth INT ,
      @RootId INT ,
      @Child INT ,
      @ArrChildId NTEXT ,
      @PrevId INT ,
      @NextId INT ,
      @OrderId INT ,
      @NodeDir NVARCHAR(50) ,
      @ParentDir NTEXT ,
      @EnableSubDomain BIT ,
      @NodeName NVARCHAR(50) ,
      @Tips NVARCHAR(255) ,
      @Description NTEXT ,
      @NodePicUrl NVARCHAR(255) ,
      @MetaKeywords NVARCHAR(255) ,
      @MetaDescription NVARCHAR(255) ,
      @ShowOnMenu BIT ,
      @ShowOnPath BIT ,
      @ShowOnMap BIT ,
      @ShowOnListIndex BIT ,
      @ShowOnListParent BIT ,
      @PurviewType INT ,
      @Creater NVARCHAR(50) ,
      @InheritPurviewFromParent INT ,
      @WorkFlowId INT ,
      @HitsOfHot INT ,
      @LeastOfEliteLevel INT ,
      @OpenType INT ,
      @ItemCount INT ,
      @ItemChecked INT ,
      @CommentCount INT ,
      @CustomContent NTEXT ,
      @IsCreateContentPage BIT ,
      @IsCreateListPage BIT ,
      @AutoCreateHtmlType INT ,
      @ContentPageHtmlRule NVARCHAR(255) ,
      @ListPageHtmlRule NVARCHAR(255) ,
      @ListPageSavePathType INT ,
      @ListPagePostfix NVARCHAR(50) ,
      @RelateNode NTEXT ,
      @RelateSpecial NTEXT ,
      @ItemAspxFileName NVARCHAR(50) ,
      @DefaultTemplateFile NVARCHAR(255) ,
      @ContainChildTemplateFile NVARCHAR(255) ,
      @ItemOpenType INT ,
      @ItemListOrderType INT ,
      @ItemPageSize INT ,
      @LinkUrl NVARCHAR(255) ,
      @Settings NTEXT ,
      @IPLock NTEXT ,
      @NeedCreateHtml BIT ,
      @CultureName NVARCHAR(10) ,
      @SubDomain NVARCHAR(255) ,
      @ConfigType INT ,
      @IncrementalUpdatePages INT ,
      @EnablePhone BIT ,
      @EnablePad BIT
    )
AS 
    UPDATE  PE_Nodes
    SET     NodeIdentifier = @NodeIdentifier ,
            ParentId = @ParentId ,
            ParentPath = @ParentPath ,
            Depth = @Depth ,
            RootId = @RootId ,
            Child = @Child ,
            ArrChildId = @ArrChildId ,
            PrevId = @PrevId ,
            NextId = @NextId ,
            OrderId = @OrderId ,
            NodeDir = @NodeDir ,
            ParentDir = @ParentDir ,
            EnableSubDomain = @EnableSubDomain ,
            NodeName = @NodeName ,
            Tips = @Tips ,
            Description = @Description ,
            NodePicUrl = @NodePicUrl ,
            Meta_Keywords = @MetaKeywords ,
            Meta_Description = @MetaDescription ,
            ShowOnMenu = @ShowOnMenu ,
            ShowOnPath = @ShowOnPath ,
            ShowOnMap = @ShowOnMap ,
            ShowOnList_Index = @ShowOnListIndex ,
            ShowOnList_Parent = @ShowOnListParent ,
            PurviewType = @PurviewType ,
            Creater = @Creater ,
            InheritPurviewFromParent = @InheritPurviewFromParent ,
            WorkFlowID = @WorkFlowId ,
            HitsOfHot = @HitsOfHot ,
            LeastOfEliteLevel = @LeastOfEliteLevel ,
            OpenType = @OpenType ,
            ItemCount = @ItemCount ,
            ItemChecked = @ItemChecked ,
            CommentCount = @CommentCount ,
            Custom_Content = @CustomContent ,
            IsCreateContentPage = @IsCreateContentPage ,
            IsCreateListPage = @IsCreateListPage ,
            AutoCreateHtmlType = @AutoCreateHtmlType ,
            ContentPageHtmlRule = @ContentPageHtmlRule ,
            ListPageHtmlRule = @ListPageHtmlRule ,
            ListPageSavePathType = @ListPageSavePathType ,
            ListPagePostfix = @ListPagePostfix ,
            RelateNode = @RelateNode ,
            RelateSpecial = @RelateSpecial ,
            ItemAspxFileName = @ItemAspxFileName ,
            DefaultTemplateFile = @DefaultTemplateFile ,
            ContainChildTemplateFile = @ContainChildTemplateFile ,
            ItemOpenType = @ItemOpenType ,
            ItemListOrderType = @ItemListOrderType ,
            ItemPageSize = @ItemPageSize ,
            LinkUrl = @LinkUrl ,
            Settings = @Settings ,
            IPLock = @IPLock ,
            NeedCreateHtml = @NeedCreateHtml ,
            CultureName = @CultureName ,
            SubDomain = @SubDomain ,
            ConfigType = @ConfigType ,
            IncrementalUpdatePages = @IncrementalUpdatePages ,
            EnablePhone = @EnablePhone ,
            EnablePad = @EnablePad
    WHERE   NodeID = @NodeID' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Nodes_GetUpOrderListByOrderId]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Nodes_GetUpOrderListByOrderId]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Nodes_GetUpOrderListByOrderId]
    (
      @ParentID INT ,
      @OrderID INT
	
    )
AS 
    SET NOCOUNT ON
    SELECT  NodeID ,
            OrderID ,
            Child ,
            ParentPath ,
            PrevID ,
            NextID
    FROM    PE_Nodes
    WHERE   ParentID = @ParentID
            AND OrderID < @OrderID
    ORDER BY OrderID DESC  
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Nodes_GetById]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Nodes_GetById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Nodes_GetById] ( @NodeID INT )
AS 
    SET NOCOUNT ON
    SELECT  *
    FROM    PE_Nodes
    WHERE   NodeID = @NodeID
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Nodes_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Nodes_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Nodes_Add]
    (
      @NodeId INT ,
      @NodeIdentifier NVARCHAR(50) ,
      @NodeType INT ,
      @ParentId INT ,
      @ParentPath NTEXT ,
      @Depth INT ,
      @RootId INT ,
      @Child INT ,
      @ArrChildId NTEXT ,
      @PrevId INT ,
      @NextId INT ,
      @OrderId INT ,
      @NodeDir NVARCHAR(50) ,
      @ParentDir NTEXT ,
      @NodeName NVARCHAR(50) ,
      @Tips NVARCHAR(255) ,
      @Description NTEXT ,
      @NodePicUrl NVARCHAR(255) ,
      @MetaKeywords NVARCHAR(255) ,
      @MetaDescription NVARCHAR(255) ,
      @ShowOnMenu BIT ,
      @ShowOnPath BIT ,
      @ShowOnMap BIT ,
      @ShowOnListIndex BIT ,
      @ShowOnListParent BIT ,
      @PurviewType INT ,
      @Creater NVARCHAR(50) ,
      @InheritPurviewFromParent INT ,
      @WorkFlowId INT ,
      @HitsOfHot INT ,
      @LeastOfEliteLevel INT ,
      @OpenType INT ,
      @ItemCount INT ,
      @ItemChecked INT ,
      @CommentCount INT ,
      @CustomContent NTEXT ,
      @EnableSubDomain BIT ,
      @IsCreateContentPage BIT ,
      @IsCreateListPage BIT ,
      @AutoCreateHtmlType INT ,
      @ContentPageHtmlRule NVARCHAR(255) ,
      @ListPageHtmlRule NVARCHAR(255) ,
      @ListPageSavePathType INT ,
      @ListPagePostfix NVARCHAR(50) ,
      @RelateNode NTEXT ,
      @RelateSpecial NTEXT ,
      @ItemAspxFileName NVARCHAR(50) ,
      @DefaultTemplateFile NVARCHAR(255) ,
      @ContainChildTemplateFile NVARCHAR(255) ,
      @ItemOpenType INT ,
      @ItemListOrderType INT ,
      @ItemPageSize INT ,
      @LinkUrl NVARCHAR(255) ,
      @Settings NTEXT ,
      @IPLock NTEXT ,
      @NeedCreateHtml BIT ,
      @CultureName NVARCHAR(10) ,
      @SubDomain NVARCHAR(255) ,
      @ConfigType INT ,
      @IncrementalUpdatePages INT,
      @EnablePhone BIT ,
      @EnablePad BIT
    )
AS 
    INSERT  INTO PE_Nodes
            ( NodeID ,
              NodeIdentifier ,
              NodeType ,
              ParentID ,
              ParentPath ,
              Depth ,
              RootID ,
              Child ,
              arrChildID ,
              PrevID ,
              NextID ,
              OrderID ,
              NodeDir ,
              ParentDir ,
              NodeName ,
              Tips ,
              Description ,
              NodePicUrl ,
              Meta_Keywords ,
              Meta_Description ,
              ShowOnMenu ,
              ShowOnPath ,
              ShowOnMap ,
              ShowOnList_Index ,
              ShowOnList_Parent ,
              PurviewType ,
              Creater ,
              InheritPurviewFromParent ,
              WorkFlowID ,
              HitsOfHot ,
              LeastOfEliteLevel ,
              OpenType ,
              ItemCount ,
              ItemChecked ,
              CommentCount ,
              Custom_Content ,
              IsCreateContentPage ,
              IsCreateListPage ,
              AutoCreateHtmlType ,
              ContentPageHtmlRule ,
              ListPageHtmlRule ,
              ListPageSavePathType ,
              ListPagePostfix ,
              RelateNode ,
              RelateSpecial ,
              ItemAspxFileName ,
              DefaultTemplateFile ,
              ContainChildTemplateFile ,
              ItemOpenType ,
              ItemListOrderType ,
              ItemPageSize ,
              LinkUrl ,
              Settings ,
              IPLock ,
              NeedCreateHtml ,
              CultureName ,
              EnableSubDomain ,
              SubDomain ,
              ConfigType ,
              IncrementalUpdatePages ,
              EnablePhone ,
              EnablePad
		)
    VALUES  ( @NodeId ,
              @NodeIdentifier ,
              @NodeType ,
              @ParentId ,
              @ParentPath ,
              @Depth ,
              @RootId ,
              @Child ,
              @ArrChildId ,
              @PrevId ,
              @NextId ,
              @OrderId ,
              @NodeDir ,
              @ParentDir ,
              @NodeName ,
              @Tips ,
              @Description ,
              @NodePicUrl ,
              @MetaKeywords ,
              @MetaDescription ,
              @ShowOnMenu ,
              @ShowOnPath ,
              @ShowOnMap ,
              @ShowOnListIndex ,
              @ShowOnListParent ,
              @PurviewType ,
              @Creater ,
              @InheritPurviewFromParent ,
              @WorkFlowId ,
              @HitsOfHot ,
              @LeastOfEliteLevel ,
              @OpenType ,
              @ItemCount ,
              @ItemChecked ,
              @CommentCount ,
              @CustomContent ,
              @IsCreateContentPage ,
              @IsCreateListPage ,
              @AutoCreateHtmlType ,
              @ContentPageHtmlRule ,
              @ListPageHtmlRule ,
              @ListPageSavePathType ,
              @ListPagePostfix ,
              @RelateNode ,
              @RelateSpecial ,
              @ItemAspxFileName ,
              @DefaultTemplateFile ,
              @ContainChildTemplateFile ,
              @ItemOpenType ,
              @ItemListOrderType ,
              @ItemPageSize ,
              @LinkUrl ,
              @Settings ,
              @IPLock ,
              @NeedCreateHtml ,
              @CultureName ,
              @EnableSubDomain ,
              @SubDomain ,
              @ConfigType ,
              @IncrementalUpdatePages ,
              @EnablePhone ,
              @EnablePad
		)
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_MoodScheme_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_MoodScheme_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_MoodScheme_Update]
    (
      @MoodID INT ,
      @MoodName NVARCHAR(300) ,
      @MoodOption VARCHAR(4000) ,
      @MoodStatus BIT ,
      @IsOnlyMember BIT
    )
AS 
    BEGIN
        UPDATE  PE_MoodScheme
        SET     MoodName = @MoodName ,
                MoodOption = @MoodOption ,
                MoodStatus = @MoodStatus ,
                IsOnlyMember = @IsOnlyMember
        WHERE   MoodID = @MoodID
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_MoodScheme_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_MoodScheme_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_MoodScheme_Add]
    (
      @MoodID INT ,
      @MoodName NVARCHAR(300) ,
      @MoodOption VARCHAR(4000) ,
      @MoodStatus BIT ,
      @IsOnlyMember BIT
    )
AS 
    INSERT  INTO PE_MoodScheme
            ( MoodID ,
              MoodName ,
              MoodOption ,
              MoodStatus ,
              IsOnlyMember
            )
    VALUES  ( @MoodID ,
              @MoodName ,
              @MoodOption ,
              @MoodStatus ,
              @IsOnlyMember
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_Mood_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_Mood_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_Mood_Add]
    (
      @GeneralID INT ,
      @MoodID INT ,
      @M0 INT ,
      @M1 INT ,
      @M2 INT ,
      @M3 INT ,
      @M4 INT ,
      @M5 INT ,
      @M6 INT ,
      @M7 INT ,
      @M8 INT ,
      @M9 INT ,
      @M10 INT ,
      @M11 INT ,
      @M12 INT ,
      @M13 INT ,
      @M14 INT ,
      @M15 INT ,
      @M16 INT ,
      @M17 INT ,
      @M18 INT ,
      @M19 INT
    )
AS 
    INSERT  INTO PE_Mood
            ( GeneralID ,
              MoodID ,
              M0 ,
              M1 ,
              M2 ,
              M3 ,
              M4 ,
              M5 ,
              M6 ,
              M7 ,
              M8 ,
              M9 ,
              M10 ,
              M11 ,
              M12 ,
              M13 ,
              M14 ,
              M15 ,
              M16 ,
              M17 ,
              M18 ,
              M19
            )
    VALUES  ( @GeneralID ,
              @MoodID ,
              @M0 ,
              @M1 ,
              @M2 ,
              @M3 ,
              @M4 ,
              @M5 ,
              @M6 ,
              @M7 ,
              @M8 ,
              @M9 ,
              @M10 ,
              @M11 ,
              @M12 ,
              @M13 ,
              @M14 ,
              @M15 ,
              @M16 ,
              @M17 ,
              @M18 ,
              @M19
            )' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_ModelTemplates_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_ModelTemplates_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_ModelTemplates_Update]
    (
      @TemplateId INT ,
      @TemplateName NVARCHAR(255) ,
      @TemplateDescription NTEXT ,
      @Field NTEXT = '''' ,
      @IsEshop BIT  
	
    )
AS 
    UPDATE  [PE_ModelTemplates]
    SET     TemplateName = @TemplateName ,
            TemplateDescription = @TemplateDescription
    WHERE   TemplateID = @TemplateId
    RETURN' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_ModelTemplates_GetInfoById]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_ModelTemplates_GetInfoById]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_ModelTemplates_GetInfoById] ( @TemplateId INT )
AS 
    SELECT  *
    FROM    PE_ModelTemplates
    WHERE   TemplateId = @TemplateId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Contents_ModelTemplates_GetField]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Contents_ModelTemplates_GetField]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Contents_ModelTemplates_GetField] ( @TemplateId INT )
AS 
    SELECT  Field
    FROM    PE_ModelTemplates
    WHERE   TemplateId = @TemplateId' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_StatOnline_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_StatOnline_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Analytics_StatOnline_Add]
    (
      @UserIP VARCHAR(50) ,
      @UserAgent VARCHAR(255) ,
      @UserPage VARCHAR(4000)
    )
AS 
    BEGIN

        DECLARE @onlinetime INT
        DECLARE @onNowTime DATETIME
        DECLARE @id INT

        SELECT  @onlinetime = ISNULL(OnlineTime, 0)
        FROM    PE_StatInfoList
        SET @onNowTime = DATEADD(s, -@onlinetime, GETDATE())

        IF EXISTS ( SELECT  *
                    FROM    PE_Statonline
                    WHERE   LastTime > @onNowTime
                            AND UserIP = @UserIP ) 
            BEGIN
                UPDATE  PE_StatOnline
                SET     LastTime = GETDATE() ,
                        UserPage = @UserPage
                WHERE   LastTime > @onNowTime
                        AND UserIP = @UserIP
            END
        ELSE 
            BEGIN
                SELECT TOP 1
                        @id = id
                FROM    PE_StatOnline
                WHERE   LastTime < @onNowTime
                ORDER BY LastTime
                IF @id IS NOT NULL 
                    BEGIN
                        UPDATE  PE_StatOnline
                        SET     UserIP = @UserIP ,
                                UserAgent = @UserAgent ,
                                UserPage = @UserPage ,
                                Ontime = GETDATE() ,
                                LastTime = GETDATE()
                        WHERE   id = @id
                    END
                ELSE 
                    BEGIN
                        INSERT  INTO PE_StatOnline
                                ( UserIP ,
                                  UserAgent ,
                                  UserPage ,
                                  OnTime ,
                                  LastTime
                                )
                        VALUES  ( @UserIP ,
                                  @UserAgent ,
                                  @UserPage ,
                                  GETDATE() ,
                                  GETDATE()
                                )
                    END
            END
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_StatIPInfo_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_StatIPInfo_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Analytics_StatIPInfo_Update]
    @StartIp FLOAT ,
    @EndIp FLOAT ,
    @Address NVARCHAR(70) ,
    @oldStartIp FLOAT ,
    @oldEndIp FLOAT
AS 
    DECLARE @id INT

    SELECT  @id = id
    FROM    pe_statipinfo
    WHERE   StartIP = @oldStartIp
            AND EndIP = @oldEndIp

    IF NOT EXISTS ( SELECT  *
                    FROM    pe_statipinfo
                    WHERE   id <> @id
                            AND ( ( StartIP > @StartIp
                                    AND EndIP < @EndIp
                                  )
                                  OR ( @StartIp BETWEEN StartIP AND EndIP )
                                  OR ( @EndIp BETWEEN StartIP AND EndIP )
                                ) ) 
        BEGIN
            UPDATE  pe_statipinfo
            SET     StartIp = @StartIp ,
                    EndIp = @EndIp ,
                    Address = @Address
            WHERE   StartIp = @oldStartIp
                    AND EndIp = @oldEndIp
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_StatIPInfo_Delete]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_StatIPInfo_Delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Analytics_StatIPInfo_Delete]
    @StartIp FLOAT ,
    @EndIp FLOAT
AS 
    DELETE  Pe_StatIpInfo
    WHERE   StartIp = @StartIp
            AND EndIp = @EndIp' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_StatIPInfo_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_StatIPInfo_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Analytics_StatIPInfo_Add]
    @StartIp FLOAT ,
    @EndIp FLOAT ,
    @Address NVARCHAR(70)
AS 
    IF NOT EXISTS ( SELECT  id
                    FROM    PE_StatIpInfo
                    WHERE   ( StartIp > @StartIP
                              AND EndIp < @EndIp
                            )
                            OR ( @StartIp BETWEEN StartIP AND EndIP )
                            OR ( @EndIp BETWEEN StartIP AND EndIP ) ) 
        BEGIN
            INSERT  INTO Pe_statipinfo
                    ( StartIp, EndIp, Address )
            VALUES  ( @StartIp, @EndIp, @Address )
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_SaveConfig]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_SaveConfig]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Analytics_SaveConfig]
    (
      @MasterTimeZone INT ,
      @Interval INT ,
      @IntervalNum INT ,
      @OnlineTime INT ,
      @VisitRecord INT ,
      @KillRefresh INT ,
      @RegFields_Fill NVARCHAR(255) ,
      @OldTotalNum INT ,
      @OldTotalView INT ,
      @StartDate NVARCHAR(10)
    )
AS 
    IF EXISTS ( SELECT  *
                FROM    PE_statInfoList ) 
        BEGIN
	
            UPDATE  PE_StatInfoList
            SET     [MasterTimeZone] = @MasterTimeZone ,
                    [Interval] = @Interval ,
                    [IntervalNum] = @IntervalNum ,
                    [OnlineTime] = @OnlineTime ,
                    [VisitRecord] = @VisitRecord ,
                    [KillRefresh] = @KillRefresh ,
                    [RegFields_Fill] = @RegFields_Fill ,
                    [OldTotalNum] = @OldTotalNum ,
                    [OldTotalView] = @OldTotalView ,
                    [StartDate] = @StartDate

        END
    ELSE 
        BEGIN
            INSERT  INTO [PE_StatInfoList]
                    ( [StartDate] ,
                      [TotalNum] ,
                      [TotalView] ,
                      [MonthNum] ,
                      [MonthMaxNum] ,
                      [OldMonth] ,
                      [MonthMaxDate] ,
                      [DayNum] ,
                      [DayMaxNum] ,
                      [OldDay] ,
                      [DayMaxDate] ,
                      [HourNum] ,
                      [HourMaxNum] ,
                      [OldHour] ,
                      [HourMaxTime] ,
                      [ChinaNum] ,
                      [OtherNum] ,
                      [MasterTimeZone] ,
                      [Interval] ,
                      [IntervalNum] ,
                      [OnlineTime] ,
                      [VisitRecord] ,
                      [KillRefresh] ,
                      [RegFields_Fill] ,
                      [OldTotalNum] ,
                      [OldTotalView]
                    )
            VALUES  ( @StartDate ,
                      0 ,
                      0 ,
                      0 ,
                      0 ,
                      '''' ,
                      '''' ,
                      0 ,
                      0 ,
                      CONVERT(CHAR(10), GETDATE(), 120) ,
                      '''' ,
                      0 ,
                      0 ,
                      '''' ,
                      0 ,
                      0 ,
                      0 ,
                      @MasterTimeZone ,
                      @Interval ,
                      @IntervalNum ,
                      @OnlineTime ,
                      @VisitRecord ,
                      @KillRefresh ,
                      @RegFields_Fill ,
                      @OldTotalNum ,
                      @OldTotalView
                    )

        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_ModiMaxNum]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_ModiMaxNum]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Analytics_ModiMaxNum]
AS 
    BEGIN
        DECLARE @daylong VARCHAR(10)
        DECLARE @monthlong VARCHAR(7)
        DECLARE @hourlong VARCHAR(19)
        SELECT  @daylong = CONVERT(CHAR(10), GETDATE(), 120)
        SELECT  @monthlong = CONVERT(CHAR(7), GETDATE(), 120)
        SELECT  @hourlong = CONVERT(CHAR(13), GETDATE(), 120) + '':00:00''

        DECLARE @OldMonth NVARCHAR(10)
        DECLARE @OldDay NVARCHAR(10)
        DECLARE @OldHour NVARCHAR(20)
        DECLARE @MonthNum INT
        DECLARE @MonthMaxNum INT
        DECLARE @DayNum INT
        DECLARE @DayMaxNum INT
        DECLARE @HourNum INT
        DECLARE @HourMaxNum INT

        SELECT TOP 1
                @MonthNum = MonthNum ,
                @MonthMaxNum = MonthMaxNum ,
                @DayNum = DayNum ,
                @DayMaxNum = DayMaxNum ,
                @HourNum = HourNum ,
                @HourMaxNum = HourMaxNum ,
                @OldMonth = OldMonth ,
                @OldDay = OldDay ,
                @OldHour = OldHour
        FROM    PE_StatInfoList

        IF @OldMonth = @monthlong 
            BEGIN
                SET @MonthNum = @MonthNum + 1
                UPDATE  PE_StatInfoList
                SET     MonthNum = @MonthNum
            END
        ELSE 
            BEGIN
                SET @MonthNum = 1
                UPDATE  PE_StatInfoList
                SET     OldMonth = @monthlong ,
                        MonthNum = 1
            END

        IF @MonthNum > @MonthMaxNum 
            UPDATE  PE_StatInfoList
            SET     MonthMaxNum = @MonthNum ,
                    MonthMaxDate = @MonthLong

        IF @OldDay = @DayLong 
            BEGIN
                SET @DayNum = @DayNum + 1
                UPDATE  PE_StatInfoList
                SET     DayNum = @DayNum
            END
        ELSE 
            BEGIN
                SET @DayNum = 1
                UPDATE  PE_StatInfoList
                SET     OldDay = @DayLong ,
                        DayNum = 1
            END

        IF @DayNum > @DayMaxNum 
            UPDATE  PE_StatInfoList
            SET     DayMaxNum = @DayNum ,
                    DayMaxDate = @DayLong

        IF @OldHour = @HourLong 
            BEGIN
                SET @HourNum = @HourNum + 1
                UPDATE  PE_StatInfoList
                SET     HourNum = @HourNum
            END
        ELSE 
            BEGIN
                SET @HourNum = 1
                UPDATE  PE_StatInfoList
                SET     OldHour = @HourLong ,
                        HourNum = 1
            END

        IF @HourNum > @HourMaxNum 
            UPDATE  PE_StatInfoList
            SET     HourMaxNum = @HourNum ,
                    HourMaxTime = @HourLong
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_GetOnlineCount]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_GetOnlineCount]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Analytics_GetOnlineCount]
AS 
    BEGIN
        DECLARE @onlinetime INT
        SELECT  @onlinetime = ISNULL(OnlineTime, 0)
        FROM    PE_StatInfoList

        SELECT  COUNT(UserIP)
        FROM    PE_Statonline
        WHERE   LastTime > DATEADD(s, -@onlinetime, GETDATE())

    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_GetOnlineByIP]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_GetOnlineByIP]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Analytics_GetOnlineByIP] @IP VARCHAR(50)
AS 
    BEGIN
        DECLARE @onlinetime INT
        SELECT  @onlinetime = ISNULL(OnlineTime, 100)
        FROM    PE_StatInfoList

        SELECT  *
        FROM    PE_Statonline
        WHERE   LastTime > DATEADD(s, -@onlinetime, GETDATE())
                AND UserIP = @IP

    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_DoInit]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_DoInit]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Analytics_DoInit]
AS 
    DELETE  FROM PE_StatAddress
    DELETE  FROM PE_StatBrowser
    DELETE  FROM PE_StatColor
    DELETE  FROM PE_StatIp
    DELETE  FROM PE_StatMozilla
    DELETE  FROM PE_StatRefer
    DELETE  FROM PE_StatScreen
    DELETE  FROM PE_StatSystem
    DELETE  FROM PE_StatTimezone
    DELETE  FROM PE_StatVisit
    DELETE  FROM PE_StatWeburl
    DELETE  FROM PE_StatDay
    DELETE  FROM PE_StatMonth
    DELETE  FROM PE_StatWeek
    DELETE  FROM PE_StatYear
    DELETE  FROM PE_StatVisitor
    DECLARE @date CHAR(10)
    SET @date = CONVERT(CHAR(10), GETDATE(), 120)
    UPDATE  PE_StatInfoList
    SET     StartDate = @date ,
            OldDay = @date ,
            TotalNum = 0 ,
            TotalView = 0 ,
            MonthNum = 0 ,
            MonthMaxNum = 0 ,
            OldMonth = '''' ,
            MonthMaxDate = '''' ,
            DayNum = 0 ,
            DayMaxNum = 0 ,
            DayMaxDate = '''' ,
            HourNum = 0 ,
            HourMaxNum = 0 ,
            OldHour = '''' ,
            HourMaxTime = '''' ,
            ChinaNum = 0 ,
            OtherNum = 0

    IF NOT ( @@error > 0 ) 
        BEGIN
            RETURN 1
        END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_StatVisitor_Add]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_StatVisitor_Add]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Analytics_StatVisitor_Add]
    (
      @Ip NVARCHAR(50) ,
      @Address NVARCHAR(50) ,
      @System NVARCHAR(20) ,
      @Browser NVARCHAR(20) ,
      @Screen NVARCHAR(10) ,
      @Color NVARCHAR(16) ,
      @Referer NVARCHAR(100) ,
      @Timezone INT
    )
AS 
    BEGIN
        DECLARE @VisitCount INT
        DECLARE @VisitRecord INT
        SELECT  @VisitCount = COUNT(ID)
        FROM    PE_StatVisitor
        SELECT TOP 1
                @VisitRecord = VisitRecord
        FROM    PE_StatInfoList
        IF @VisitCount >= @VisitRecord 
            BEGIN
                DECLARE @id INT
                SELECT TOP 1
                        @id = id
                FROM    PE_StatVisitor
                ORDER BY VTime ASC
                UPDATE  [PE_StatVisitor]
                SET     [VTime] = GETDATE() ,
                        [Ip] = @Ip ,
                        [Address] = @Address ,
                        [System] = @System ,
                        [Browser] = @Browser ,
                        [Screen] = @Screen ,
                        [Color] = @Color ,
                        [Referer] = @Referer ,
                        [Timezone] = @Timezone
                WHERE   id = @id
            END
        ELSE 
            BEGIN
                INSERT  INTO [PE_StatVisitor]
                        ( [VTime] ,
                          [Ip] ,
                          [Address] ,
                          [System] ,
                          [Browser] ,
                          [Screen] ,
                          [Color] ,
                          [Referer] ,
                          [Timezone]
                        )
                VALUES  ( GETDATE() ,
                          @Ip ,
                          @Address ,
                          @System ,
                          @Browser ,
                          @Screen ,
                          @Color ,
                          @Referer ,
                          @Timezone
                        )
            END
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_StatVisit_Update]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_StatVisit_Update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Analytics_StatVisit_Update] @visit INT
AS 
    BEGIN
        IF NOT EXISTS ( SELECT  *
                        FROM    PE_StatVisit ) 
            BEGIN
                INSERT  INTO PE_StatVisit
                VALUES  ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
            END

        IF @visit > 0
            AND @visit <= 10 
            BEGIN
                DECLARE @num CHAR(2)
                SET @num = CONVERT(CHAR(2), @visit)
                EXEC(''update PE_StatVisit set [''+ @num+''] = [''+@num+''] + 1'')
            END

        IF @visit > 10 
            BEGIN
                UPDATE  PE_StatVisit
                SET     [10] = [10] + 1
            END
    END' 
END
GO
/****** Object:  StoredProcedure [dbo].[PR_Analytics_StatUpdate]    Script Date: 01/19/2017 15:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Analytics_StatUpdate]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PR_Analytics_StatUpdate]
    (
      @_visit INT ,
      @_IP NVARCHAR(50) = '''' ,
      @_address NVARCHAR(50) = '''' ,
      @_system NVARCHAR(20) = '''' ,
      @_browser NVARCHAR(20) = '''' ,
      @_screen NVARCHAR(10) = '''' ,
      @_color NVARCHAR(16) = '''' ,
      @_referer NVARCHAR(100) = '''' ,
      @_weburl NVARCHAR(50) = '''' ,
      @_timezone NVARCHAR(50) = '''' ,
      @_visitTimezone INT ,
      @_keyword NVARCHAR(50) = '''' ,
      @_mozilla NVARCHAR(255) = ''''
    )
AS 
    BEGIN
        DECLARE @RegFields_Fill NVARCHAR(4000)
        DECLARE @_scope NVARCHAR(20)
        DECLARE @Province NVARCHAR(4000)
        DECLARE @dayLong NVARCHAR(10)
        DECLARE @monthLong NVARCHAR(7)
        DECLARE @hour NVARCHAR(2)
        DECLARE @year NVARCHAR(4)
        DECLARE @month NVARCHAR(2)
        DECLARE @day NVARCHAR(2)
        DECLARE @week NVARCHAR(1)

        SET @monthLong = CONVERT(NVARCHAR(7), GETDATE(), 120)
        SET @dayLong = CONVERT(NVARCHAR(10), GETDATE(), 120)
        SET @year = DATENAME(yyyy, GETDATE())
        SET @month = CONVERT(NVARCHAR(2), DATEPART(mm, GETDATE()))
        SET @day = DATENAME(dd, GETDATE())
        SET @hour = DATENAME(hh, GETDATE())
        SET @week = CONVERT(NVARCHAR(1), DATEPART(dw, GETDATE()))
        SET @Province = ''北京天津上海重庆黑龙江吉林辽宁江苏浙江安徽河南河北湖南湖北山东山西内蒙古陕西甘肃宁夏青海新疆西藏云南贵州四川广东广西福建江西海南香港澳门台湾内部网络未知保留本地本机''

        IF CHARINDEX(LEFT(@_address, 2), @Province, 0) > 0 
            SET @_scope = ''ChinaNum''
        ELSE 
            SET @_scope = ''OtherNum''

        SELECT  @RegFields_Fill = RegFields_Fill
        FROM    pe_statInfolist

	--更新PE_StatVisit表
        IF CHARINDEX(''FVisit'', @RegFields_Fill, 0) > 0 
            EXEC [PR_Analytics_StatVisit_Update] @visit = @_visit

	--更新PE_StatVisitor表
        EXEC [PR_Analytics_StatVisitor_Add] @Ip = @_IP, @Address = @_address,
            @System = @_system, @Browser = @_browser, @Screen = @_screen,
            @Color = @_color, @Referer = @_referer,
            @Timezone = @_visitTimezone

	--更新PE_StatInfoList表
        IF NOT EXISTS ( SELECT TOP 1
                                *
                        FROM    PE_StatInfoList ) 
            BEGIN
                INSERT  INTO PE_StatInfoList
                        ( [StartDate] ,
                          [TotalNum] ,
                          [TotalView] ,
                          [MonthNum] ,
                          [MonthMaxNum] ,
                          [OldMonth] ,
                          [MonthMaxDate] ,
                          [DayNum] ,
                          [DayMaxNum] ,
                          [OldDay] ,
                          [DayMaxDate] ,
                          [HourNum] ,
                          [HourMaxNum] ,
                          [OldHour] ,
                          [HourMaxTime] ,
                          [ChinaNum] ,
                          [OtherNum] ,
                          [MasterTimeZone] ,
                          [Interval] ,
                          [IntervalNum] ,
                          [OnlineTime] ,
                          [VisitRecord] ,
                          [KillRefresh] ,
                          [RegFields_Fill] ,
                          [OldTotalNum] ,
                          [OldTotalView]
                        )
                VALUES  ( @dayLong ,
                          0 ,
                          0 ,
                          0 ,
                          0 ,
                          0 ,
                          '''' ,
                          0 ,
                          0 ,
                          @dayLong ,
                          '''' ,
                          0 ,
                          0 ,
                          '''' ,
                          '''' ,
                          0 ,
                          0 ,
                          0 ,
                          60 ,
                          10 ,
                          120 ,
                          0 ,
                          0 ,
                          '''' ,
                          0 ,
                          0
                        )
            END
        EXEC (''Update PE_StatInfoList set TotalNum = TotalNum +1,TotalView = TotalView +1,''+@_scope+''=''+@_scope+''+1'')
        DECLARE @StartDate NVARCHAR(10)
        DECLARE @OldDay NVARCHAR(10)
        SELECT TOP 1
                @Startdate = startDate ,
                @OldDay = OldDay
        FROM    PE_StatInfoList
        IF @StartDate IS NULL 
            UPDATE  PE_StatInfoList
            SET     startDate = @dayLong
        IF @OldDay IS NULL 
            BEGIN
                UPDATE  PE_StatInfoList
                SET     OldDay = @dayLong
                SET @OldDay = @dayLong
            END
        EXEC [PR_Analytics_ModiMaxNum]
        IF @_keyword <> ''''
            AND CHARINDEX(''FKeyword'', @RegFields_Fill, 0) > 0 
            EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatKeyword'',
                @CompareField = ''Tkeyword'', @AddField = ''TkeywordNum'',
                @Data = @_keyword

        IF CHARINDEX(''FSystem'', @RegFields_Fill, 0) > 0 
            EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatSystem'',
                @CompareField = ''TSystem'', @AddField = ''TSysNum'',
                @Data = @_system

        IF CHARINDEX(''FBrowser'', @RegFields_Fill, 0) > 0 
            EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatBrowser'',
                @CompareField = ''TBrowser'', @AddField = ''TBrwNum'',
                @Data = @_browser

        IF CHARINDEX(''FMozilla'', @RegFields_Fill, 0) > 0 
            EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatMozilla'',
                @CompareField = ''TMozilla'', @AddField = ''TMozNum'',
                @Data = @_mozilla

        IF CHARINDEX(''FScreen'', @RegFields_Fill, 0) > 0 
            EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatScreen'',
                @CompareField = ''TScreen'', @AddField = ''TScrNum'',
                @Data = @_screen

        IF CHARINDEX(''FColor'', @RegFields_Fill, 0) > 0 
            EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatColor'',
                @CompareField = ''TColor'', @AddField = ''TColNum'',
                @Data = @_color

        IF CHARINDEX(''FTimezone'', @RegFields_Fill, 0) > 0 
            EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatTimezone'',
                @CompareField = ''TTimezone'', @AddField = ''TTimNum'',
                @Data = @_timezone

        IF CHARINDEX(''FRefer'', @RegFields_Fill, 0) > 0 
            EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatRefer'',
                @CompareField = ''TRefer'', @AddField = ''TRefNum'',
                @Data = @_referer

        IF CHARINDEX(''FWeburl'', @RegFields_Fill, 0) > 0 
            EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatWeburl'',
                @CompareField = ''TWeburl'', @AddField = ''TWebNum'',
                @Data = @_weburl

        IF CHARINDEX(''FAddress'', @RegFields_Fill, 0) > 0 
            EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatAddress'',
                @CompareField = ''TAddress'', @AddField = ''TAddNum'',
                @Data = @_address

        IF CHARINDEX(''FIP'', @RegFields_Fill, 0) > 0 
            EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatIp'',
                @CompareField = ''TIp'', @AddField = ''TIpNum'', @Data = @_IP

        EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatDay'',
            @CompareField = ''TDay'', @AddField = @hour, @Data = @dayLong
        EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatDay'',
            @CompareField = ''TDay'', @AddField = @hour, @Data = ''Total''
        EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatYear'',
            @CompareField = ''TYear'', @AddField = @month, @Data = @year
        EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatYear'',
            @CompareField = ''TYear'', @AddField = @month, @Data = ''Total''
        EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatMonth'',
            @CompareField = ''TMonth'', @AddField = @day, @Data = @monthLong
        EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatMonth'',
            @CompareField = ''TMonth'', @AddField = @day, @Data = ''Total''
        EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatWeek'',
            @CompareField = ''TWeek'', @AddField = @week, @Data = ''Total''
        IF DATEDIFF(week, @OldDay, GETDATE()) > 0 
            DELETE  FROM PE_StatWeek
            WHERE   TWeek = ''Current''
        EXEC [PR_Analytics_AddNum] @TableName = ''PE_StatWeek'',
            @CompareField = ''TWeek'', @AddField = @week, @Data = ''Current''

    END' 
END
GO
/****** Object:  Default [DF_PE_Address_IsDefalult]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Address_IsDefalult]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Address]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Address_IsDefalult]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Address] ADD  CONSTRAINT [DF_PE_Address_IsDefalult]  DEFAULT ((0)) FOR [IsDefault]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_ADType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_ADType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_ADType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] ADD  CONSTRAINT [DF_PE_Advertisement_ADType]  DEFAULT ((0)) FOR [ADType]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_FlashWmode]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_FlashWmode]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_FlashWmode]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] ADD  CONSTRAINT [DF_PE_Advertisement_FlashWmode]  DEFAULT ((0)) FOR [FlashWmode]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_LinkTarget]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_LinkTarget]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_LinkTarget]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] ADD  CONSTRAINT [DF_PE_Advertisement_LinkTarget]  DEFAULT ((0)) FOR [LinkTarget]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_CountView]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_CountView]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_CountView]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] ADD  CONSTRAINT [DF_PE_Advertisement_CountView]  DEFAULT ((0)) FOR [CountView]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_Views]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_Views]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_Views]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] ADD  CONSTRAINT [DF_PE_Advertisement_Views]  DEFAULT ((0)) FOR [Views]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_CountClick]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_CountClick]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_CountClick]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] ADD  CONSTRAINT [DF_PE_Advertisement_CountClick]  DEFAULT ((0)) FOR [CountClick]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_Clicks]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_Clicks]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_Clicks]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] ADD  CONSTRAINT [DF_PE_Advertisement_Clicks]  DEFAULT ((0)) FOR [Clicks]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_AbsolutePath]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_AbsolutePath]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_AbsolutePath]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] ADD  CONSTRAINT [DF_PE_Advertisement_AbsolutePath]  DEFAULT ((0)) FOR [IsAbsolutePath]
END


End
GO
/****** Object:  Default [DF_PE_Advertisement_Passed]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Advertisement_Passed]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Advertisement]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Advertisement_Passed]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Advertisement] ADD  CONSTRAINT [DF_PE_Advertisement_Passed]  DEFAULT ((0)) FOR [Passed]
END


End
GO
/****** Object:  Default [DF_PE_AdZone_ZoneType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_AdZone_ZoneType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_AdZone]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_AdZone_ZoneType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_AdZone] ADD  CONSTRAINT [DF_PE_AdZone_ZoneType]  DEFAULT ((0)) FOR [ZoneType]
END


End
GO
/****** Object:  Default [DF_PE_AdZone_DefaultSetting]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_AdZone_DefaultSetting]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_AdZone]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_AdZone_DefaultSetting]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_AdZone] ADD  CONSTRAINT [DF_PE_AdZone_DefaultSetting]  DEFAULT ((1)) FOR [DefaultSetting]
END


End
GO
/****** Object:  Default [DF_PE_AdZone_ZoneWidth]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_AdZone_ZoneWidth]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_AdZone]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_AdZone_ZoneWidth]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_AdZone] ADD  CONSTRAINT [DF_PE_AdZone_ZoneWidth]  DEFAULT ((0)) FOR [ZoneWidth]
END


End
GO
/****** Object:  Default [DF_PE_AdZone_ZoneHeight]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_AdZone_ZoneHeight]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_AdZone]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_AdZone_ZoneHeight]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_AdZone] ADD  CONSTRAINT [DF_PE_AdZone_ZoneHeight]  DEFAULT ((0)) FOR [ZoneHeight]
END


End
GO
/****** Object:  Default [DF_PE_AdZone_Active]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_AdZone_Active]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_AdZone]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_AdZone_Active]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_AdZone] ADD  CONSTRAINT [DF_PE_AdZone_Active]  DEFAULT ((0)) FOR [Active]
END


End
GO
/****** Object:  Default [DF_PE_AdZone_ShowType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_AdZone_ShowType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_AdZone]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_AdZone_ShowType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_AdZone] ADD  CONSTRAINT [DF_PE_AdZone_ShowType]  DEFAULT ((0)) FOR [ShowType]
END


End
GO
/****** Object:  Default [DF_PE_Author_UserID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_UserID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_UserID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] ADD  CONSTRAINT [DF_PE_Author_UserID]  DEFAULT ((0)) FOR [UserID]
END


End
GO
/****** Object:  Default [DF_PE_Author_Passed]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_Passed]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_Passed]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] ADD  CONSTRAINT [DF_PE_Author_Passed]  DEFAULT ((0)) FOR [Passed]
END


End
GO
/****** Object:  Default [DF_PE_Author_onTop]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_onTop]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_onTop]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] ADD  CONSTRAINT [DF_PE_Author_onTop]  DEFAULT ((0)) FOR [onTop]
END


End
GO
/****** Object:  Default [DF_PE_Author_IsElite]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_IsElite]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_IsElite]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] ADD  CONSTRAINT [DF_PE_Author_IsElite]  DEFAULT ((0)) FOR [IsElite]
END


End
GO
/****** Object:  Default [DF_PE_Author_Hits]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_Hits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_Hits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] ADD  CONSTRAINT [DF_PE_Author_Hits]  DEFAULT ((0)) FOR [Hits]
END


End
GO
/****** Object:  Default [DF_PE_Author_TemplateID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_TemplateID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_TemplateID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] ADD  CONSTRAINT [DF_PE_Author_TemplateID]  DEFAULT ((0)) FOR [TemplateID]
END


End
GO
/****** Object:  Default [DF_PE_Author_ZipCode]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_ZipCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_ZipCode]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] ADD  CONSTRAINT [DF_PE_Author_ZipCode]  DEFAULT ((0)) FOR [ZipCode]
END


End
GO
/****** Object:  Default [DF_PE_Author_Sex]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Author_Sex]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Author]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Author_Sex]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Author] ADD  CONSTRAINT [DF_PE_Author_Sex]  DEFAULT ((0)) FOR [Sex]
END


End
GO
/****** Object:  Default [DF_PE_Bank_OrderID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Bank_OrderID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Bank]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Bank_OrderID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Bank] ADD  CONSTRAINT [DF_PE_Bank_OrderID]  DEFAULT ((0)) FOR [OrderID]
END


End
GO
/****** Object:  Default [DF_PE_Bank_IsDefault]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Bank_IsDefault]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Bank]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Bank_IsDefault]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Bank] ADD  CONSTRAINT [DF_PE_Bank_IsDefault]  DEFAULT ((0)) FOR [IsDefault]
END


End
GO
/****** Object:  Default [DF_PE_Bank_IsDisabled]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Bank_IsDisabled]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Bank]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Bank_IsDisabled]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Bank] ADD  CONSTRAINT [DF_PE_Bank_IsDisabled]  DEFAULT ((0)) FOR [IsDisabled]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_ClientID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] ADD  CONSTRAINT [DF_PE_BankrollItem_ClientID]  DEFAULT ((0)) FOR [ClientID]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_Money]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_Money]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_Money]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] ADD  CONSTRAINT [DF_PE_BankrollItem_Money]  DEFAULT ((0)) FOR [Money]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_MoneyType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_MoneyType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_MoneyType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] ADD  CONSTRAINT [DF_PE_BankrollItem_MoneyType]  DEFAULT ((0)) FOR [MoneyType]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_CurrencyType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_CurrencyType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_CurrencyType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] ADD  CONSTRAINT [DF_PE_BankrollItem_CurrencyType]  DEFAULT ((0)) FOR [CurrencyType]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_eBankID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_eBankID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_eBankID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] ADD  CONSTRAINT [DF_PE_BankrollItem_eBankID]  DEFAULT ((0)) FOR [eBankID]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_OrderFormID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_OrderFormID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_OrderFormID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] ADD  CONSTRAINT [DF_PE_BankrollItem_OrderFormID]  DEFAULT ((0)) FOR [OrderID]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_PaymentID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_PaymentID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_PaymentID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] ADD  CONSTRAINT [DF_PE_BankrollItem_PaymentID]  DEFAULT ((0)) FOR [PaymentID]
END


End
GO
/****** Object:  Default [DF_PE_BankrollItem_Status]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_BankrollItem_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_BankrollItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_BankrollItem_Status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_BankrollItem] ADD  CONSTRAINT [DF_PE_BankrollItem_Status]  DEFAULT ((1)) FOR [Status]
END


End
GO
/****** Object:  Default [DF_PE_Cards_CardType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Cards_CardType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Cards]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Cards_CardType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Cards] ADD  CONSTRAINT [DF_PE_Cards_CardType]  DEFAULT ((0)) FOR [CardType]
END


End
GO
/****** Object:  Default [DF_PE_Cards_ProductID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Cards_ProductID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Cards]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Cards_ProductID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Cards] ADD  CONSTRAINT [DF_PE_Cards_ProductID]  DEFAULT ((0)) FOR [ProductID]
END


End
GO
/****** Object:  Default [DF_PE_Card_Money]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Card_Money]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Cards]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Card_Money]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Cards] ADD  CONSTRAINT [DF_PE_Card_Money]  DEFAULT ((0)) FOR [Money]
END


End
GO
/****** Object:  Default [DF_PE_Card_ValidNum]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Card_ValidNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Cards]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Card_ValidNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Cards] ADD  CONSTRAINT [DF_PE_Card_ValidNum]  DEFAULT ((0)) FOR [ValidNum]
END


End
GO
/****** Object:  Default [DF_PE_Card_ValidUnit]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Card_ValidUnit]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Cards]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Card_ValidUnit]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Cards] ADD  CONSTRAINT [DF_PE_Card_ValidUnit]  DEFAULT ((0)) FOR [ValidUnit]
END


End
GO
/****** Object:  Default [DF_PE_Card_OrderItemID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Card_OrderItemID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Cards]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Card_OrderItemID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Cards] ADD  CONSTRAINT [DF_PE_Card_OrderItemID]  DEFAULT ((0)) FOR [OrderItemID]
END


End
GO
/****** Object:  Default [DF_PE_Client_ClientID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_ClientID]  DEFAULT ((0)) FOR [ClientID]
END


End
GO
/****** Object:  Default [DF_PE_Client_ParentID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ParentID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ParentID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_ParentID]  DEFAULT ((0)) FOR [ParentID]
END


End
GO
/****** Object:  Default [DF_PE_Client_ClientType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ClientType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ClientType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_ClientType]  DEFAULT ((0)) FOR [ClientType]
END


End
GO
/****** Object:  Default [DF_PE_Client_Area]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_Area]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_Area]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_Area]  DEFAULT ((0)) FOR [Area]
END


End
GO
/****** Object:  Default [DF_PE_Client_ClientField]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ClientField]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ClientField]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_ClientField]  DEFAULT ((0)) FOR [ClientField]
END


End
GO
/****** Object:  Default [DF_PE_Client_ValueLevel]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ValueLevel]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ValueLevel]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_ValueLevel]  DEFAULT ((0)) FOR [ValueLevel]
END


End
GO
/****** Object:  Default [DF_PE_Client_CreditLevel]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_CreditLevel]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_CreditLevel]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_CreditLevel]  DEFAULT ((0)) FOR [CreditLevel]
END


End
GO
/****** Object:  Default [DF_PE_Client_Importance]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_Importance]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_Importance]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_Importance]  DEFAULT ((0)) FOR [Importance]
END


End
GO
/****** Object:  Default [DF_PE_Client_ConnectionLevel]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ConnectionLevel]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ConnectionLevel]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_ConnectionLevel]  DEFAULT ((0)) FOR [ConnectionLevel]
END


End
GO
/****** Object:  Default [DF_PE_Client_GroupID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_GroupID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_GroupID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_GroupID]  DEFAULT ((0)) FOR [GroupID]
END


End
GO
/****** Object:  Default [DF_PE_Client_SourceType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_SourceType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_SourceType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_SourceType]  DEFAULT ((0)) FOR [SourceType]
END


End
GO
/****** Object:  Default [DF_PE_Client_PhaseType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_PhaseType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_PhaseType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_PhaseType]  DEFAULT ((0)) FOR [PhaseType]
END


End
GO
/****** Object:  Default [DF_PE_Client_VisitTimes]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_VisitTimes]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_VisitTimes]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_VisitTimes]  DEFAULT ((0)) FOR [VisitTimes]
END


End
GO
/****** Object:  Default [DF_PE_Client_ServiceTimes]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ServiceTimes]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ServiceTimes]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_ServiceTimes]  DEFAULT ((0)) FOR [ServiceTimes]
END


End
GO
/****** Object:  Default [DF_PE_Client_ComplainTimes]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_ComplainTimes]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_ComplainTimes]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_ComplainTimes]  DEFAULT ((0)) FOR [ComplainTimes]
END


End
GO
/****** Object:  Default [DF_PE_Client_Balance]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Client_Balance]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Client]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Client_Balance]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Client] ADD  CONSTRAINT [DF_PE_Client_Balance]  DEFAULT ((0)) FOR [Balance]
END


End
GO
/****** Object:  Default [DF_PE_CollectionExclosion_ExclosionStringType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionExclosion_ExclosionStringType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionExclosion]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionExclosion_ExclosionStringType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionExclosion] ADD  CONSTRAINT [DF_PE_CollectionExclosion_ExclosionStringType]  DEFAULT ((1)) FOR [ExclosionStringType]
END


End
GO
/****** Object:  Default [DF_PE_CollectionFieldRules_RuleType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionFieldRules_RuleType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionFieldRules]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionFieldRules_RuleType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionFieldRules] ADD  CONSTRAINT [DF_PE_CollectionFieldRules_RuleType]  DEFAULT ((0)) FOR [RuleType]
END


End
GO
/****** Object:  Default [DF_PE_CollectionFieldRules_UsePaging]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionFieldRules_UsePaging]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionFieldRules]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionFieldRules_UsePaging]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionFieldRules] ADD  CONSTRAINT [DF_PE_CollectionFieldRules_UsePaging]  DEFAULT ((0)) FOR [UsePaging]
END


End
GO
/****** Object:  Default [DF_PE_CollectionFilterRules_FilterType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionFilterRules_FilterType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionFilterRules]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionFilterRules_FilterType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionFilterRules] ADD  CONSTRAINT [DF_PE_CollectionFilterRules_FilterType]  DEFAULT ((0)) FOR [FilterType]
END


End
GO
/****** Object:  Default [DF_PE_CollectionItem_MaxNum]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionItem_MaxNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionItem_MaxNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionItem] ADD  CONSTRAINT [DF_PE_CollectionItem_MaxNum]  DEFAULT ((0)) FOR [MaxNum]
END


End
GO
/****** Object:  Default [DF_PE_CollectionItem_Detection]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionItem_Detection]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionItem_Detection]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionItem] ADD  CONSTRAINT [DF_PE_CollectionItem_Detection]  DEFAULT ((0)) FOR [Detection]
END


End
GO
/****** Object:  Default [DF_PE_CollectionListRules_UsePaging]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionListRules_UsePaging]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionListRules]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionListRules_UsePaging]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionListRules] ADD  CONSTRAINT [DF_PE_CollectionListRules_UsePaging]  DEFAULT ((0)) FOR [UsePaging]
END


End
GO
/****** Object:  Default [DF_PE_CollectionPagingRules_CorrelationRuleId]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionPagingRules_CorrelationRuleId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionPagingRules]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionPagingRules_CorrelationRuleId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionPagingRules] ADD  CONSTRAINT [DF_PE_CollectionPagingRules_CorrelationRuleId]  DEFAULT ((0)) FOR [PagingRuleID]
END


End
GO
/****** Object:  Default [DF_PE_CollectionPagingRules_RuleType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionPagingRules_RuleType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionPagingRules]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionPagingRules_RuleType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionPagingRules] ADD  CONSTRAINT [DF_PE_CollectionPagingRules_RuleType]  DEFAULT ((0)) FOR [RuleType]
END


End
GO
/****** Object:  Default [DF_PE_CollectionPagingRules_PagingType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CollectionPagingRules_PagingType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CollectionPagingRules]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CollectionPagingRules_PagingType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CollectionPagingRules] ADD  CONSTRAINT [DF_PE_CollectionPagingRules_PagingType]  DEFAULT ((0)) FOR [PagingType]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_Hits]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_Hits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_Hits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] ADD  CONSTRAINT [DF_PE_CommonModel_Hits]  DEFAULT ((0)) FOR [Hits]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_DayHits]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_DayHits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_DayHits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] ADD  CONSTRAINT [DF_PE_CommonModel_DayHits]  DEFAULT ((0)) FOR [DayHits]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_WeekHits]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_WeekHits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_WeekHits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] ADD  CONSTRAINT [DF_PE_CommonModel_WeekHits]  DEFAULT ((0)) FOR [WeekHits]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_MonthHits]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_MonthHits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_MonthHits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] ADD  CONSTRAINT [DF_PE_CommonModel_MonthHits]  DEFAULT ((0)) FOR [MonthHits]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_LinkType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_LinkType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_LinkType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] ADD  CONSTRAINT [DF_PE_CommonModel_LinkType]  DEFAULT ((0)) FOR [LinkType]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_CommentAudited]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_CommentAudited]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_CommentAudited]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] ADD  CONSTRAINT [DF_PE_CommonModel_CommentAudited]  DEFAULT ((0)) FOR [CommentAudited]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_CommentUnAudited]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_CommentUnAudited]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_CommentUnAudited]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] ADD  CONSTRAINT [DF_PE_CommonModel_CommentUnAudited]  DEFAULT ((0)) FOR [CommentUnAudited]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_SigninType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_SigninType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_SigninType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] ADD  CONSTRAINT [DF_PE_CommonModel_SigninType]  DEFAULT ((0)) FOR [SigninType]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_SGType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_SGType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_SGType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] ADD  CONSTRAINT [DF_PE_CommonModel_SGType]  DEFAULT ((0)) FOR [SGType]
END


End
GO
/****** Object:  Default [DF_PE_CommonModel_SGDataId]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonModel_SGDataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonModel]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonModel_SGDataId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonModel] ADD  CONSTRAINT [DF_PE_CommonModel_SGDataId]  DEFAULT ((0)) FOR [SGDataId]
END


End
GO
/****** Object:  Default [DF_PE_CommonProduct_ProductCharacter]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CommonProduct_ProductCharacter]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CommonProduct]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CommonProduct_ProductCharacter]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CommonProduct] ADD  CONSTRAINT [DF_PE_CommonProduct_ProductCharacter]  DEFAULT ((0)) FOR [ProductCharacter]
END


End
GO
/****** Object:  Default [DF_PE_Company_CompanyID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Company_CompanyID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Company]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Company_CompanyID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Company] ADD  CONSTRAINT [DF_PE_Company_CompanyID]  DEFAULT ((0)) FOR [CompanyID]
END


End
GO
/****** Object:  Default [DF_PE_Company_ClientID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Company_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Company]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Company_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Company] ADD  CONSTRAINT [DF_PE_Company_ClientID]  DEFAULT ((0)) FOR [ClientID]
END


End
GO
/****** Object:  Default [DF_PE_Company_StatusInField]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Company_StatusInField]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Company]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Company_StatusInField]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Company] ADD  CONSTRAINT [DF_PE_Company_StatusInField]  DEFAULT ((0)) FOR [StatusInField]
END


End
GO
/****** Object:  Default [DF_PE_Company_CompanySize]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Company_CompanySize]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Company]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Company_CompanySize]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Company] ADD  CONSTRAINT [DF_PE_Company_CompanySize]  DEFAULT ((0)) FOR [CompanySize]
END


End
GO
/****** Object:  Default [DF_PE_Company_ManagementForms]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Company_ManagementForms]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Company]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Company_ManagementForms]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Company] ADD  CONSTRAINT [DF_PE_Company_ManagementForms]  DEFAULT ((0)) FOR [ManagementForms]
END


End
GO
/****** Object:  Default [DF_PE_ComplainItem_ClientID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ComplainItem_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ComplainItem_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ComplainItem] ADD  CONSTRAINT [DF_PE_ComplainItem_ClientID]  DEFAULT ((0)) FOR [ClientID]
END


End
GO
/****** Object:  Default [DF_PE_ComplainItem_ContacterID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ComplainItem_ContacterID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ComplainItem_ContacterID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ComplainItem] ADD  CONSTRAINT [DF_PE_ComplainItem_ContacterID]  DEFAULT ((0)) FOR [ContacterID]
END


End
GO
/****** Object:  Default [DF_PE_ComplainItem_ComplainType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ComplainItem_ComplainType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ComplainItem_ComplainType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ComplainItem] ADD  CONSTRAINT [DF_PE_ComplainItem_ComplainType]  DEFAULT ((0)) FOR [ComplainType]
END


End
GO
/****** Object:  Default [DF_PE_ComplainItem_ComplainMode]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ComplainItem_ComplainMode]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ComplainItem_ComplainMode]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ComplainItem] ADD  CONSTRAINT [DF_PE_ComplainItem_ComplainMode]  DEFAULT ((0)) FOR [ComplainMode]
END


End
GO
/****** Object:  Default [DF_PE_ComplainItem_MagnitudeOfExigence]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ComplainItem_MagnitudeOfExigence]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ComplainItem_MagnitudeOfExigence]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ComplainItem] ADD  CONSTRAINT [DF_PE_ComplainItem_MagnitudeOfExigence]  DEFAULT ((0)) FOR [MagnitudeOfExigence]
END


End
GO
/****** Object:  Default [DF_PE_ComplainItem_ConfirmScore]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ComplainItem_ConfirmScore]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ComplainItem_ConfirmScore]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ComplainItem] ADD  CONSTRAINT [DF_PE_ComplainItem_ConfirmScore]  DEFAULT ((0)) FOR [ConfirmScore]
END


End
GO
/****** Object:  Default [DF_PE_ComplainItem_Status]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ComplainItem_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ComplainItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ComplainItem_Status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ComplainItem] ADD  CONSTRAINT [DF_PE_ComplainItem_Status]  DEFAULT ((0)) FOR [Status]
END


End
GO
/****** Object:  Default [DF_PE_Contacter_ContacterID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Contacter_ContacterID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Contacter]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Contacter_ContacterID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Contacter] ADD  CONSTRAINT [DF_PE_Contacter_ContacterID]  DEFAULT ((0)) FOR [ContacterID]
END


End
GO
/****** Object:  Default [DF_PE_Contacter_ClientID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Contacter_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Contacter]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Contacter_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Contacter] ADD  CONSTRAINT [DF_PE_Contacter_ClientID]  DEFAULT ((0)) FOR [ClientID]
END


End
GO
/****** Object:  Default [DF_PE_Contacter_ParentID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Contacter_ParentID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Contacter]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Contacter_ParentID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Contacter] ADD  CONSTRAINT [DF_PE_Contacter_ParentID]  DEFAULT ((0)) FOR [ParentID]
END


End
GO
/****** Object:  Default [DF_PE_Contacter_Education]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Contacter_Education]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Contacter]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Contacter_Education]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Contacter] ADD  CONSTRAINT [DF_PE_Contacter_Education]  DEFAULT ((0)) FOR [Education]
END


End
GO
/****** Object:  Default [DF_PE_ContentCharge_ChargeType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentCharge_ChargeType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ContentCharge]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentCharge_ChargeType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ContentCharge] ADD  CONSTRAINT [DF_PE_ContentCharge_ChargeType]  DEFAULT ((0)) FOR [ChargeType]
END


End
GO
/****** Object:  Default [DF_PE_ContentCharge_InfoPoint]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentCharge_InfoPoint]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ContentCharge]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentCharge_InfoPoint]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ContentCharge] ADD  CONSTRAINT [DF_PE_ContentCharge_InfoPoint]  DEFAULT ((0)) FOR [InfoPoint]
END


End
GO
/****** Object:  Default [DF_PE_ContentCharge_DividePercent]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentCharge_DividePercent]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ContentCharge]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentCharge_DividePercent]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ContentCharge] ADD  CONSTRAINT [DF_PE_ContentCharge_DividePercent]  DEFAULT ((0)) FOR [DividePercent]
END


End
GO
/****** Object:  Default [DF_PE_ContentPermission_GeneralId]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentPermission_GeneralId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ContentPermission]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentPermission_GeneralId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ContentPermission] ADD  CONSTRAINT [DF_PE_ContentPermission_GeneralId]  DEFAULT ((0)) FOR [GeneralID]
END


End
GO
/****** Object:  Default [DF_PE_ContentPermission_PermissionType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentPermission_PermissionType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ContentPermission]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentPermission_PermissionType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ContentPermission] ADD  CONSTRAINT [DF_PE_ContentPermission_PermissionType]  DEFAULT ((0)) FOR [PermissionType]
END


End
GO
/****** Object:  Default [DF_PE_CouponItem_OrderID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_CouponItem_OrderID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_CouponItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_CouponItem_OrderID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_CouponItem] ADD  CONSTRAINT [DF_PE_CouponItem_OrderID]  DEFAULT ((0)) FOR [OrderID]
END


End
GO
/****** Object:  Default [DF_PE_DeliverCharge_DeliverTypeID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverCharge_DeliverTypeID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverCharge_DeliverTypeID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverCharge] ADD  CONSTRAINT [DF_PE_DeliverCharge_DeliverTypeID]  DEFAULT ((0)) FOR [DeliverTypeID]
END


End
GO
/****** Object:  Default [DF_PE_DeliverCharge_AreaType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverCharge_AreaType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverCharge_AreaType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverCharge] ADD  CONSTRAINT [DF_PE_DeliverCharge_AreaType]  DEFAULT ((0)) FOR [AreaType]
END


End
GO
/****** Object:  Default [DF_PE_DeliverCharge_Charge_Min]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverCharge_Charge_Min]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverCharge_Charge_Min]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverCharge] ADD  CONSTRAINT [DF_PE_DeliverCharge_Charge_Min]  DEFAULT ((0)) FOR [Charge_Min]
END


End
GO
/****** Object:  Default [DF_PE_DeliverCharge_Weight_Min]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverCharge_Weight_Min]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverCharge_Weight_Min]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverCharge] ADD  CONSTRAINT [DF_PE_DeliverCharge_Weight_Min]  DEFAULT ((0)) FOR [Weight_Min]
END


End
GO
/****** Object:  Default [DF_PE_DeliverCharge_ChargePerUnit]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverCharge_ChargePerUnit]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverCharge_ChargePerUnit]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverCharge] ADD  CONSTRAINT [DF_PE_DeliverCharge_ChargePerUnit]  DEFAULT ((0)) FOR [ChargePerUnit]
END


End
GO
/****** Object:  Default [DF_PE_DeliverCharge_WeightPerUnit]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverCharge_WeightPerUnit]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverCharge_WeightPerUnit]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverCharge] ADD  CONSTRAINT [DF_PE_DeliverCharge_WeightPerUnit]  DEFAULT ((0)) FOR [WeightPerUnit]
END


End
GO
/****** Object:  Default [DF_PE_DeliverCharge_Charge_Max]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverCharge_Charge_Max]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverCharge]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverCharge_Charge_Max]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverCharge] ADD  CONSTRAINT [DF_PE_DeliverCharge_Charge_Max]  DEFAULT ((0)) FOR [Charge_Max]
END


End
GO
/****** Object:  Default [DF_PE_DeliverItem_OrderID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverItem_OrderID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverItem_OrderID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverItem] ADD  CONSTRAINT [DF_PE_DeliverItem_OrderID]  DEFAULT ((0)) FOR [OrderID]
END


End
GO
/****** Object:  Default [DF_PE_DeliverItem_DeliverDirection]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverItem_DeliverDirection]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverItem_DeliverDirection]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverItem] ADD  CONSTRAINT [DF_PE_DeliverItem_DeliverDirection]  DEFAULT ((0)) FOR [DeliverDirection]
END


End
GO
/****** Object:  Default [DF_PE_DeliverItem_Received]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverItem_Received]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverItem_Received]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverItem] ADD  CONSTRAINT [DF_PE_DeliverItem_Received]  DEFAULT ((0)) FOR [Received]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_ChargeType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_ChargeType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_ChargeType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_ChargeType]  DEFAULT ((0)) FOR [ChargeType]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_IsDefault]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_IsDefault]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_IsDefault]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_IsDefault]  DEFAULT ((0)) FOR [IsDefault]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_IsDisabled]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_IsDisabled]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_IsDisabled]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_IsDisabled]  DEFAULT ((0)) FOR [IsDisabled]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_OrderID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_OrderID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_OrderID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_OrderID]  DEFAULT ((0)) FOR [OrderID]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_ReleaseType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_ReleaseType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_ReleaseType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_ReleaseType]  DEFAULT ((0)) FOR [ReleaseType]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_MinMoney1]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_MinMoney1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_MinMoney1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_MinMoney1]  DEFAULT ((0)) FOR [MinMoney1]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_ReleaseCharge]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_ReleaseCharge]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_ReleaseCharge]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_ReleaseCharge]  DEFAULT ((0)) FOR [ReleaseCharge]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_Minmoney2]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_Minmoney2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_Minmoney2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_Minmoney2]  DEFAULT ((0)) FOR [Minmoney2]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_MaxCharge]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_MaxCharge]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_MaxCharge]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_MaxCharge]  DEFAULT ((0)) FOR [MaxCharge]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_MinMoney3]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_MinMoney3]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_MinMoney3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_MinMoney3]  DEFAULT ((0)) FOR [MinMoney3]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_Charge_Min]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_Charge_Min]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_Charge_Min]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_Charge_Min]  DEFAULT ((0)) FOR [Charge_Min]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_Charge_Max]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_Charge_Max]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_Charge_Max]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_Charge_Max]  DEFAULT ((0)) FOR [Charge_Max]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_Charge_Percent]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_Charge_Percent]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_Charge_Percent]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_Charge_Percent]  DEFAULT ((0)) FOR [Charge_Percent]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_IncludeTax]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_IncludeTax]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_IncludeTax]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_IncludeTax]  DEFAULT ((0)) FOR [IncludeTax]
END


End
GO
/****** Object:  Default [DF_PE_DeliverType_TaxRate]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_DeliverType_TaxRate]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_DeliverType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_DeliverType_TaxRate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_DeliverType] ADD  CONSTRAINT [DF_PE_DeliverType_TaxRate]  DEFAULT ((0)) FOR [TaxRate]
END


End
GO
/****** Object:  Default [DF_PE_Indent_Status]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Indent_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Indent]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Indent_Status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Indent] ADD  CONSTRAINT [DF_PE_Indent_Status]  DEFAULT ((0)) FOR [Status]
END


End
GO
/****** Object:  Default [DF_PE_InfoFileRelation_InfoID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_InfoFileRelation_InfoID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_InfoFileRelation]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_InfoFileRelation_InfoID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_InfoFileRelation] ADD  CONSTRAINT [DF_PE_InfoFileRelation_InfoID]  DEFAULT ((0)) FOR [InfoID]
END


End
GO
/****** Object:  Default [DF_PE_InvoiceItem_ClientID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_InvoiceItem_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_InvoiceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_InvoiceItem_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_InvoiceItem] ADD  CONSTRAINT [DF_PE_InvoiceItem_ClientID]  DEFAULT ((0)) FOR [ClientID]
END


End
GO
/****** Object:  Default [DF_PE_InvoiceItem_OrderFormID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_InvoiceItem_OrderFormID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_InvoiceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_InvoiceItem_OrderFormID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_InvoiceItem] ADD  CONSTRAINT [DF_PE_InvoiceItem_OrderFormID]  DEFAULT ((0)) FOR [OrderID]
END


End
GO
/****** Object:  Default [DF_PE_InvoiceItem_InvoiceType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_InvoiceItem_InvoiceType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_InvoiceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_InvoiceItem_InvoiceType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_InvoiceItem] ADD  CONSTRAINT [DF_PE_InvoiceItem_InvoiceType]  DEFAULT ((0)) FOR [InvoiceType]
END


End
GO
/****** Object:  Default [DF_PE_Keywords_Priority]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Keywords_Priority]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Keywords]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Keywords_Priority]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Keywords] ADD  CONSTRAINT [DF_PE_Keywords_Priority]  DEFAULT ((0)) FOR [Priority]
END


End
GO
/****** Object:  Default [DF_PE_Keywords_Hits]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Keywords_Hits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Keywords]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Keywords_Hits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Keywords] ADD  CONSTRAINT [DF_PE_Keywords_Hits]  DEFAULT ((0)) FOR [Hits]
END


End
GO
/****** Object:  Default [DF_PE_Keywords_LastUseTime]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Keywords_LastUseTime]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Keywords]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Keywords_LastUseTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Keywords] ADD  CONSTRAINT [DF_PE_Keywords_LastUseTime]  DEFAULT (getdate()) FOR [LastUseTime]
END


End
GO
/****** Object:  Default [DF_PE_Log_Priority]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Log_Priority]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Log]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Log_Priority]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Log] ADD  CONSTRAINT [DF_PE_Log_Priority]  DEFAULT ((0)) FOR [Priority]
END


End
GO
/****** Object:  Default [DF_PE_ContentModel_Disabled]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentModel_Disabled]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Model]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentModel_Disabled]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Model] ADD  CONSTRAINT [DF_PE_ContentModel_Disabled]  DEFAULT ((0)) FOR [Disabled]
END


End
GO
/****** Object:  Default [DF_PE_ContentModel_EnableCharge]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentModel_EnableCharge]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Model]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentModel_EnableCharge]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Model] ADD  CONSTRAINT [DF_PE_ContentModel_EnableCharge]  DEFAULT ((0)) FOR [EnableCharge]
END


End
GO
/****** Object:  Default [DF_PE_ContentModel_EnableSignin]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ContentModel_EnableSignin]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Model]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ContentModel_EnableSignin]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Model] ADD  CONSTRAINT [DF_PE_ContentModel_EnableSignin]  DEFAULT ((0)) FOR [EnableSignin]
END


End
GO
/****** Object:  Default [DF_PE_Model_MaxPerUser]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Model_MaxPerUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Model]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Model_MaxPerUser]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Model] ADD  CONSTRAINT [DF_PE_Model_MaxPerUser]  DEFAULT ((0)) FOR [MaxPerUser]
END


End
GO
/****** Object:  Default [DF_PE_ModelTemplates_IsEshop]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ModelTemplates_IsEshop]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ModelTemplates]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ModelTemplates_IsEshop]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ModelTemplates] ADD  CONSTRAINT [DF_PE_ModelTemplates_IsEshop]  DEFAULT ((0)) FOR [IsEshop]
END


End
GO
/****** Object:  Default [DF_Mood_M0]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M0]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M0]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M0]  DEFAULT ((0)) FOR [M0]
END


End
GO
/****** Object:  Default [DF_Mood_M1]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M1]  DEFAULT ((0)) FOR [M1]
END


End
GO
/****** Object:  Default [DF_Mood_M2]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M2]  DEFAULT ((0)) FOR [M2]
END


End
GO
/****** Object:  Default [DF_Mood_M3]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M3]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M3]  DEFAULT ((0)) FOR [M3]
END


End
GO
/****** Object:  Default [DF_Mood_M4]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M4]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M4]  DEFAULT ((0)) FOR [M4]
END


End
GO
/****** Object:  Default [DF_Mood_M5]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M5]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M5]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M5]  DEFAULT ((0)) FOR [M5]
END


End
GO
/****** Object:  Default [DF_Mood_M6]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M6]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M6]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M6]  DEFAULT ((0)) FOR [M6]
END


End
GO
/****** Object:  Default [DF_Mood_M7]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M7]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M7]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M7]  DEFAULT ((0)) FOR [M7]
END


End
GO
/****** Object:  Default [DF_Mood_M8]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M8]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M8]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M8]  DEFAULT ((0)) FOR [M8]
END


End
GO
/****** Object:  Default [DF_Mood_M9]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M9]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M9]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M9]  DEFAULT ((0)) FOR [M9]
END


End
GO
/****** Object:  Default [DF_Mood_M10]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M10]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M10]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M10]  DEFAULT ((0)) FOR [M10]
END


End
GO
/****** Object:  Default [DF_Mood_M11]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M11]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M11]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M11]  DEFAULT ((0)) FOR [M11]
END


End
GO
/****** Object:  Default [DF_Mood_M12]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M12]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M12]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M12]  DEFAULT ((0)) FOR [M12]
END


End
GO
/****** Object:  Default [DF_Mood_M13]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M13]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M13]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M13]  DEFAULT ((0)) FOR [M13]
END


End
GO
/****** Object:  Default [DF_Mood_M14]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M14]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M14]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M14]  DEFAULT ((0)) FOR [M14]
END


End
GO
/****** Object:  Default [DF_Mood_M15]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M15]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M15]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M15]  DEFAULT ((0)) FOR [M15]
END


End
GO
/****** Object:  Default [DF_Mood_M16]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M16]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M16]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M16]  DEFAULT ((0)) FOR [M16]
END


End
GO
/****** Object:  Default [DF_Mood_M17]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M17]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M17]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M17]  DEFAULT ((0)) FOR [M17]
END


End
GO
/****** Object:  Default [DF_Mood_M18]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M18]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M18]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M18]  DEFAULT ((0)) FOR [M18]
END


End
GO
/****** Object:  Default [DF_Mood_M19]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Mood_M19]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Mood]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Mood_M19]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Mood] ADD  CONSTRAINT [DF_Mood_M19]  DEFAULT ((0)) FOR [M19]
END


End
GO
/****** Object:  Default [DF_PE_Nodes_IncrementalUpdatePages]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Nodes_IncrementalUpdatePages]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Nodes]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Nodes_IncrementalUpdatePages]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Nodes] ADD  CONSTRAINT [DF_PE_Nodes_IncrementalUpdatePages]  DEFAULT ((0)) FOR [IncrementalUpdatePages]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_ItemID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_ItemID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_ItemID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderFormItem_ItemID]  DEFAULT ((0)) FOR [ItemID]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_OrderFormID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_OrderFormID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_OrderFormID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderFormItem_OrderFormID]  DEFAULT ((0)) FOR [OrderID]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_ProductID]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_ProductID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_ProductID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderFormItem_ProductID]  DEFAULT ((0)) FOR [ProductID]
END


End
GO
/****** Object:  Default [DF_PE_OrderItem_TableName]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderItem_TableName]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderItem_TableName]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderItem_TableName]  DEFAULT ('') FOR [TableName]
END


End
GO
/****** Object:  Default [DF_PE_OrderItem_Property]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderItem_Property]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderItem_Property]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderItem_Property]  DEFAULT ('') FOR [Property]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_SaleType]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_SaleType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_SaleType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderFormItem_SaleType]  DEFAULT ((0)) FOR [SaleType]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_Price_Original]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_Price_Original]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_Price_Original]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderFormItem_Price_Original]  DEFAULT ((0)) FOR [Price_Market]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_Price]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_Price]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_Price]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderFormItem_Price]  DEFAULT ((0)) FOR [Price]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_TruePrice]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_TruePrice]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_TruePrice]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderFormItem_TruePrice]  DEFAULT ((0)) FOR [TruePrice]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_Amount]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_Amount]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_Amount]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderFormItem_Amount]  DEFAULT ((0)) FOR [Amount]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_SubTotal]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_SubTotal]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_SubTotal]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderFormItem_SubTotal]  DEFAULT ((0)) FOR [SubTotal]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_ServiceTerm]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_ServiceTerm]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_ServiceTerm]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderFormItem_ServiceTerm]  DEFAULT ((0)) FOR [ServiceTerm]
END


End
GO
/****** Object:  Default [DF_PE_OrderItem_ServiceTermUnit]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderItem_ServiceTermUnit]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderItem_ServiceTermUnit]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderItem_ServiceTermUnit]  DEFAULT ((0)) FOR [ServiceTermUnit]
END


End
GO
/****** Object:  Default [DF_PE_OrderItem_Remark]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderItem_Remark]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderItem_Remark]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderItem_Remark]  DEFAULT ('') FOR [Remark]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_PresentMoney]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_PresentMoney]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_PresentMoney]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderFormItem_PresentMoney]  DEFAULT ((0)) FOR [PresentMoney]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_PresentPoint]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_PresentPoint]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_PresentPoint]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderFormItem_PresentPoint]  DEFAULT ((0)) FOR [PresentPoint]
END


End
GO
/****** Object:  Default [DF_PE_OrderFormItem_PresentExp]    Script Date: 01/19/2017 15:37:17 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_OrderFormItem_PresentExp]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_OrderItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_OrderFormItem_PresentExp]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_OrderItem] ADD  CONSTRAINT [DF_PE_OrderFormItem_PresentExp]  DEFAULT ((0)) FOR [PresentExp]
END


End
GO
/****** Object:  Default [DF_PE_Orders_OrderNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_OrderNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_OrderNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] ADD  CONSTRAINT [DF_PE_Orders_OrderNum]  DEFAULT ('') FOR [OrderNum]
END


End
GO
/****** Object:  Default [DF_PE_Orders_UserName]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_UserName]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_UserName]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] ADD  CONSTRAINT [DF_PE_Orders_UserName]  DEFAULT ('') FOR [UserName]
END


End
GO
/****** Object:  Default [DF_PE_Orders_AgentName]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_AgentName]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_AgentName]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] ADD  CONSTRAINT [DF_PE_Orders_AgentName]  DEFAULT ('') FOR [AgentName]
END


End
GO
/****** Object:  Default [DF_PE_Orders_InvoiceContent]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_InvoiceContent]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_InvoiceContent]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] ADD  CONSTRAINT [DF_PE_Orders_InvoiceContent]  DEFAULT ('') FOR [InvoiceContent]
END


End
GO
/****** Object:  Default [DF_PE_Orders_Status]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_Status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] ADD  CONSTRAINT [DF_PE_Orders_Status]  DEFAULT ((0)) FOR [Status]
END


End
GO
/****** Object:  Default [DF_PE_Orders_OrderType]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_OrderType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_OrderType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] ADD  CONSTRAINT [DF_PE_Orders_OrderType]  DEFAULT ((0)) FOR [OrderType]
END


End
GO
/****** Object:  Default [DF_PE_Orders_CouponID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_CouponID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_CouponID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] ADD  CONSTRAINT [DF_PE_Orders_CouponID]  DEFAULT ((0)) FOR [CouponID]
END


End
GO
/****** Object:  Default [DF_PE_Orders_OrderKind]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Orders_OrderKind]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Orders]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Orders_OrderKind]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Orders] ADD  CONSTRAINT [DF_PE_Orders_OrderKind]  DEFAULT ((0)) FOR [OrderKind]
END


End
GO
/****** Object:  Default [DF_PE_Package_PackageWeight]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Package_PackageWeight]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Package]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Package_PackageWeight]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Package] ADD  CONSTRAINT [DF_PE_Package_PackageWeight]  DEFAULT ((0)) FOR [PackageWeight]
END


End
GO
/****** Object:  Default [DF_PE_Package_GoodsWeightMax]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Package_GoodsWeightMax]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Package]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Package_GoodsWeightMax]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Package] ADD  CONSTRAINT [DF_PE_Package_GoodsWeightMax]  DEFAULT ((0)) FOR [GoodsWeightMin]
END


End
GO
/****** Object:  Default [DF_PE_Package_GoodsWeightMax_1]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Package_GoodsWeightMax_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Package]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Package_GoodsWeightMax_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Package] ADD  CONSTRAINT [DF_PE_Package_GoodsWeightMax_1]  DEFAULT ((0)) FOR [GoodsWeightMax]
END


End
GO
/****** Object:  Default [DF_PE_PaymentType_Discount]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PaymentType_Discount]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PaymentType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PaymentType_Discount]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PaymentType] ADD  CONSTRAINT [DF_PE_PaymentType_Discount]  DEFAULT ((0)) FOR [Discount]
END


End
GO
/****** Object:  Default [DF_PE_PaymentType_IsDefault]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PaymentType_IsDefault]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PaymentType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PaymentType_IsDefault]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PaymentType] ADD  CONSTRAINT [DF_PE_PaymentType_IsDefault]  DEFAULT ((0)) FOR [IsDefault]
END


End
GO
/****** Object:  Default [DF_PE_PaymentType_IsDisabled]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PaymentType_IsDisabled]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PaymentType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PaymentType_IsDisabled]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PaymentType] ADD  CONSTRAINT [DF_PE_PaymentType_IsDisabled]  DEFAULT ((0)) FOR [IsDisabled]
END


End
GO
/****** Object:  Default [DF_PE_PaymentType_Category]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PaymentType_Category]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PaymentType]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PaymentType_Category]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PaymentType] ADD  CONSTRAINT [DF_PE_PaymentType_Category]  DEFAULT ((0)) FOR [Category]
END


End
GO
/****** Object:  Default [DF_PE_PM_CommissionDetail_GatheringID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_CommissionDetail_GatheringID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_CommissionDetail]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_CommissionDetail_GatheringID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_CommissionDetail] ADD  CONSTRAINT [DF_PE_PM_CommissionDetail_GatheringID]  DEFAULT ((0)) FOR [GatheringID]
END


End
GO
/****** Object:  Default [DF_PE_PM_CommissionDetail_CommissionType]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_CommissionDetail_CommissionType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_CommissionDetail]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_CommissionDetail_CommissionType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_CommissionDetail] ADD  CONSTRAINT [DF_PE_PM_CommissionDetail_CommissionType]  DEFAULT ((0)) FOR [CommissionType]
END


End
GO
/****** Object:  Default [DF_PE_PM_CommissionDetail_Rate]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_CommissionDetail_Rate]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_CommissionDetail]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_CommissionDetail_Rate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_CommissionDetail] ADD  CONSTRAINT [DF_PE_PM_CommissionDetail_Rate]  DEFAULT ((0)) FOR [Rate]
END


End
GO
/****** Object:  Default [DF_PE_PM_CommissionDetail_Property]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_CommissionDetail_Property]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_CommissionDetail]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_CommissionDetail_Property]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_CommissionDetail] ADD  CONSTRAINT [DF_PE_PM_CommissionDetail_Property]  DEFAULT ('') FOR [Property]
END


End
GO
/****** Object:  Default [DF_PE_PM_GatheringDetail_State]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_GatheringDetail_State]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_GatheringDetail]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_GatheringDetail_State]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_GatheringDetail] ADD  CONSTRAINT [DF_PE_PM_GatheringDetail_State]  DEFAULT ((0)) FOR [State]
END


End
GO
/****** Object:  Default [DF_PE_PM_Promotion_CommissionType]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_Promotion_CommissionType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_Promotion]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_Promotion_CommissionType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_Promotion] ADD  CONSTRAINT [DF_PE_PM_Promotion_CommissionType]  DEFAULT ((0)) FOR [CommissionType]
END


End
GO
/****** Object:  Default [DF_PE_PM_Promotion_Rate]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_Promotion_Rate]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_Promotion]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_Promotion_Rate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_Promotion] ADD  CONSTRAINT [DF_PE_PM_Promotion_Rate]  DEFAULT ((0)) FOR [Rate]
END


End
GO
/****** Object:  Default [DF_PE_PM_RegisterPromotion_GatheringID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PM_RegisterPromotion_GatheringID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PM_RegisterPromotion]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PM_RegisterPromotion_GatheringID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PM_RegisterPromotion] ADD  CONSTRAINT [DF_PE_PM_RegisterPromotion_GatheringID]  DEFAULT ((0)) FOR [GatheringID]
END


End
GO
/****** Object:  Default [DF_PE_PointLog_InfoId]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PointLog_InfoId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PointLog]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PointLog_InfoId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PointLog] ADD  CONSTRAINT [DF_PE_PointLog_InfoId]  DEFAULT ((0)) FOR [InfoID]
END


End
GO
/****** Object:  Default [DF_PE_PointLog_Point]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PointLog_Point]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PointLog]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PointLog_Point]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PointLog] ADD  CONSTRAINT [DF_PE_PointLog_Point]  DEFAULT ((0)) FOR [Point]
END


End
GO
/****** Object:  Default [DF_PE_PointLog_LogTime]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PointLog_LogTime]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PointLog]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PointLog_LogTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PointLog] ADD  CONSTRAINT [DF_PE_PointLog_LogTime]  DEFAULT (getdate()) FOR [LogTime]
END


End
GO
/****** Object:  Default [DF_PE_PointLog_Times]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PointLog_Times]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PointLog]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PointLog_Times]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PointLog] ADD  CONSTRAINT [DF_PE_PointLog_Times]  DEFAULT ((0)) FOR [Times]
END


End
GO
/****** Object:  Default [DF_PE_PointLog_IncomePayOut]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_PointLog_IncomePayOut]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_PointLog]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_PointLog_IncomePayOut]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_PointLog] ADD  CONSTRAINT [DF_PE_PointLog_IncomePayOut]  DEFAULT ((0)) FOR [IncomePayOut]
END


End
GO
/****** Object:  Default [DF_PE_Present_OrderNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Present_OrderNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Present]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Present_OrderNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Present] ADD  CONSTRAINT [DF_PE_Present_OrderNum]  DEFAULT ((0)) FOR [OrderNum]
END


End
GO
/****** Object:  Default [DF_PE_Producer_ProducerType_1]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Producer_ProducerType_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Producer]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Producer_ProducerType_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Producer] ADD  CONSTRAINT [DF_PE_Producer_ProducerType_1]  DEFAULT ((0)) FOR [ProducerType]
END


End
GO
/****** Object:  Default [DF_PE_Producer_Passed]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Producer_Passed]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Producer]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Producer_Passed]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Producer] ADD  CONSTRAINT [DF_PE_Producer_Passed]  DEFAULT ((0)) FOR [Passed]
END


End
GO
/****** Object:  Default [DF_PE_Producer_onTop]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Producer_onTop]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Producer]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Producer_onTop]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Producer] ADD  CONSTRAINT [DF_PE_Producer_onTop]  DEFAULT ((0)) FOR [onTop]
END


End
GO
/****** Object:  Default [DF_PE_Producer_IsElite]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Producer_IsElite]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Producer]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Producer_IsElite]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Producer] ADD  CONSTRAINT [DF_PE_Producer_IsElite]  DEFAULT ((0)) FOR [IsElite]
END


End
GO
/****** Object:  Default [DF_PE_Producer_Hits]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Producer_Hits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Producer]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Producer_Hits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Producer] ADD  CONSTRAINT [DF_PE_Producer_Hits]  DEFAULT ((0)) FOR [Hits]
END


End
GO
/****** Object:  Default [DF_PE_ProductData_ProductID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ProductData_ProductID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ProductData]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ProductData_ProductID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ProductData] ADD  CONSTRAINT [DF_PE_ProductData_ProductID]  DEFAULT ((0)) FOR [ProductID]
END


End
GO
/****** Object:  Default [DF_PE_ProductData_Stocks]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ProductData_Stocks]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ProductData]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ProductData_Stocks]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ProductData] ADD  CONSTRAINT [DF_PE_ProductData_Stocks]  DEFAULT ((0)) FOR [Stocks]
END


End
GO
/****** Object:  Default [DF_PE_ProductData_OrderNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ProductData_OrderNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ProductData]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ProductData_OrderNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ProductData] ADD  CONSTRAINT [DF_PE_ProductData_OrderNum]  DEFAULT ((0)) FOR [OrderNum]
END


End
GO
/****** Object:  Default [DF_PE_ProductData_AlarmNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ProductData_AlarmNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ProductData]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ProductData_AlarmNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ProductData] ADD  CONSTRAINT [DF_PE_ProductData_AlarmNum]  DEFAULT ((0)) FOR [AlarmNum]
END


End
GO
/****** Object:  Default [DF_PE_ProductData_BuyTimes]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ProductData_BuyTimes]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ProductData]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ProductData_BuyTimes]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ProductData] ADD  CONSTRAINT [DF_PE_ProductData_BuyTimes]  DEFAULT ((0)) FOR [BuyTimes]
END


End
GO
/****** Object:  Default [DF_PE_Provider_ProviderID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Provider_ProviderID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Provider]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Provider_ProviderID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Provider] ADD  CONSTRAINT [DF_PE_Provider_ProviderID]  DEFAULT ((0)) FOR [ProviderID]
END


End
GO
/****** Object:  Default [DF_PE_Region_Country]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Region_Country]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Region]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Region_Country]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Region] ADD  CONSTRAINT [DF_PE_Region_Country]  DEFAULT ('') FOR [Country]
END


End
GO
/****** Object:  Default [DF_PE_Region_Province]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Region_Province]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Region]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Region_Province]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Region] ADD  CONSTRAINT [DF_PE_Region_Province]  DEFAULT ('') FOR [Province]
END


End
GO
/****** Object:  Default [DF_PE_Region_City]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Region_City]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Region]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Region_City]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Region] ADD  CONSTRAINT [DF_PE_Region_City]  DEFAULT ('') FOR [City]
END


End
GO
/****** Object:  Default [DF_PE_Region_Area]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Region_Area]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Region]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Region_Area]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Region] ADD  CONSTRAINT [DF_PE_Region_Area]  DEFAULT ('') FOR [Area]
END


End
GO
/****** Object:  Default [DF_PE_Region_PostCode]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Region_PostCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Region]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Region_PostCode]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Region] ADD  CONSTRAINT [DF_PE_Region_PostCode]  DEFAULT ('') FOR [PostCode]
END


End
GO
/****** Object:  Default [DF_PE_Region_AreaCode]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Region_AreaCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Region]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Region_AreaCode]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Region] ADD  CONSTRAINT [DF_PE_Region_AreaCode]  DEFAULT ('') FOR [AreaCode]
END


End
GO
/****** Object:  Default [DF_PE_ServiceItem_ClientID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ServiceItem_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ServiceItem_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ServiceItem] ADD  CONSTRAINT [DF_PE_ServiceItem_ClientID]  DEFAULT ((0)) FOR [ClientID]
END


End
GO
/****** Object:  Default [DF_PE_ServiceItem_ContacterID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ServiceItem_ContacterID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ServiceItem_ContacterID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ServiceItem] ADD  CONSTRAINT [DF_PE_ServiceItem_ContacterID]  DEFAULT ((0)) FOR [ContacterID]
END


End
GO
/****** Object:  Default [DF_PE_ServiceItem_OrderID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ServiceItem_OrderID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ServiceItem_OrderID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ServiceItem] ADD  CONSTRAINT [DF_PE_ServiceItem_OrderID]  DEFAULT ((0)) FOR [OrderID]
END


End
GO
/****** Object:  Default [DF_PE_ServiceItem_ServiceResult]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ServiceItem_ServiceResult]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ServiceItem_ServiceResult]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ServiceItem] ADD  CONSTRAINT [DF_PE_ServiceItem_ServiceResult]  DEFAULT ((0)) FOR [ServiceResult]
END


End
GO
/****** Object:  Default [DF_PE_ServiceItem_TakeTime]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ServiceItem_TakeTime]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ServiceItem_TakeTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ServiceItem] ADD  CONSTRAINT [DF_PE_ServiceItem_TakeTime]  DEFAULT ((0)) FOR [TakeTime]
END


End
GO
/****** Object:  Default [DF_PE_ServiceItem_ServicePoint]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ServiceItem_ServicePoint]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ServiceItem_ServicePoint]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ServiceItem] ADD  CONSTRAINT [DF_PE_ServiceItem_ServicePoint]  DEFAULT ((0)) FOR [ServicePoint]
END


End
GO
/****** Object:  Default [DF_PE_ServiceItem_ConfirmScore]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ServiceItem_ConfirmScore]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ServiceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ServiceItem_ConfirmScore]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ServiceItem] ADD  CONSTRAINT [DF_PE_ServiceItem_ConfirmScore]  DEFAULT ((0)) FOR [ConfirmScore]
END


End
GO
/****** Object:  Default [DF_PE_ShoppingCarts_ProductID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ShoppingCarts_ProductID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ShoppingCarts_ProductID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ShoppingCarts] ADD  CONSTRAINT [DF_PE_ShoppingCarts_ProductID]  DEFAULT ((0)) FOR [ProductID]
END


End
GO
/****** Object:  Default [DF_PE_ShoppingCarts_Quantity]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ShoppingCarts_Quantity]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ShoppingCarts_Quantity]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ShoppingCarts] ADD  CONSTRAINT [DF_PE_ShoppingCarts_Quantity]  DEFAULT ((0)) FOR [Quantity]
END


End
GO
/****** Object:  Default [DF_PE_ShoppingCarts_PresentID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ShoppingCarts_PresentID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ShoppingCarts_PresentID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ShoppingCarts] ADD  CONSTRAINT [DF_PE_ShoppingCarts_PresentID]  DEFAULT ((0)) FOR [IsPresent]
END


End
GO
/****** Object:  Default [DF_PE_ShoppingCarts_InformResult]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ShoppingCarts_InformResult]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ShoppingCarts_InformResult]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ShoppingCarts] ADD  CONSTRAINT [DF_PE_ShoppingCarts_InformResult]  DEFAULT ((0)) FOR [InformResult]
END


End
GO
/****** Object:  Default [DF_PE_ShoppingCarts_BelongsToProductID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ShoppingCarts_BelongsToProductID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ShoppingCarts]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ShoppingCarts_BelongsToProductID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ShoppingCarts] ADD  CONSTRAINT [DF_PE_ShoppingCarts_BelongsToProductID]  DEFAULT ((0)) FOR [BelongsToProductID]
END


End
GO
/****** Object:  Default [DF_PE_Source_Type]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Source_Type]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Source]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Source_Type]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Source] ADD  CONSTRAINT [DF_PE_Source_Type]  DEFAULT ((0)) FOR [Type]
END


End
GO
/****** Object:  Default [DF_PE_Source_Passed]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Source_Passed]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Source]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Source_Passed]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Source] ADD  CONSTRAINT [DF_PE_Source_Passed]  DEFAULT ((0)) FOR [Passed]
END


End
GO
/****** Object:  Default [DF_PE_Source_onTop]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Source_onTop]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Source]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Source_onTop]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Source] ADD  CONSTRAINT [DF_PE_Source_onTop]  DEFAULT ((0)) FOR [onTop]
END


End
GO
/****** Object:  Default [DF_PE_Source_IsElite]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Source_IsElite]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Source]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Source_IsElite]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Source] ADD  CONSTRAINT [DF_PE_Source_IsElite]  DEFAULT ((0)) FOR [IsElite]
END


End
GO
/****** Object:  Default [DF_PE_Source_Hits]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Source_Hits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Source]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Source_Hits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Source] ADD  CONSTRAINT [DF_PE_Source_Hits]  DEFAULT ((0)) FOR [Hits]
END


End
GO
/****** Object:  Default [DF_PE_StatAddress_TAddNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatAddress_TAddNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatAddress]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatAddress_TAddNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatAddress] ADD  CONSTRAINT [DF_PE_StatAddress_TAddNum]  DEFAULT ((0)) FOR [TAddNum]
END


End
GO
/****** Object:  Default [DF_PE_StatBrowser_TBrwNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatBrowser_TBrwNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatBrowser]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatBrowser_TBrwNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatBrowser] ADD  CONSTRAINT [DF_PE_StatBrowser_TBrwNum]  DEFAULT ((0)) FOR [TBrwNum]
END


End
GO
/****** Object:  Default [DF_PE_StatColor_TColNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatColor_TColNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatColor]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatColor_TColNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatColor] ADD  CONSTRAINT [DF_PE_StatColor_TColNum]  DEFAULT ((0)) FOR [TColNum]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_0]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_0]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_0]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_0]  DEFAULT ((0)) FOR [0]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_1]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_1]  DEFAULT ((0)) FOR [1]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_2]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_2]  DEFAULT ((0)) FOR [2]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_3]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_3]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_3]  DEFAULT ((0)) FOR [3]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_4]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_4]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_4]  DEFAULT ((0)) FOR [4]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_5]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_5]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_5]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_5]  DEFAULT ((0)) FOR [5]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_6]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_6]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_6]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_6]  DEFAULT ((0)) FOR [6]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_7]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_7]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_7]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_7]  DEFAULT ((0)) FOR [7]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_8]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_8]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_8]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_8]  DEFAULT ((0)) FOR [8]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_9]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_9]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_9]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_9]  DEFAULT ((0)) FOR [9]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_10]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_10]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_10]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_10]  DEFAULT ((0)) FOR [10]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_11]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_11]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_11]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_11]  DEFAULT ((0)) FOR [11]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_12]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_12]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_12]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_12]  DEFAULT ((0)) FOR [12]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_13]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_13]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_13]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_13]  DEFAULT ((0)) FOR [13]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_14]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_14]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_14]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_14]  DEFAULT ((0)) FOR [14]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_15]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_15]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_15]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_15]  DEFAULT ((0)) FOR [15]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_16]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_16]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_16]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_16]  DEFAULT ((0)) FOR [16]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_17]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_17]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_17]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_17]  DEFAULT ((0)) FOR [17]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_18]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_18]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_18]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_18]  DEFAULT ((0)) FOR [18]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_19]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_19]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_19]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_19]  DEFAULT ((0)) FOR [19]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_20]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_20]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_20]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_20]  DEFAULT ((0)) FOR [20]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_21]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_21]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_21]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_21]  DEFAULT ((0)) FOR [21]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_22]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_22]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_22]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_22]  DEFAULT ((0)) FOR [22]
END


End
GO
/****** Object:  Default [DF_PE_StatDay_23]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatDay_23]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatDay]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatDay_23]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatDay] ADD  CONSTRAINT [DF_PE_StatDay_23]  DEFAULT ((0)) FOR [23]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_TotalNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_TotalNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_TotalNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_TotalNum]  DEFAULT ((0)) FOR [TotalNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_TotalView]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_TotalView]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_TotalView]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_TotalView]  DEFAULT ((0)) FOR [TotalView]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_MonthNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_MonthNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_MonthNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_MonthNum]  DEFAULT ((0)) FOR [MonthNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_MonthMaxNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_MonthMaxNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_MonthMaxNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_MonthMaxNum]  DEFAULT ((0)) FOR [MonthMaxNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_DayNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_DayNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_DayNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_DayNum]  DEFAULT ((0)) FOR [DayNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_DayMaxNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_DayMaxNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_DayMaxNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_DayMaxNum]  DEFAULT ((0)) FOR [DayMaxNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_HourNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_HourNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_HourNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_HourNum]  DEFAULT ((0)) FOR [HourNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_HourMaxNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_HourMaxNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_HourMaxNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_HourMaxNum]  DEFAULT ((0)) FOR [HourMaxNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_ChinaNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_ChinaNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_ChinaNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_ChinaNum]  DEFAULT ((0)) FOR [ChinaNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_OtherNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_OtherNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_OtherNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_OtherNum]  DEFAULT ((0)) FOR [OtherNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_MasterTimeZone]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_MasterTimeZone]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_MasterTimeZone]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_MasterTimeZone]  DEFAULT ((0)) FOR [MasterTimeZone]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_IntervalNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_IntervalNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_IntervalNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_IntervalNum]  DEFAULT ((0)) FOR [IntervalNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_OnlineTime]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_OnlineTime]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_OnlineTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_OnlineTime]  DEFAULT ((0)) FOR [OnlineTime]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_VisitRecord]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_VisitRecord]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_VisitRecord]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_VisitRecord]  DEFAULT ((0)) FOR [VisitRecord]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_KillRefresh]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_KillRefresh]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_KillRefresh]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_KillRefresh]  DEFAULT ((0)) FOR [KillRefresh]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_OldTotalNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_OldTotalNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_OldTotalNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_OldTotalNum]  DEFAULT ((0)) FOR [OldTotalNum]
END


End
GO
/****** Object:  Default [DF_PE_StatInfoList_OldTotalView]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatInfoList_OldTotalView]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatInfoList]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatInfoList_OldTotalView]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatInfoList] ADD  CONSTRAINT [DF_PE_StatInfoList_OldTotalView]  DEFAULT ((0)) FOR [OldTotalView]
END


End
GO
/****** Object:  Default [DF_PE_StatIp_TIpNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatIp_TIpNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatIp]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatIp_TIpNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatIp] ADD  CONSTRAINT [DF_PE_StatIp_TIpNum]  DEFAULT ((0)) FOR [TIpNum]
END


End
GO
/****** Object:  Default [DF_PE_StatKeyword_TKeywordNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatKeyword_TKeywordNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatKeyword]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatKeyword_TKeywordNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatKeyword] ADD  CONSTRAINT [DF_PE_StatKeyword_TKeywordNum]  DEFAULT ((0)) FOR [TKeywordNum]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_1]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_1]  DEFAULT ((0)) FOR [1]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_2]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_2]  DEFAULT ((0)) FOR [2]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_3]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_3]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_3]  DEFAULT ((0)) FOR [3]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_4]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_4]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_4]  DEFAULT ((0)) FOR [4]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_5]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_5]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_5]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_5]  DEFAULT ((0)) FOR [5]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_6]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_6]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_6]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_6]  DEFAULT ((0)) FOR [6]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_7]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_7]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_7]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_7]  DEFAULT ((0)) FOR [7]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_8]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_8]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_8]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_8]  DEFAULT ((0)) FOR [8]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_9]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_9]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_9]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_9]  DEFAULT ((0)) FOR [9]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_10]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_10]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_10]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_10]  DEFAULT ((0)) FOR [10]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_11]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_11]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_11]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_11]  DEFAULT ((0)) FOR [11]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_12]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_12]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_12]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_12]  DEFAULT ((0)) FOR [12]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_13]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_13]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_13]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_13]  DEFAULT ((0)) FOR [13]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_14]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_14]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_14]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_14]  DEFAULT ((0)) FOR [14]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_15]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_15]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_15]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_15]  DEFAULT ((0)) FOR [15]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_16]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_16]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_16]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_16]  DEFAULT ((0)) FOR [16]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_17]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_17]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_17]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_17]  DEFAULT ((0)) FOR [17]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_18]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_18]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_18]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_18]  DEFAULT ((0)) FOR [18]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_19]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_19]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_19]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_19]  DEFAULT ((0)) FOR [19]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_20]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_20]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_20]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_20]  DEFAULT ((0)) FOR [20]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_21]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_21]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_21]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_21]  DEFAULT ((0)) FOR [21]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_22]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_22]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_22]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_22]  DEFAULT ((0)) FOR [22]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_23]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_23]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_23]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_23]  DEFAULT ((0)) FOR [23]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_24]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_24]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_24]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_24]  DEFAULT ((0)) FOR [24]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_25]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_25]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_25]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_25]  DEFAULT ((0)) FOR [25]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_26]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_26]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_26]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_26]  DEFAULT ((0)) FOR [26]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_27]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_27]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_27]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_27]  DEFAULT ((0)) FOR [27]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_28]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_28]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_28]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_28]  DEFAULT ((0)) FOR [28]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_29]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_29]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_29]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_29]  DEFAULT ((0)) FOR [29]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_30]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_30]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_30]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_30]  DEFAULT ((0)) FOR [30]
END


End
GO
/****** Object:  Default [DF_PE_StatMonth_31]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMonth_31]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMonth]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMonth_31]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMonth] ADD  CONSTRAINT [DF_PE_StatMonth_31]  DEFAULT ((0)) FOR [31]
END


End
GO
/****** Object:  Default [DF_PE_StatMozilla_TMozNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatMozilla_TMozNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatMozilla]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatMozilla_TMozNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatMozilla] ADD  CONSTRAINT [DF_PE_StatMozilla_TMozNum]  DEFAULT ((0)) FOR [TMozNum]
END


End
GO
/****** Object:  Default [DF_PE_StatRefer_TRefNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatRefer_TRefNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatRefer]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatRefer_TRefNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatRefer] ADD  CONSTRAINT [DF_PE_StatRefer_TRefNum]  DEFAULT ((0)) FOR [TRefNum]
END


End
GO
/****** Object:  Default [DF_PE_StatScreen_TScrNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatScreen_TScrNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatScreen]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatScreen_TScrNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatScreen] ADD  CONSTRAINT [DF_PE_StatScreen_TScrNum]  DEFAULT ((0)) FOR [TScrNum]
END


End
GO
/****** Object:  Default [DF_PE_StatSystem_TSysNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatSystem_TSysNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatSystem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatSystem_TSysNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatSystem] ADD  CONSTRAINT [DF_PE_StatSystem_TSysNum]  DEFAULT ((0)) FOR [TSysNum]
END


End
GO
/****** Object:  Default [DF_PE_StatTimezone_TTimNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatTimezone_TTimNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatTimezone]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatTimezone_TTimNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatTimezone] ADD  CONSTRAINT [DF_PE_StatTimezone_TTimNum]  DEFAULT ((0)) FOR [TTimNum]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_1]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] ADD  CONSTRAINT [DF_PE_StatVisit_1]  DEFAULT ((0)) FOR [1]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_2]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] ADD  CONSTRAINT [DF_PE_StatVisit_2]  DEFAULT ((0)) FOR [2]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_3]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_3]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] ADD  CONSTRAINT [DF_PE_StatVisit_3]  DEFAULT ((0)) FOR [3]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_4]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_4]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] ADD  CONSTRAINT [DF_PE_StatVisit_4]  DEFAULT ((0)) FOR [4]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_5]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_5]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_5]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] ADD  CONSTRAINT [DF_PE_StatVisit_5]  DEFAULT ((0)) FOR [5]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_6]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_6]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_6]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] ADD  CONSTRAINT [DF_PE_StatVisit_6]  DEFAULT ((0)) FOR [6]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_7]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_7]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_7]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] ADD  CONSTRAINT [DF_PE_StatVisit_7]  DEFAULT ((0)) FOR [7]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_8]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_8]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_8]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] ADD  CONSTRAINT [DF_PE_StatVisit_8]  DEFAULT ((0)) FOR [8]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_9]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_9]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_9]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] ADD  CONSTRAINT [DF_PE_StatVisit_9]  DEFAULT ((0)) FOR [9]
END


End
GO
/****** Object:  Default [DF_PE_StatVisit_10]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisit_10]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisit]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisit_10]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisit] ADD  CONSTRAINT [DF_PE_StatVisit_10]  DEFAULT ((0)) FOR [10]
END


End
GO
/****** Object:  Default [DF_PE_StatVisitor_Timezone]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatVisitor_Timezone]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatVisitor]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatVisitor_Timezone]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatVisitor] ADD  CONSTRAINT [DF_PE_StatVisitor_Timezone]  DEFAULT ((0)) FOR [Timezone]
END


End
GO
/****** Object:  Default [DF_PE_StatWeburl_TWebNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeburl_TWebNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeburl]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeburl_TWebNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeburl] ADD  CONSTRAINT [DF_PE_StatWeburl_TWebNum]  DEFAULT ((0)) FOR [TWebNum]
END


End
GO
/****** Object:  Default [DF_PE_StatWeek_1]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeek_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeek_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeek] ADD  CONSTRAINT [DF_PE_StatWeek_1]  DEFAULT ((0)) FOR [1]
END


End
GO
/****** Object:  Default [DF_PE_StatWeek_2]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeek_2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeek_2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeek] ADD  CONSTRAINT [DF_PE_StatWeek_2]  DEFAULT ((0)) FOR [2]
END


End
GO
/****** Object:  Default [DF_PE_StatWeek_3]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeek_3]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeek_3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeek] ADD  CONSTRAINT [DF_PE_StatWeek_3]  DEFAULT ((0)) FOR [3]
END


End
GO
/****** Object:  Default [DF_PE_StatWeek_4]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeek_4]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeek_4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeek] ADD  CONSTRAINT [DF_PE_StatWeek_4]  DEFAULT ((0)) FOR [4]
END


End
GO
/****** Object:  Default [DF_PE_StatWeek_5]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeek_5]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeek_5]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeek] ADD  CONSTRAINT [DF_PE_StatWeek_5]  DEFAULT ((0)) FOR [5]
END


End
GO
/****** Object:  Default [DF_PE_StatWeek_6]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeek_6]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeek_6]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeek] ADD  CONSTRAINT [DF_PE_StatWeek_6]  DEFAULT ((0)) FOR [6]
END


End
GO
/****** Object:  Default [DF_PE_StatWeek_7]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatWeek_7]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatWeek]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatWeek_7]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatWeek] ADD  CONSTRAINT [DF_PE_StatWeek_7]  DEFAULT ((0)) FOR [7]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_1]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] ADD  CONSTRAINT [DF_PE_StatYear_1]  DEFAULT ((0)) FOR [1]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_2]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] ADD  CONSTRAINT [DF_PE_StatYear_2]  DEFAULT ((0)) FOR [2]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_3]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_3]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] ADD  CONSTRAINT [DF_PE_StatYear_3]  DEFAULT ((0)) FOR [3]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_4]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_4]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] ADD  CONSTRAINT [DF_PE_StatYear_4]  DEFAULT ((0)) FOR [4]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_5]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_5]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_5]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] ADD  CONSTRAINT [DF_PE_StatYear_5]  DEFAULT ((0)) FOR [5]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_6]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_6]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_6]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] ADD  CONSTRAINT [DF_PE_StatYear_6]  DEFAULT ((0)) FOR [6]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_7]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_7]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_7]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] ADD  CONSTRAINT [DF_PE_StatYear_7]  DEFAULT ((0)) FOR [7]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_8]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_8]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_8]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] ADD  CONSTRAINT [DF_PE_StatYear_8]  DEFAULT ((0)) FOR [8]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_9]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_9]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_9]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] ADD  CONSTRAINT [DF_PE_StatYear_9]  DEFAULT ((0)) FOR [9]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_10]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_10]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_10]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] ADD  CONSTRAINT [DF_PE_StatYear_10]  DEFAULT ((0)) FOR [10]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_11]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_11]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_11]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] ADD  CONSTRAINT [DF_PE_StatYear_11]  DEFAULT ((0)) FOR [11]
END


End
GO
/****** Object:  Default [DF_PE_StatYear_12]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StatYear_12]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StatYear]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StatYear_12]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StatYear] ADD  CONSTRAINT [DF_PE_StatYear_12]  DEFAULT ((0)) FOR [12]
END


End
GO
/****** Object:  Default [DF_PE_Stock_ID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Stock_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Stock]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Stock_ID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Stock] ADD  CONSTRAINT [DF_PE_Stock_ID]  DEFAULT ((0)) FOR [StockID]
END


End
GO
/****** Object:  Default [DF_PE_Stock_StockType]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Stock_StockType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Stock]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Stock_StockType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Stock] ADD  CONSTRAINT [DF_PE_Stock_StockType]  DEFAULT ((0)) FOR [StockType]
END


End
GO
/****** Object:  Default [DF_PE_Stock_Status]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Stock_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Stock]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Stock_Status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Stock] ADD  CONSTRAINT [DF_PE_Stock_Status]  DEFAULT ((0)) FOR [Status]
END


End
GO
/****** Object:  Default [DF_PE_StockItem_Amount]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StockItem_Amount]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StockItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StockItem_Amount]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StockItem] ADD  CONSTRAINT [DF_PE_StockItem_Amount]  DEFAULT ((0)) FOR [Amount]
END


End
GO
/****** Object:  Default [DF_PE_StockItem_Price]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_StockItem_Price]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_StockItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_StockItem_Price]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_StockItem] ADD  CONSTRAINT [DF_PE_StockItem_Price]  DEFAULT ((0)) FOR [Price]
END


End
GO
/****** Object:  Default [DF_PE_Survey_IPRepeat]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Survey_IPRepeat]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Survey]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Survey_IPRepeat]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Survey] ADD  CONSTRAINT [DF_PE_Survey_IPRepeat]  DEFAULT ((0)) FOR [IPRepeat]
END


End
GO
/****** Object:  Default [DF_PE_Survey_IsOpen]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Survey_IsOpen]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Survey]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Survey_IsOpen]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Survey] ADD  CONSTRAINT [DF_PE_Survey_IsOpen]  DEFAULT ((0)) FOR [IsOpen]
END


End
GO
/****** Object:  Default [DF_PE_Survey_NeedLogin]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Survey_NeedLogin]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Survey]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Survey_NeedLogin]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Survey] ADD  CONSTRAINT [DF_PE_Survey_NeedLogin]  DEFAULT ((0)) FOR [NeedLogin]
END


End
GO
/****** Object:  Default [DF_PE_Survey_LockIPType]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Survey_LockIPType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Survey]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Survey_LockIPType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Survey] ADD  CONSTRAINT [DF_PE_Survey_LockIPType]  DEFAULT ((0)) FOR [LockIPType]
END


End
GO
/****** Object:  Default [DF_PE_Survey_TemplateID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Survey_TemplateID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Survey]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Survey_TemplateID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Survey] ADD  CONSTRAINT [DF_PE_Survey_TemplateID]  DEFAULT ((0)) FOR [Template]
END


End
GO
/****** Object:  Default [DF_PE_Survey_QuestionMaxId]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Survey_QuestionMaxId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Survey]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Survey_QuestionMaxId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Survey] ADD  CONSTRAINT [DF_PE_Survey_QuestionMaxId]  DEFAULT ((0)) FOR [QuestionMaxID]
END


End
GO
/****** Object:  Default [DF_PE_Survey_IsResultPublic]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Survey_IsResultPublic]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Survey]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Survey_IsResultPublic]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Survey] ADD  CONSTRAINT [DF_PE_Survey_IsResultPublic]  DEFAULT ((1)) FOR [IsResultPublic]
END


End
GO
/****** Object:  Default [DF_PE_SurveyVote_SurveyId]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_SurveyVote_SurveyId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_SurveyVote]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_SurveyVote_SurveyId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_SurveyVote] ADD  CONSTRAINT [DF_PE_SurveyVote_SurveyId]  DEFAULT ((0)) FOR [SurveyID]
END


End
GO
/****** Object:  Default [DF_PE_SurveyVote_QuestionId]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_SurveyVote_QuestionId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_SurveyVote]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_SurveyVote_QuestionId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_SurveyVote] ADD  CONSTRAINT [DF_PE_SurveyVote_QuestionId]  DEFAULT ((0)) FOR [QuestionID]
END


End
GO
/****** Object:  Default [DF_PE_SurveyVote_OptionId]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_SurveyVote_OptionId]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_SurveyVote]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_SurveyVote_OptionId]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_SurveyVote] ADD  CONSTRAINT [DF_PE_SurveyVote_OptionId]  DEFAULT ((0)) FOR [OptionID]
END


End
GO
/****** Object:  Default [DF_PE_SurveyVote_VoteAmount]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_SurveyVote_VoteAmount]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_SurveyVote]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_SurveyVote_VoteAmount]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_SurveyVote] ADD  CONSTRAINT [DF_PE_SurveyVote_VoteAmount]  DEFAULT ((0)) FOR [VoteAmount]
END


End
GO
/****** Object:  Default [DF_PE_Trademark_TrademarkType]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Trademark_TrademarkType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Trademark]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Trademark_TrademarkType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Trademark] ADD  CONSTRAINT [DF_PE_Trademark_TrademarkType]  DEFAULT ((0)) FOR [TrademarkType]
END


End
GO
/****** Object:  Default [DF_PE_Trademark_ProducerID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Trademark_ProducerID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Trademark]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Trademark_ProducerID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Trademark] ADD  CONSTRAINT [DF_PE_Trademark_ProducerID]  DEFAULT ((0)) FOR [ProducerID]
END


End
GO
/****** Object:  Default [DF_PE_Trademark_Passed]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Trademark_Passed]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Trademark]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Trademark_Passed]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Trademark] ADD  CONSTRAINT [DF_PE_Trademark_Passed]  DEFAULT ((1)) FOR [Passed]
END


End
GO
/****** Object:  Default [DF_PE_Trademark_onTop]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Trademark_onTop]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Trademark]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Trademark_onTop]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Trademark] ADD  CONSTRAINT [DF_PE_Trademark_onTop]  DEFAULT ((0)) FOR [onTop]
END


End
GO
/****** Object:  Default [DF_PE_Trademark_IsElite]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Trademark_IsElite]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Trademark]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Trademark_IsElite]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Trademark] ADD  CONSTRAINT [DF_PE_Trademark_IsElite]  DEFAULT ((0)) FOR [IsElite]
END


End
GO
/****** Object:  Default [DF_PE_Trademark_Hits]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Trademark_Hits]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Trademark]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Trademark_Hits]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Trademark] ADD  CONSTRAINT [DF_PE_Trademark_Hits]  DEFAULT ((0)) FOR [Hits]
END


End
GO
/****** Object:  Default [DF_PE_UserExpLog_ExpNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_UserExpLog_ExpNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_UserExpLog]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_UserExpLog_ExpNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_UserExpLog] ADD  CONSTRAINT [DF_PE_UserExpLog_ExpNum]  DEFAULT ((0)) FOR [ExpNum]
END


End
GO
/****** Object:  Default [DF_PE_UserExpLog_IncomePayout]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_UserExpLog_IncomePayout]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_UserExpLog]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_UserExpLog_IncomePayout]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_UserExpLog] ADD  CONSTRAINT [DF_PE_UserExpLog_IncomePayout]  DEFAULT ((0)) FOR [IncomePayout]
END


End
GO
/****** Object:  Default [DF_PE_UserExpLog_LogTime]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_UserExpLog_LogTime]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_UserExpLog]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_UserExpLog_LogTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_UserExpLog] ADD  CONSTRAINT [DF_PE_UserExpLog_LogTime]  DEFAULT (getdate()) FOR [LogTime]
END


End
GO
/****** Object:  Default [DF_PE_Users_ClientID]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Users_ClientID]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Users]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Users_ClientID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Users] ADD  CONSTRAINT [DF_PE_Users_ClientID]  DEFAULT ((0)) FOR [ClientID]
END


End
GO
/****** Object:  Default [DF_PE_Users_QAPoint]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_Users_QAPoint]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_Users]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_Users_QAPoint]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_Users] ADD  CONSTRAINT [DF_PE_Users_QAPoint]  DEFAULT ((20)) FOR [QAPoint]
END


End
GO
/****** Object:  Default [DF_PE_ValidLog_ValidNum]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ValidLog_ValidNum]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ValidLog]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ValidLog_ValidNum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ValidLog] ADD  CONSTRAINT [DF_PE_ValidLog_ValidNum]  DEFAULT ((0)) FOR [ValidNum]
END


End
GO
/****** Object:  Default [DF_PE_ValidLog_IncomePayout]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ValidLog_IncomePayout]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ValidLog]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ValidLog_IncomePayout]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ValidLog] ADD  CONSTRAINT [DF_PE_ValidLog_IncomePayout]  DEFAULT ((0)) FOR [IncomePayout]
END


End
GO
/****** Object:  Default [DF_PE_ValidLog_LogTime]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_ValidLog_LogTime]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_ValidLog]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_ValidLog_LogTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_ValidLog] ADD  CONSTRAINT [DF_PE_ValidLog_LogTime]  DEFAULT (getdate()) FOR [LogTime]
END


End
GO
/****** Object:  Default [DF_PE_WordFilter_ReplaceType]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_WordFilter_ReplaceType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_WordReplaceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_WordFilter_ReplaceType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_WordReplaceItem] ADD  CONSTRAINT [DF_PE_WordFilter_ReplaceType]  DEFAULT ((0)) FOR [ReplaceType]
END


End
GO
/****** Object:  Default [DF_PE_WordFilter_ScopesType]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_WordFilter_ScopesType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_WordReplaceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_WordFilter_ScopesType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_WordReplaceItem] ADD  CONSTRAINT [DF_PE_WordFilter_ScopesType]  DEFAULT ((0)) FOR [ScopesType]
END


End
GO
/****** Object:  Default [DF_PE_WordFilter_ReplaceTimes]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_WordFilter_ReplaceTimes]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_WordReplaceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_WordFilter_ReplaceTimes]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_WordReplaceItem] ADD  CONSTRAINT [DF_PE_WordFilter_ReplaceTimes]  DEFAULT ((0)) FOR [ReplaceTimes]
END


End
GO
/****** Object:  Default [DF_PE_WordFilter_Priority]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_WordFilter_Priority]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_WordReplaceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_WordFilter_Priority]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_WordReplaceItem] ADD  CONSTRAINT [DF_PE_WordFilter_Priority]  DEFAULT ((0)) FOR [Priority]
END


End
GO
/****** Object:  Default [DF_PE_WordFilter_OpenType]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_WordFilter_OpenType]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_WordReplaceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_WordFilter_OpenType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_WordReplaceItem] ADD  CONSTRAINT [DF_PE_WordFilter_OpenType]  DEFAULT ((0)) FOR [OpenType]
END


End
GO
/****** Object:  Default [DF_PE_WordFilter_IsEnabled]    Script Date: 01/19/2017 15:37:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_PE_WordFilter_IsEnabled]') AND parent_object_id = OBJECT_ID(N'[dbo].[PE_WordReplaceItem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PE_WordFilter_IsEnabled]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PE_WordReplaceItem] ADD  CONSTRAINT [DF_PE_WordFilter_IsEnabled]  DEFAULT ((0)) FOR [IsEnabled]
END


End
GO
