if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[My_split]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[My_split]
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_ArticleGather_Add]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_ArticleGather_Add]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_ArticleGather_Edit]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_ArticleGather_Edit]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Article_NewArticle]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Article_NewArticle]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Article_XGArticle]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Article_XGArticle]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Class_Add]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Class_Add]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Class_Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Class_Delete]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Class_OrderByMove]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Class_OrderByMove]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Class_Path]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Class_Path]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Class_Show]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Class_Show]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_CountData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_CountData]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Digo_Add]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Digo_Add]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_GuestBook_Add]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_GuestBook_Add]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Log_Add]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Log_Add]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Member_Add]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Member_Add]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Member_TryLogin]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Member_TryLogin]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_PageList]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_PageList]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Product_NewProduct]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Product_NewProduct]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Product_XGProduct]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Product_XGProduct]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_RepaiRights]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_RepaiRights]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_RepalceField]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_RepalceField]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_SoftServer_Add]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_SoftServer_Add]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_SoftServer_Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_SoftServer_Delete]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Soft_DownLoads]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Soft_DownLoads]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Soft_NewSoft]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Soft_NewSoft]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Soft_XGSoft]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Soft_XGSoft]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Special_Add]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Special_Add]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Special_Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Special_Delete]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Special_FindFellowID]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Special_FindFellowID]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Special_OrderByMove]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Special_OrderByMove]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Special_Path]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Special_Path]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Special_Show]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Special_Show]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Tags]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Tags]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Tags_InitData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Tags_InitData]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Templates_UsedIt]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Templates_UsedIt]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Vote_Add]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Vote_Add]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_Words_InitData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_Words_InitData]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_WorkStatDiary_SaveDiary]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_WorkStatDiary_SaveDiary]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[P_TopWinCMS_WorkStatDiary_Total]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_TopWinCMS_WorkStatDiary_Total]
GO
 

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_WorkStatDiary_Article]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_WorkStatDiary_Article]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_AdList]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_AdList]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Article]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Article]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Article_Comment]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Article_Comment]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Article_Digg]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Article_Digg]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Article_DiggDiary]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Article_DiggDiary]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Article_Special]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Article_Special]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Article_Total]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Article_Total]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Business]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Business]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Field]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Field]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Member]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Member]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Product]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Product]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Product_Comment]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Product_Comment]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Product_Digg]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Product_Digg]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Product_DiggDiary]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Product_DiggDiary]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Product_Special]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Product_Special]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Product_Total]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Product_Total]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Soft]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Soft]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_SoftDownList]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_SoftDownList]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Soft_Comment]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Soft_Comment]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Soft_Digg]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Soft_Digg]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Soft_DiggDiary]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Soft_DiggDiary]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Soft_LinkErr]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Soft_LinkErr]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Soft_Total]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Soft_Total]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_Vote]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_Vote]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_WorkStatDiary]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_WorkStatDiary]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VW_TopWinCMS_ArticleGather]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[VW_TopWinCMS_ArticleGather]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_AdList]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_AdList]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Admin]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Admin]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_AdminMenuDefault]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_AdminMenuDefault]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_AdminMenuHead]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_AdminMenuHead]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_AdminRole]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_AdminRole]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Annex]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Annex]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Announce]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Announce]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Article]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Article]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_ArticleGather]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_ArticleGather]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Business]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Business]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Channel]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Channel]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Class]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Class]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Comment]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Comment]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_ContentKeyWord]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_ContentKeyWord]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_ContentProperty]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_ContentProperty]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_CounterContent]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_CounterContent]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_CounterDiary]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_CounterDiary]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Digg]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Digg]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_DiggDiary]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_DiggDiary]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Favorite]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Favorite]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Field]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Field]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_FriendLink]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_FriendLink]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_GuestBook]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_GuestBook]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_HoldAuth]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_HoldAuth]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_HotKeyWords]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_HotKeyWords]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_IPBlackList]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_IPBlackList]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Log]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Log]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Member]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Member]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_MemberRole]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_MemberRole]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Message]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Message]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Model]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Model]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Product]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Product]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Rights]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Rights]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_SecurityCenter]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_SecurityCenter]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Soft]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Soft]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_SoftDownList]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_SoftDownList]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_SoftLinkErr]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_SoftLinkErr]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_SoftServer]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_SoftServer]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Special]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Special]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_TagIndexs]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_TagIndexs]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Tags]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Tags]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Task]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Task]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_TaskActive]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_TaskActive]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Templates]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Templates]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_UDT]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_UDT]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Vote]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Vote]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_VoteChoice]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_VoteChoice]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Words]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Words]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_WorkStatDiary]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_WorkStatDiary]
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE function My_split(@aString varchar(8000),@pattern varchar(10))
returns @temp table([Sid]  [int] IDENTITY (1, 1) NOT NULL ,Myvalues varchar(100))
--实现split功能的函数
--说明：@aString，字符串，如“27,28,29”；@pattern，分隔标志，如“ ,”
--使用select Myvalues FROM my_split(字符串, ',')
as
begin
declare @i int
set @aString=rtrim(ltrim(@aString))
set @i=charindex(@pattern,@aString)
while @i>=1
begin
insert @temp values(left(@aString,@i-1))
set @aString=substring(@aString,@i+1,len(@aString)-@i)
set @i=charindex(@pattern,@aString)
end
if @aString<>''
insert @temp values(@aString)
return
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

CREATE TABLE [dbo].[TopWinCMS_AdList] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[SiteName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[UserName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Contact] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[Ad_Url] [nvarchar] (300) COLLATE Chinese_PRC_CI_AS NULL ,
	[Url] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Width] [int] NOT NULL ,
	[Height] [int] NOT NULL ,
	[Target] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[MaxShowTime] [int] NOT NULL ,
	[MaxClick] [int] NOT NULL ,
	[MaxDateTime] [datetime] NOT NULL ,
	[Show] [int] NULL ,
	[Clicks] [int] NULL ,
	[UpDateTime] [datetime] NOT NULL ,
	[ShowType] [int] NULL ,
	[Remark] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
	[Stop] [bit] NOT NULL ,
	[Note] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Admin] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Password] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[LastLoginIP] [nvarchar] (16) COLLATE Chinese_PRC_CI_AS NULL ,
	[LastLoginTime] [datetime] NULL ,
	[LastLogoutTime] [datetime] NULL ,
	[LoginTimes] [int] NULL ,
	[RoleID] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_AdminMenuDefault] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Title] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Command] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Link] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[UserName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[OrderID] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_AdminMenuHead] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Name] [nvarchar] (16) COLLATE Chinese_PRC_CI_AS NULL ,
	[Command] [nvarchar] (40) COLLATE Chinese_PRC_CI_AS NULL ,
	[Show] [bit] NULL ,
	[MenuGroup] [int] NULL ,
	[OrderID] [int] NULL ,
	[MouseOver] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[Rights] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_AdminRole] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[RoleName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[RolePower] [varchar] (8000) COLLATE Chinese_PRC_CI_AS NULL ,
	[Remark] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Annex] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [tinyint] NULL ,
	[ContentID] [int] NULL ,
	[FileName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[DownURL] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[UpDateTime] [datetime] NULL ,
	[TempFlag] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Announce] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ChannelID] [tinyint] NULL ,
	[Title] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[Content] [text] COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Author] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[DateTime] [datetime] NOT NULL ,
	[Pass] [int] NOT NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Article] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [tinyint] NOT NULL ,
	[SpecialID] [int] NOT NULL ,
	[SpecialName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ClassID] [int] NOT NULL ,
	[ClassName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Title] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Title1] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Brief] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Author] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[From] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Editor] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Key] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Hits] [int] NOT NULL ,
	[UpdateTime] [datetime] NOT NULL ,
	[OnTop] [int] NOT NULL ,
	[Elite] [int] NOT NULL ,
	[Content] [text] COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IncludePic] [int] NOT NULL ,
	[PicUrl] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Deleted] [int] NOT NULL ,
	[Stars] [int] NOT NULL ,
	[Pass] [int] NOT NULL ,
	[ContentPass] [int] NOT NULL ,
	[Gather] [int] NOT NULL ,
	[Rank] [int] NOT NULL ,
	[PointNum] [int] NOT NULL ,
	[ColorStyle] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[FontStyle] [nvarchar] (60) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[AllowComment] [int] NOT NULL ,
	[TemplateFileName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsSlide] [tinyint] NOT NULL ,
	[IsDraft] [tinyint] NOT NULL ,
	[StaticURL] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[test] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[test2] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[test3] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[test5] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_ArticleGather] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Name] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[StartUrl] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[ClassArea] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[Title] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[UpdateTime] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[ComeFrom] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[Author] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[Content] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[ShowArticleUrl] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[ClassNextPage] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[ShowArticleNextUrl] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[GatherNum] [int] NOT NULL ,
	[Filter] [text] COLLATE Chinese_PRC_CI_AS NULL ,
	[Replace] [text] COLLATE Chinese_PRC_CI_AS NULL ,
	[DownImg] [int] NOT NULL ,
	[InCheckTime] [datetime] NOT NULL ,
	[ClassID] [int] NOT NULL ,
	[LastWork] [datetime] NULL ,
	[Pass] [int] NULL ,
	[GatherPicArticle] [int] NULL ,
	[DrawWaterMark] [int] NULL ,
	[IsExpert] [int] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Business] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[MemberID] [int] NULL ,
	[ModelID] [int] NULL ,
	[Indent] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Point] [int] NULL ,
	[PayMoney] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Customer] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[DateTime] [datetime] NULL ,
	[Remark] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[flag] [int] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Channel] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[DomainName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[URL] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[OrderID] [int] NOT NULL ,
	[Target] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Remark] [nvarchar] (300) COLLATE Chinese_PRC_CI_AS NULL ,
	[Show] [int] NULL ,
	[ModelID] [int] NULL ,
	[MetaKeyword] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[MetaDescription] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[CheckInDate] [datetime] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Class] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [tinyint] NULL ,
	[ClassName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[ClassName_EN] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[ParentID] [int] NULL ,
	[RootID] [int] NULL ,
	[OrderID] [int] NULL ,
	[LinkUrl] [nvarchar] (300) COLLATE Chinese_PRC_CI_AS NULL ,
	[Path] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[HaveBaby] [int] NULL ,
	[PicPath] [nvarchar] (300) COLLATE Chinese_PRC_CI_AS NULL ,
	[IsShowInIndex] [int] NULL ,
	[IsShowInHeader] [int] NULL ,
	[TemplateFileName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ContentAdmin] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
	[ClassAdmin] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
	[FilePostfix] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
	[FilePrefix] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
	[URLStyle] [int] NOT NULL ,
	[ClassFilePostfix] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
	[ClassFilePrefix] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
	[ClassURLStyle] [int] NOT NULL ,
	[ClassIntro] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ClassPic] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ClassDescription] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[ClassKeyWord] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[OpenGrade] [int] NULL ,
	[EnableContribute] [int] NULL ,
	[EnableComment] [int] NULL ,
	[StaticURL] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Comment] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [tinyint] NULL ,
	[ContentID] [int] NULL ,
	[WriteTime] [datetime] NULL ,
	[Name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Score] [int] NULL ,
	[Content] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Pass] [int] NULL ,
	[IP] [nvarchar] (16) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_ContentKeyWord] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [tinyint] NULL ,
	[Title] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Url] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Target] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[UpDateTime] [datetime] NULL ,
	[IsClose] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_ContentProperty] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [tinyint] NULL ,
	[Name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[UpDateTime] [datetime] NULL ,
	[Type] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_CounterContent] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Today] [bigint] NULL ,
	[Yesterday] [bigint] NULL ,
	[Date] [datetime] NULL ,
	[Total] [bigint] NULL ,
	[StartTime] [smalldatetime] NULL ,
	[High] [bigint] NULL ,
	[HighTime] [datetime] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_CounterDiary] (
	[ID] [bigint] IDENTITY (1, 1) NOT NULL ,
	[Year] [int] NULL ,
	[Month] [int] NULL ,
	[Day] [int] NULL ,
	[Hour] [int] NULL ,
	[Time] [datetime] NULL ,
	[Week] [int] NULL ,
	[IP] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Where] [nvarchar] (250) COLLATE Chinese_PRC_CI_AS NULL ,
	[Where2] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Come] [nvarchar] (250) COLLATE Chinese_PRC_CI_AS NULL ,
	[Page] [nvarchar] (250) COLLATE Chinese_PRC_CI_AS NULL ,
	[Browser] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[OS] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Resolution] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Digg] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [tinyint] NOT NULL ,
	[ContentID] [int] NOT NULL ,
	[GoodNum] [int] NOT NULL ,
	[BadNum] [int] NOT NULL ,
	[LastUserName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[LastDiggDate] [datetime] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_DiggDiary] (
	[ID] [bigint] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [tinyint] NULL ,
	[ContentID] [int] NULL ,
	[Name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[IsMember] [int] NULL ,
	[CheckInDate] [datetime] NULL ,
	[IsAgree] [tinyint] NULL ,
	[IP] [nvarchar] (16) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Favorite] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Title] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[URL] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[MemberID] [int] NULL ,
	[Visit] [int] NULL ,
	[Updatetime] [datetime] NULL ,
	[LastVisit] [datetime] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Field] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [int] NULL ,
	[FieldName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Title] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Tips] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[FieldType] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[DefaultValue] [nvarchar] (4000) COLLATE Chinese_PRC_CI_AS NULL ,
	[ControlType] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[IsShowInMember] [int] NULL ,
	[OrderID] [int] NULL ,
	[Indispensable] [int] NULL ,
	[Width] [int] NULL ,
	[MaxFieldLength] [int] NULL ,
	[Stop] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_FriendLink] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[FL_Title] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FL_Logo] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[FL_URL] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[OrderID] [int] NOT NULL ,
	[Pass] [int] NOT NULL ,
	[Password] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[UpdateTime] [datetime] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_GuestBook] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[eMail] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[PostTime] [datetime] NULL ,
	[Content] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[IP] [nvarchar] (16) COLLATE Chinese_PRC_CI_AS NULL ,
	[Reply] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[QQ] [nvarchar] (13) COLLATE Chinese_PRC_CI_AS NULL ,
	[Home] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Face] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Humor] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Privacy] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_HoldAuth] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserId] [int] NOT NULL ,
	[BusObId] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ACCode] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[isUserGroup] [bit] NOT NULL ,
	[ClassCode] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FuncId] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[isDefault] [bit] NULL ,
	[pubufts] [timestamp] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_HotKeyWords] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ChannelID] [int] NULL ,
	[KeyWord] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[Hits] [int] NULL ,
	[LastHitTime] [datetime] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_IPBlackList] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[IPStart] [nchar] (16) COLLATE Chinese_PRC_CI_AS NULL ,
	[IPEnd] [nchar] (16) COLLATE Chinese_PRC_CI_AS NULL ,
	[SectorStart] [bigint] NULL ,
	[SectorEnd] [bigint] NULL ,
	[AdminName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[UpDateTime] [datetime] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Log] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Admin] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Type] [nvarchar] (12) COLLATE Chinese_PRC_CI_AS NULL ,
	[Event] [nvarchar] (250) COLLATE Chinese_PRC_CI_AS NULL ,
	[CheckInDate] [datetime] NULL ,
	[Deleted] [bit] NULL ,
	[PageName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Member] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[PSW] [nvarchar] (32) COLLATE Chinese_PRC_CI_AS NULL ,
	[HomePage] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[QQ] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[PetName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Introduce] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[eMail] [nvarchar] (150) COLLATE Chinese_PRC_CI_AS NULL ,
	[Coin] [int] NOT NULL ,
	[Point] [int] NOT NULL ,
	[Experience] [int] NULL ,
	[Mature] [datetime] NULL ,
	[Question] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Answer] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Sex] [int] NOT NULL ,
	[MemberRoleID] [int] NOT NULL ,
	[ActiveType] [int] NULL ,
	[ActiveBBS] [bit] NULL ,
	[ActiveBlog] [bit] NULL ,
	[LastLoginIP] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[RegTime] [datetime] NULL ,
	[LastLoginTime] [datetime] NULL ,
	[IsLocked] [int] NULL ,
	[TrueName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[MSN] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Birthday] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Province] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[City] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[ICQ] [varchar] (12) COLLATE Chinese_PRC_CI_AS NULL ,
	[Yahoo] [varchar] (40) COLLATE Chinese_PRC_CI_AS NULL ,
	[Skype] [varchar] (40) COLLATE Chinese_PRC_CI_AS NULL ,
	[Location] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[IdCard] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[Mobile] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[Phone] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[Address] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_MemberRole] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[RoleName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[RolePower] [text] COLLATE Chinese_PRC_CI_AS NULL ,
	[Rank] [int] NULL ,
	[Remark] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Message] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Sender] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Incept] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Title] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[Content] [nvarchar] (4000) COLLATE Chinese_PRC_CI_AS NULL ,
	[Flag] [int] NOT NULL ,
	[SendTime] [datetime] NOT NULL ,
	[IsRead] [int] NOT NULL ,
	[DelSend] [int] NOT NULL ,
	[CloseTime] [datetime] NULL ,
	[GUID] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Model] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[DataTable] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[BaseModel] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[ContentName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[ContentUnit] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Filter] [nvarchar] (4000) COLLATE Chinese_PRC_CI_AS NULL ,
	[Remark] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[EnableStatic] [int] NULL ,
	[HtmlSavePath] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[MaxClassPageNo] [int] NULL ,
	[AdminUploadPath] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[AdminUploadSize] [int] NULL ,
	[AdminFileTypes] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
	[EnableMemberUpload] [int] NULL ,
	[MemberUploadPath] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[MemberUploadSize] [int] NULL ,
	[MemberFileTypes] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
	[AdminPass] [int] NULL ,
	[CommentAutoPass] [int] NULL ,
	[Contribution] [int] NULL ,
	[SearchOption] [int] NULL ,
	[IsShowNewSign] [int] NULL ,
	[NewSignKeep] [int] NULL ,
	[PageSize] [int] NULL ,
	[PageSizeBackGround] [int] NULL ,
	[TemplateFileName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Hide] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Product] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [tinyint] NOT NULL ,
	[SpecialID] [int] NOT NULL ,
	[SpecialName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ClassID] [int] NOT NULL ,
	[ClassName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ProductName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ProductPrice] [decimal](18, 2) NOT NULL ,
	[Standard] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Packaging] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Brand] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Brief] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Editor] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Key] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Hits] [int] NOT NULL ,
	[UpdateTime] [datetime] NOT NULL ,
	[OnTop] [int] NOT NULL ,
	[Elite] [int] NOT NULL ,
	[Content] [text] COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IncludePic] [int] NOT NULL ,
	[PicUrl] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[BigPicUrl] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Deleted] [int] NOT NULL ,
	[Stars] [int] NOT NULL ,
	[Pass] [int] NOT NULL ,
	[ContentPass] [int] NOT NULL ,
	[Rank] [int] NOT NULL ,
	[PointNum] [int] NOT NULL ,
	[ColorStyle] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[FontStyle] [nvarchar] (60) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[AllowComment] [int] NOT NULL ,
	[TemplateFileName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsSlide] [tinyint] NOT NULL ,
	[IsDraft] [tinyint] NOT NULL ,
	[StaticURL] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Rights] (
	[ID] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ModelID] [varchar] (4) COLLATE Chinese_PRC_CI_AS NULL ,
	[Name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Code] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[RootID] [int] NULL ,
	[OrderID] [int] NULL ,
	[ParentID] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[IsAdmin] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_SecurityCenter] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[FilePath] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Remark] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[UpDateTime] [datetime] NULL ,
	[Type] [int] NULL ,
	[UserName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[IP] [nvarchar] (16) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Soft] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [tinyint] NOT NULL ,
	[SpecialID] [int] NOT NULL ,
	[SpecialName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ClassID] [int] NOT NULL ,
	[ClassName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[SoftName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[SoftVersion] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[SoftSize] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Brief] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Editor] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Key] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[OnTop] [int] NOT NULL ,
	[Elite] [int] NOT NULL ,
	[Content] [text] COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IncludePic] [int] NOT NULL ,
	[DemoUrl] [nvarchar] (300) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Author] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Email] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Homepage] [nvarchar] (300) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[PicUrl] [nvarchar] (300) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[RunAtSystem] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[SoftType] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[SoftLanguage] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[CopyrightType] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Stars] [int] NOT NULL ,
	[Hits] [int] NOT NULL ,
	[DayHits] [int] NOT NULL ,
	[WeekHits] [int] NOT NULL ,
	[MonthHits] [int] NOT NULL ,
	[DecompressPassword] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Deleted] [int] NOT NULL ,
	[UpdateTime] [datetime] NOT NULL ,
	[LastHitTime] [datetime] NOT NULL ,
	[BlackGuard] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Pass] [int] NOT NULL ,
	[ContentPass] [int] NOT NULL ,
	[Gather] [int] NOT NULL ,
	[Rank] [int] NOT NULL ,
	[PointNum] [int] NOT NULL ,
	[ColorStyle] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[FontStyle] [nvarchar] (60) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[AllowComment] [int] NOT NULL ,
	[TemplateFileName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsSlide] [tinyint] NOT NULL ,
	[IsDraft] [tinyint] NOT NULL ,
	[StaticURL] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_SoftDownList] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [int] NULL ,
	[SoftID] [int] NOT NULL ,
	[ServerID] [int] NOT NULL ,
	[FileName] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[DownLinkName] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_SoftLinkErr] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [int] NOT NULL ,
	[SoftID] [int] NOT NULL ,
	[Name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Message] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[IP] [nvarchar] (16) COLLATE Chinese_PRC_CI_AS NULL ,
	[UpDateTime] [datetime] NOT NULL ,
	[Complete] [bit] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_SoftServer] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [int] NULL ,
	[ServerName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[DownURL] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[LinkProperty] [int] NULL ,
	[ParentID] [int] NOT NULL ,
	[RootID] [int] NOT NULL ,
	[OrderID] [int] NOT NULL ,
	[IsLock] [bit] NOT NULL ,
	[ServerHTML] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Special] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [int] NULL ,
	[SpecialName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[SpecialName_EN] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[ParentID] [int] NULL ,
	[RootID] [int] NULL ,
	[OrderID] [int] NULL ,
	[LinkUrl] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Path] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[HaveBaby] [int] NULL ,
	[IsShowInIndex] [int] NULL ,
	[IsShowInHeader] [int] NULL ,
	[TemplateFileName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ContentAdmin] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
	[SpecialAdmin] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
	[SpecialFilePostfix] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
	[SpecialFilePrefix] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
	[SpecialURLStyle] [int] NULL ,
	[SpecialIntro] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[SpecialPic] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[SpecialDescription] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[SpecialKeyWord] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[OpenGrade] [int] NULL ,
	[StaticURL] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_TagIndexs] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [tinyint] NULL ,
	[ContentID] [int] NULL ,
	[TagID] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Tags] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [tinyint] NOT NULL ,
	[TagName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Counts] [bigint] NULL ,
	[ViewCounts] [bigint] NULL ,
	[MemberID] [int] NULL ,
	[Flag] [tinyint] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Task] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[TaskName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[TaskActiveID] [int] NULL ,
	[AwakenTime] [datetime] NULL ,
	[IntervalMinute] [int] NULL ,
	[EveryDayTime] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Week] [int] NULL ,
	[UnexecuteType] [int] NULL ,
	[LastRunTime] [datetime] NULL ,
	[IsUsed] [int] NULL ,
	[DLLName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[FullClassName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[CommandLine] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_TaskActive] (
	[ID] [int] NOT NULL ,
	[Name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Templates] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[TemplateName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[TemplatePath] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[IsUsed] [int] NULL ,
	[Style] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Remark] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[ArticleShow] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ArticleClass] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ArticleSpecial] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ArticleChannelIndex] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ArticleSpecialIndex] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[SoftShow] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[SoftClass] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[SoftSpecial] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[SoftChannelIndex] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[SoftSpecialIndex] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ProductShow] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ProductClass] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ProductSpecial] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ProductChannelIndex] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ProductSpecialIndex] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_UDT] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[DataType] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[DataSource] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
	[SqlScript] [varchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
	[Type] [int] NULL ,
	[JsPath] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Stop] [int] NULL ,
	[URLType] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[ShortTitle] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Length] [int] NULL ,
	[ItemTemplet] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[EmptyTemplet] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[Remark] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[CheckInDate] [datetime] NULL ,
	[Tag] [nvarchar] (4000) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Vote] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Title] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Pass] [int] NULL ,
	[DataTime] [datetime] NULL ,
	[VoteType] [int] NULL ,
	[PicUrl] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[EndData] [datetime] NULL ,
	[windowsize] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[TemplateFileName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[LimitIP] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_VoteChoice] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ChoiceTitle] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[VoteNum] [int] NULL ,
	[PicUrl] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[IsDefault] [int] NULL ,
	[VoteID] [int] NULL ,
	[OrderID] [char] (10) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_Words] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Find] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Replacement] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Ban] [int] NULL ,
	[AdminName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[UpDateTime] [datetime] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TopWinCMS_WorkStatDiary] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModelID] [tinyint] NULL ,
	[UserName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Stat] [int] NULL ,
	[DayStat] [int] NULL ,
	[WeekStat] [int] NULL ,
	[MonthStat] [int] NULL ,
	[YearStat] [int] NULL ,
	[Type] [int] NULL ,
	[LastTime] [datetime] NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TopWinCMS_AdList] WITH NOCHECK ADD 
	CONSTRAINT [PK_Ads] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Admin] WITH NOCHECK ADD 
	CONSTRAINT [PK_Admin] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_AdminMenuDefault] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_AdminMenuDefault] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_AdminMenuHead] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_AdminMenuHead] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_AdminRole] WITH NOCHECK ADD 
	CONSTRAINT [PK_UserRole] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Annex] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Annex] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Announce] WITH NOCHECK ADD 
	CONSTRAINT [PK_Announce] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Article] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Article] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_ArticleGather] WITH NOCHECK ADD 
	CONSTRAINT [PK_ArticleGather] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Business] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Business.aspx] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Channel] WITH NOCHECK ADD 
	CONSTRAINT [PK_Channel] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Class] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Class] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Comment] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Comment] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_ContentKeyWord] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_ContentKeyWord] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_ContentProperty] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_ContentProperty] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_CounterContent] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_CounterContent] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_CounterDiary] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_CounterDiary] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Digg] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Digg] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_DiggDiary] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_DiggDiary] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Favorite] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Favorite] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Field] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Field] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_FriendLink] WITH NOCHECK ADD 
	CONSTRAINT [PK_FriendLink] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_GuestBook] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_GuestBook] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_HoldAuth] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_HoldAuth] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_HotKeyWords] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_HotKeyWords] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_IPBlackList] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_IPBlackList] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Log] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Log] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Member] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS] PRIMARY KEY  CLUSTERED 
	(
		[ID],
		[Name]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_MemberRole] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_MemberRole] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Message] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Message] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Model] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Model] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Product] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Product] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Rights] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Rights] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_SecurityCenter] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_SecurityCenter] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Soft] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Soft] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_SoftDownList] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_SoftDownList] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_SoftLinkErr] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_SoftLinkErr] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_SoftServer] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_SoftServer] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Special] WITH NOCHECK ADD 
	CONSTRAINT [PK_Special] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_TagIndexs] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_TagsIndex] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Tags] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Tags] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Task] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Task] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_TaskActive] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_TaskActive] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Templates] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Templates] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_UDT] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_UDT] PRIMARY KEY  CLUSTERED 
	(
		[ID],
		[Name]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Vote] WITH NOCHECK ADD 
	CONSTRAINT [PK_Vote] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_VoteChoice] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_VoteChoice] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_Words] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_Words] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_WorkStatDiary] WITH NOCHECK ADD 
	CONSTRAINT [PK_TopWinCMS_WorkStatDiary] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TopWinCMS_AdList] ADD 
	CONSTRAINT [DF_AdList_UpDateTime] DEFAULT (getdate()) FOR [UpDateTime]
GO

ALTER TABLE [dbo].[TopWinCMS_Admin] ADD 
	CONSTRAINT [DF_TopWinCMS_Admin_LoginTimes] DEFAULT (0) FOR [LoginTimes]
GO

ALTER TABLE [dbo].[TopWinCMS_Annex] ADD 
	CONSTRAINT [DF_TopWinCMS_Annex_UpDateTime] DEFAULT (getdate()) FOR [UpDateTime]
GO

ALTER TABLE [dbo].[TopWinCMS_Announce] ADD 
	CONSTRAINT [DF_Announce_Pass] DEFAULT (1) FOR [Pass]
GO

 CREATE  INDEX [IX_TopWinCMS_Announce_UpdateTime] ON [dbo].[TopWinCMS_Announce]([DateTime]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TopWinCMS_Article] ADD 
	CONSTRAINT [DF_TopWinCMS_Article_ModelID] DEFAULT (2) FOR [ModelID],
	CONSTRAINT [DF_TopWinCMS_Article_SpecialID] DEFAULT (0) FOR [SpecialID],
	CONSTRAINT [DF_TopWinCMS_Article_SpecialName] DEFAULT ('') FOR [SpecialName],
	CONSTRAINT [DF_TopWinCMS_Article_ClassName] DEFAULT ('') FOR [ClassName],
	CONSTRAINT [DF_TopWinCMS_Article_UpdateTime] DEFAULT (getdate()) FOR [UpdateTime],
	CONSTRAINT [DF_TopWinCMS_Article_OnTop] DEFAULT (0) FOR [OnTop],
	CONSTRAINT [DF_TopWinCMS_Article_Elite] DEFAULT (0) FOR [Elite],
	CONSTRAINT [DF_TopWinCMS_Article_IncludePic] DEFAULT (0) FOR [IncludePic],
	CONSTRAINT [DF_TopWinCMS_Article_PicUrl] DEFAULT ('') FOR [PicUrl],
	CONSTRAINT [DF_TopWinCMS_Article_Deleted] DEFAULT (0) FOR [Deleted],
	CONSTRAINT [DF_TopWinCMS_Article_Stars] DEFAULT (3) FOR [Stars],
	CONSTRAINT [DF_TopWinCMS_Article_Pass] DEFAULT (1) FOR [Pass],
	CONSTRAINT [DF_TopWinCMS_Article_ContentPass] DEFAULT (1) FOR [ContentPass],
	CONSTRAINT [DF_TopWinCMS_Article_MemberRole] DEFAULT (0) FOR [Rank],
	CONSTRAINT [DF_TopWinCMS_Article_PointNum] DEFAULT (0) FOR [PointNum],
	CONSTRAINT [DF_TopWinCMS_Article_AllowComment] DEFAULT (1) FOR [AllowComment],
	CONSTRAINT [DF_TopWinCMS_Article_StaticURL] DEFAULT ('') FOR [StaticURL]
GO

 CREATE  INDEX [IX_TopWinCMS_Article_Hits] ON [dbo].[TopWinCMS_Article]([Hits] DESC ) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_Article_ClassID] ON [dbo].[TopWinCMS_Article]([ClassID]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_Article_UpdateTime] ON [dbo].[TopWinCMS_Article]([UpdateTime] DESC ) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TopWinCMS_ArticleGather] ADD 
	CONSTRAINT [DF_ArticleGather_DownImg] DEFAULT (0) FOR [DownImg],
	CONSTRAINT [DF_ArticleGather_InCheckTime] DEFAULT (getdate()) FOR [InCheckTime],
	CONSTRAINT [DF_TopWinCMS_ArticleGather_IsExpert] DEFAULT (0) FOR [IsExpert]
GO

 CREATE  INDEX [IX_TopWinCMS_flag] ON [dbo].[TopWinCMS_Business]([flag]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TopWinCMS_Channel] ADD 
	CONSTRAINT [DF_TopWinCMS_Channel_CheckInDate] DEFAULT (getdate()) FOR [CheckInDate]
GO

ALTER TABLE [dbo].[TopWinCMS_Class] ADD 
	CONSTRAINT [DF_TopWinCMS_Class_ParentID] DEFAULT (0) FOR [ParentID],
	CONSTRAINT [DF_TopWinCMS_Class_RootID] DEFAULT (0) FOR [RootID],
	CONSTRAINT [DF_TopWinCMS_Class_OrderID] DEFAULT (0) FOR [OrderID],
	CONSTRAINT [DF_TopWinCMS_Class_HaveBaby] DEFAULT (0) FOR [HaveBaby],
	CONSTRAINT [DF_TopWinCMS_Class_IsShowInIndex] DEFAULT (1) FOR [IsShowInIndex],
	CONSTRAINT [DF_TopWinCMS_Class_IsShowInHeader] DEFAULT (1) FOR [IsShowInHeader],
	CONSTRAINT [DF_TopWinCMS_Class_Admin] DEFAULT ('') FOR [ContentAdmin]
GO

ALTER TABLE [dbo].[TopWinCMS_Comment] ADD 
	CONSTRAINT [DF_CommonComment_WriteTime] DEFAULT (getdate()) FOR [WriteTime],
	CONSTRAINT [DF_CommonComment_Pass] DEFAULT (0) FOR [Pass]
GO

 CREATE  INDEX [IX_TopWinCMS_Comment_ContentID] ON [dbo].[TopWinCMS_Comment]([ContentID]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_Comment_WriteTime] ON [dbo].[TopWinCMS_Comment]([WriteTime]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TopWinCMS_ContentKeyWord] ADD 
	CONSTRAINT [DF_TopWinCMS_ContentKeyWord_UpDateTime] DEFAULT (getdate()) FOR [UpDateTime]
GO

ALTER TABLE [dbo].[TopWinCMS_ContentProperty] ADD 
	CONSTRAINT [DF_TopWinCMS_ContentProperty_UpDateTime] DEFAULT (getdate()) FOR [UpDateTime]
GO

 CREATE  INDEX [IX_TopWinCMS_CounterDiary_Year] ON [dbo].[TopWinCMS_CounterDiary]([Year]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_CounterDiary_Month] ON [dbo].[TopWinCMS_CounterDiary]([Month]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_CounterDiary_Day] ON [dbo].[TopWinCMS_CounterDiary]([Day]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_CounterDiary_Hour] ON [dbo].[TopWinCMS_CounterDiary]([Hour]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_CounterDiary_Time] ON [dbo].[TopWinCMS_CounterDiary]([Time]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_CounterDiary_Week] ON [dbo].[TopWinCMS_CounterDiary]([Week]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_CounterDiary_IP] ON [dbo].[TopWinCMS_CounterDiary]([IP]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_CounterDiary_Where] ON [dbo].[TopWinCMS_CounterDiary]([ID], [Where]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_CounterDiary_Come] ON [dbo].[TopWinCMS_CounterDiary]([Come]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_CounterDiary_Page] ON [dbo].[TopWinCMS_CounterDiary]([ID], [Page]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_CounterDiary_Browser] ON [dbo].[TopWinCMS_CounterDiary]([ID], [Browser]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_CounterDiary_OS] ON [dbo].[TopWinCMS_CounterDiary]([ID], [OS]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_CounterDiary_Resolution] ON [dbo].[TopWinCMS_CounterDiary]([ID], [Resolution]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TopWinCMS_DiggDiary] ADD 
	CONSTRAINT [DF_TopWinCMS_DiggDiary_CheckInDate] DEFAULT (getdate()) FOR [CheckInDate]
GO

ALTER TABLE [dbo].[TopWinCMS_Field] ADD 
	CONSTRAINT [DF_TopWinCMS_Field_Stop] DEFAULT (0) FOR [Stop]
GO

ALTER TABLE [dbo].[TopWinCMS_FriendLink] ADD 
	CONSTRAINT [DF_TopWinCMS_FriendLink_Pass] DEFAULT (0) FOR [Pass],
	CONSTRAINT [DF_TopWinCMS_FriendLink_UpdateTime] DEFAULT (getdate()) FOR [UpdateTime]
GO

ALTER TABLE [dbo].[TopWinCMS_GuestBook] ADD 
	CONSTRAINT [DF_Guestbook_posttime] DEFAULT (getdate()) FOR [PostTime],
	CONSTRAINT [DF_TopWinCMS_GuestBook_privacy] DEFAULT (0) FOR [Privacy]
GO

 CREATE  INDEX [IX_TopWinCMS_GuestBook_PostTime] ON [dbo].[TopWinCMS_GuestBook]([PostTime]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TopWinCMS_IPBlackList] ADD 
	CONSTRAINT [DF_TopWinCMS_IPBlackList_Updateime] DEFAULT (getdate()) FOR [UpDateTime]
GO

 CREATE  INDEX [IX_TopWinCMS_IPBlackList_IPStart] ON [dbo].[TopWinCMS_IPBlackList]([IPStart]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_IPBlackList_IPEnd] ON [dbo].[TopWinCMS_IPBlackList]([IPEnd]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_IPBlackList_SectorStart] ON [dbo].[TopWinCMS_IPBlackList]([SectorStart]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_IPBlackList_SectorEnd] ON [dbo].[TopWinCMS_IPBlackList]([SectorEnd]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TopWinCMS_Log] ADD 
	CONSTRAINT [DF__log__time__15DA3E5D] DEFAULT (getdate()) FOR [CheckInDate],
	CONSTRAINT [DF_Log_Deleted] DEFAULT (0) FOR [Deleted]
GO

 CREATE  INDEX [IX_TopWinCMS_Log_Type] ON [dbo].[TopWinCMS_Log]([Type]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TopWinCMS_Member] ADD 
	CONSTRAINT [DF_TopWinCMS_Coin] DEFAULT (0) FOR [Coin],
	CONSTRAINT [DF_TopWinCMS_Point] DEFAULT (0) FOR [Point],
	CONSTRAINT [DF_TopWinCMS_Member_Experience] DEFAULT (0) FOR [Experience],
	CONSTRAINT [DF_TopWinCMS_Member_Mature] DEFAULT (getdate()) FOR [Mature],
	CONSTRAINT [DF_TopWinCMS_Member_ActiveType] DEFAULT (0) FOR [ActiveType],
	CONSTRAINT [DF_TopWinCMS_Member_ActiveBBS] DEFAULT (0) FOR [ActiveBBS],
	CONSTRAINT [DF_TopWinCMS_Member_ActiveBlog] DEFAULT (0) FOR [ActiveBlog],
	CONSTRAINT [DF_TopWinCMS_RegTime] DEFAULT (getdate()) FOR [RegTime],
	CONSTRAINT [DF_TopWinCMS_Member_IsLock] DEFAULT (0) FOR [IsLocked]
GO

 CREATE  INDEX [IX_TopWinCMS_Member_Name] ON [dbo].[TopWinCMS_Member]([Name]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TopWinCMS_Message] ADD 
	CONSTRAINT [DF_TopWinCMS_Message_Flag] DEFAULT (0) FOR [Flag],
	CONSTRAINT [DF_TopWinCMS_Message_SendTime] DEFAULT (getdate()) FOR [SendTime],
	CONSTRAINT [DF_TopWinCMS_Message_IsRead] DEFAULT (0) FOR [IsRead],
	CONSTRAINT [DF_TopWinCMS_Message_DelSend] DEFAULT (0) FOR [DelSend]
GO

ALTER TABLE [dbo].[TopWinCMS_Model] ADD 
	CONSTRAINT [DF_TopWinCMS_Model_Hide] DEFAULT (0) FOR [Hide]
GO

ALTER TABLE [dbo].[TopWinCMS_Product] ADD 
	CONSTRAINT [DF_TopWinCMS_Product_ModelID] DEFAULT (3) FOR [ModelID],
	CONSTRAINT [DF_TopWinCMS_Product_SpecialID] DEFAULT (0) FOR [SpecialID],
	CONSTRAINT [DF_TopWinCMS_Product_SpecialName] DEFAULT ('') FOR [SpecialName],
	CONSTRAINT [DF_TopWinCMS_Product_ClassName] DEFAULT ('') FOR [ClassName],
	CONSTRAINT [DF_TopWinCMS_Product_UpdateTime] DEFAULT (getdate()) FOR [UpdateTime],
	CONSTRAINT [DF_TopWinCMS_Product_OnTop] DEFAULT (0) FOR [OnTop],
	CONSTRAINT [DF_TopWinCMS_Product_Elite] DEFAULT (0) FOR [Elite],
	CONSTRAINT [DF_TopWinCMS_Product_IncludePic] DEFAULT (0) FOR [IncludePic],
	CONSTRAINT [DF_TopWinCMS_Product_PicUrl] DEFAULT ('') FOR [PicUrl],
	CONSTRAINT [DF_TopWinCMS_Product_BigPicUrl] DEFAULT ('') FOR [BigPicUrl],
	CONSTRAINT [DF_TopWinCMS_Product_Deleted] DEFAULT (0) FOR [Deleted],
	CONSTRAINT [DF_TopWinCMS_Product_Stars] DEFAULT (3) FOR [Stars],
	CONSTRAINT [DF_TopWinCMS_Product_Pass] DEFAULT (1) FOR [Pass],
	CONSTRAINT [DF_TopWinCMS_Product_ContentPass] DEFAULT (1) FOR [ContentPass],
	CONSTRAINT [DF_TopWinCMS_Product_MemberRole] DEFAULT (0) FOR [Rank],
	CONSTRAINT [DF_TopWinCMS_Product_PointNum] DEFAULT (0) FOR [PointNum],
	CONSTRAINT [DF_TopWinCMS_Product_AllowComment] DEFAULT (1) FOR [AllowComment],
	CONSTRAINT [DF_TopWinCMS_Product_StaticURL] DEFAULT ('') FOR [StaticURL]
GO

 CREATE  INDEX [IX_TopWinCMS_Product_Hits] ON [dbo].[TopWinCMS_Product]([Hits] DESC ) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_Product_ClassID] ON [dbo].[TopWinCMS_Product]([ClassID]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_Product_UpdateTime] ON [dbo].[TopWinCMS_Product]([UpdateTime] DESC ) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TopWinCMS_Rights] ADD 
	CONSTRAINT [DF_TopWinCMS_Rights_ModelID] DEFAULT ('') FOR [ModelID]
GO

ALTER TABLE [dbo].[TopWinCMS_SecurityCenter] ADD 
	CONSTRAINT [DF_TopWinCMS_SecurityCenter_UpDateTime] DEFAULT (getdate()) FOR [UpDateTime]
GO

ALTER TABLE [dbo].[TopWinCMS_Soft] ADD 
	CONSTRAINT [DF_TopWinCMS_Soft_SpecialID] DEFAULT (0) FOR [SpecialID],
	CONSTRAINT [DF_TopWinCMS_Soft_SpecialName] DEFAULT ('') FOR [SpecialName],
	CONSTRAINT [DF_TopWinCMS_Soft_ClassName] DEFAULT ('') FOR [ClassName],
	CONSTRAINT [DF_TopWinCMS_Soft_IncludePic] DEFAULT (0) FOR [IncludePic],
	CONSTRAINT [DF_TopWinCMS_Soft_DayHits] DEFAULT (0) FOR [DayHits],
	CONSTRAINT [DF_TopWinCMS_Soft_WeekHits] DEFAULT (0) FOR [WeekHits],
	CONSTRAINT [DF_TopWinCMS_Soft_MonthHits] DEFAULT (0) FOR [MonthHits],
	CONSTRAINT [DF_TopWinCMS_Soft_Deleted] DEFAULT (0) FOR [Deleted],
	CONSTRAINT [DF_TopWinCMS_Soft_Pass] DEFAULT (1) FOR [Pass],
	CONSTRAINT [DF_TopWinCMS_Soft_ContentPass] DEFAULT (1) FOR [ContentPass],
	CONSTRAINT [DF_TopWinCMS_Soft_Gather] DEFAULT (0) FOR [Gather],
	CONSTRAINT [DF_TopWinCMS_Soft_Rank] DEFAULT (0) FOR [Rank],
	CONSTRAINT [DF_TopWinCMS_Soft_PointNum] DEFAULT (0) FOR [PointNum],
	CONSTRAINT [DF_TopWinCMS_Soft_AllowComment] DEFAULT (1) FOR [AllowComment],
	CONSTRAINT [DF_TopWinCMS_Soft_StaticURL] DEFAULT ('') FOR [StaticURL]
GO

 CREATE  INDEX [IX_TopWinCMS_Soft_Hits] ON [dbo].[TopWinCMS_Soft]([Hits]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_Soft_DayHits] ON [dbo].[TopWinCMS_Soft]([DayHits]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_Soft_WeekHits] ON [dbo].[TopWinCMS_Soft]([WeekHits]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_Soft_MonthHits] ON [dbo].[TopWinCMS_Soft]([MonthHits]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_Soft_UpdateTime] ON [dbo].[TopWinCMS_Soft]([UpdateTime] DESC ) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_Soft_ClassID] ON [dbo].[TopWinCMS_Soft]([ClassID]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TopWinCMS_SoftDownList] ADD 
	CONSTRAINT [DF_TopWinCMS_SoftDownList_DownLinkName] DEFAULT ('') FOR [DownLinkName]
GO

ALTER TABLE [dbo].[TopWinCMS_SoftLinkErr] ADD 
	CONSTRAINT [DF_TopWinCMS_SoftLinkErr_UpDateTime] DEFAULT (getdate()) FOR [UpDateTime],
	CONSTRAINT [DF_TopWinCMS_SoftLinkErr_Complete] DEFAULT (0) FOR [Complete]
GO

ALTER TABLE [dbo].[TopWinCMS_SoftServer] ADD 
	CONSTRAINT [DF_TopWinCMS_SoftServer_LinkProperty] DEFAULT (0) FOR [LinkProperty],
	CONSTRAINT [DF_TopWinCMS_SoftServer_IsLock] DEFAULT (0) FOR [IsLock]
GO

ALTER TABLE [dbo].[TopWinCMS_Special] ADD 
	CONSTRAINT [DF_TopWinCMS_Special_ParentID] DEFAULT (0) FOR [ParentID],
	CONSTRAINT [DF_TopWinCMS_Special_RootID] DEFAULT (0) FOR [RootID],
	CONSTRAINT [DF_TopWinCMS_Special_HaveBaby] DEFAULT (0) FOR [HaveBaby],
	CONSTRAINT [DF_TopWinCMS_Special_IsShowInIndex] DEFAULT (1) FOR [IsShowInIndex],
	CONSTRAINT [DF_TopWinCMS_Special_IsShowInHeader] DEFAULT (1) FOR [IsShowInHeader],
	CONSTRAINT [DF_TopWinCMS_Special_ContentAdmin] DEFAULT ('') FOR [ContentAdmin],
	CONSTRAINT [DF_TopWinCMS_Special_StaticURL] DEFAULT ('') FOR [StaticURL]
GO

ALTER TABLE [dbo].[TopWinCMS_Templates] ADD 
	CONSTRAINT [DF_TopWinCMS_Templates_IsUsed] DEFAULT (0) FOR [IsUsed]
GO

ALTER TABLE [dbo].[TopWinCMS_UDT] ADD 
	CONSTRAINT [DF_TopWinCMS_UDT_Stop] DEFAULT (0) FOR [Stop],
	CONSTRAINT [DF_TopWinCMS_UDT_CheckInDate] DEFAULT (getdate()) FOR [CheckInDate]
GO

ALTER TABLE [dbo].[TopWinCMS_Vote] ADD 
	CONSTRAINT [DF_Vote_DataTime] DEFAULT (getdate()) FOR [DataTime],
	CONSTRAINT [DF_TopWinCMS_Vote_SelectMode] DEFAULT (0) FOR [VoteType]
GO

ALTER TABLE [dbo].[TopWinCMS_Words] ADD 
	CONSTRAINT [DF_TopWinCMS_Words_UpDateTime] DEFAULT (getdate()) FOR [UpDateTime]
GO

 CREATE  INDEX [IX_TopWinCMS_Words_Ban] ON [dbo].[TopWinCMS_Words]([Ban]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TopWinCMS_WorkStatDiary] ADD 
	CONSTRAINT [DF_TopWinCMS_WorkStatDiary_LastTime] DEFAULT (getdate()) FOR [LastTime]
GO

 CREATE  INDEX [IX_TopWinCMS_WorkStatDiary_Type] ON [dbo].[TopWinCMS_WorkStatDiary]([Type]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_TopWinCMS_WorkStatDiary_Channel] ON [dbo].[TopWinCMS_WorkStatDiary]([ModelID]) ON [PRIMARY]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_ArticleGather
AS
SELECT     ID, Name, StartUrl, ClassArea, Title, UpdateTime, ComeFrom, Author, Content, ShowArticleUrl, ClassNextPage, ShowArticleNextUrl, GatherNum, 
                      Replace, DownImg, InCheckTime, Filter, LastWork, Pass, GatherPicArticle, DrawWaterMark, IsExpert,
                          (SELECT     ClassName
                            FROM          dbo.TopWinCMS_Class
                            WHERE      (ID = dbo.TopWinCMS_ArticleGather.ClassID)) AS ClassName, ClassID
FROM         dbo.TopWinCMS_ArticleGather

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


exec sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "TopWinCMS_ArticleGather"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 330
               Right = 211
            End
            DisplayFlags = 280
            TopColumn = 5
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
', N'user', N'dbo', N'view', N'VW_TopWinCMS_ArticleGather'
GO
exec sp_addextendedproperty N'MS_DiagramPaneCount', 1, N'user', N'dbo', N'view', N'VW_TopWinCMS_ArticleGather'

GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.VW_TopWinCMS_AdList    Script Date: 2008-02-08 1:18:09 ******/
CREATE VIEW dbo.VW_TopWinCMS_AdList
AS
SELECT     DATEDIFF(D, GETDATE(), MaxDateTime) AS DateOff, ID, SiteName, UserName, Ad_Url, Contact, Url, Width, Height, MaxShowTime, Target, MaxClick,
MaxDateTime, Show, Clicks, ShowType, Remark, UpDateTime, Stop, Note
FROM         dbo.TopWinCMS_AdList

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Article
AS
SELECT dbo.TopWinCMS_Article.ID, dbo.TopWinCMS_Article.Title,
dbo.TopWinCMS_Article.Title AS ContentTitle, dbo.TopWinCMS_Article.Hits,
dbo.TopWinCMS_Article.UpdateTime, dbo.TopWinCMS_Article.Pass,
dbo.TopWinCMS_Article.OnTop, dbo.TopWinCMS_Article.Elite,
dbo.TopWinCMS_Article.Deleted, dbo.TopWinCMS_Class.ClassName,
(SELECT COUNT(*) AS Expr1
FROM dbo.TopWinCMS_Comment
WHERE (dbo.TopWinCMS_Article.ModelID = ModelID) AND
(ContentID = dbo.TopWinCMS_Article.ID)) AS CommentQuantity,
(SELECT SpecialName
FROM dbo.TopWinCMS_Special
WHERE (ID = dbo.TopWinCMS_Article.SpecialID)) AS SpecialName,
dbo.TopWinCMS_Article.Editor, dbo.TopWinCMS_Article.ClassID,
dbo.TopWinCMS_Article.SpecialID, dbo.TopWinCMS_Article.Content,
dbo.TopWinCMS_Article.Stars, dbo.TopWinCMS_Article.PicUrl,
dbo.TopWinCMS_Article.Gather, dbo.TopWinCMS_Article.IncludePic,
dbo.TopWinCMS_Article.Rank, dbo.TopWinCMS_Article.ColorStyle,
dbo.TopWinCMS_Article.FontStyle, dbo.TopWinCMS_Article.IsSlide,
dbo.TopWinCMS_Article.IsDraft, dbo.TopWinCMS_Article.ContentPass,
dbo.TopWinCMS_Article.StaticURL, dbo.TopWinCMS_Article.ModelID,
dbo.TopWinCMS_Article.[From], dbo.TopWinCMS_Article.Author,
dbo.TopWinCMS_Article.TemplateFileName
FROM dbo.TopWinCMS_Article INNER JOIN
dbo.TopWinCMS_Class ON
dbo.TopWinCMS_Article.ClassID = dbo.TopWinCMS_Class.ID AND
dbo.TopWinCMS_Article.ModelID = dbo.TopWinCMS_Class.ModelID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


exec sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[51] 4[10] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1[50] 2[25] 3) )"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1 [56] 4 [18] 2))"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "TopWinCMS_Article"
Begin Extent =
Top = 6
Left = 38
Bottom = 289
Right = 310
End
DisplayFlags = 280
TopColumn = 16
End
Begin Table = "TopWinCMS_Class"
Begin Extent =
Top = 0
Left = 473
Bottom = 364
Right = 650
End
DisplayFlags = 280
TopColumn = 8
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
RowHeights = 240
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 900
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
', N'user', N'dbo', N'view', N'VW_TopWinCMS_Article'
GO
exec sp_addextendedproperty N'MS_DiagramPaneCount', 1, N'user', N'dbo', N'view', N'VW_TopWinCMS_Article'

GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Article_Comment
AS
SELECT dbo.TopWinCMS_Comment.ID, dbo.TopWinCMS_Comment.Name,
dbo.TopWinCMS_Comment.ContentID, dbo.TopWinCMS_Article.Title AS ContentTitle,
dbo.TopWinCMS_Comment.Content, dbo.TopWinCMS_Comment.Pass
FROM dbo.TopWinCMS_Article INNER JOIN
dbo.TopWinCMS_Comment ON
dbo.TopWinCMS_Article.ModelID = dbo.TopWinCMS_Comment.ModelID AND
dbo.TopWinCMS_Article.ID = dbo.TopWinCMS_Comment.ContentID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


exec sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1[50] 2[25] 3) )"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1 [56] 4 [18] 2))"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "TopWinCMS_Article"
Begin Extent =
Top = 6
Left = 38
Bottom = 236
Right = 223
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "TopWinCMS_Comment"
Begin Extent =
Top = 0
Left = 430
Bottom = 218
Right = 775
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
RowHeights = 240
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 1905
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
', N'user', N'dbo', N'view', N'VW_TopWinCMS_Article_Comment'
GO
exec sp_addextendedproperty N'MS_DiagramPaneCount', 1, N'user', N'dbo', N'view', N'VW_TopWinCMS_Article_Comment'

GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Article_Digg
AS
SELECT     dbo.TopWinCMS_Article.ID, dbo.TopWinCMS_Article.Title AS ContentTitle, dbo.TopWinCMS_Digg.GoodNum, dbo.TopWinCMS_Digg.BadNum,
dbo.TopWinCMS_Digg.LastUserName
FROM         dbo.TopWinCMS_Article INNER JOIN
dbo.TopWinCMS_Digg ON dbo.TopWinCMS_Article.ModelID = dbo.TopWinCMS_Digg.ModelID AND
dbo.TopWinCMS_Article.ID = dbo.TopWinCMS_Digg.ContentID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


exec sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1 [50] 2 [25] 3))"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1[56] 4[18] 2) )"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "TopWinCMS_Article"
Begin Extent =
Top = 6
Left = 38
Bottom = 267
Right = 232
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "TopWinCMS_Digg"
Begin Extent =
Top = 0
Left = 405
Bottom = 291
Right = 642
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 1080
Table = 1590
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
', N'user', N'dbo', N'view', N'VW_TopWinCMS_Article_Digg'
GO
exec sp_addextendedproperty N'MS_DiagramPaneCount', 1, N'user', N'dbo', N'view', N'VW_TopWinCMS_Article_Digg'

GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Article_DiggDiary
AS
SELECT     dbo.TopWinCMS_Article.ID, dbo.TopWinCMS_Article.Title AS ContentTitle, dbo.TopWinCMS_DiggDiary.Name, dbo.TopWinCMS_DiggDiary.IsAgree,
dbo.TopWinCMS_DiggDiary.IP, dbo.TopWinCMS_DiggDiary.CheckInDate
FROM         dbo.TopWinCMS_Article INNER JOIN
dbo.TopWinCMS_DiggDiary ON dbo.TopWinCMS_Article.ModelID = dbo.TopWinCMS_DiggDiary.ModelID AND
dbo.TopWinCMS_Article.ID = dbo.TopWinCMS_DiggDiary.ContentID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


exec sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1 [50] 2 [25] 3))"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1[56] 4[18] 2) )"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "TopWinCMS_Article"
Begin Extent =
Top = 6
Left = 38
Bottom = 271
Right = 206
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "TopWinCMS_DiggDiary"
Begin Extent =
Top = 20
Left = 404
Bottom = 252
Right = 547
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
Begin ColumnWidths = 9
Width = 284
Width = 1500
Width = 1500
Width = 1500
Width = 1500
Width = 1500
Width = 1500
Width = 1500
Width = 1500
End
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 900
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
', N'user', N'dbo', N'view', N'VW_TopWinCMS_Article_DiggDiary'
GO
exec sp_addextendedproperty N'MS_DiagramPaneCount', 1, N'user', N'dbo', N'view', N'VW_TopWinCMS_Article_DiggDiary'

GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

--视图名称格式，VW_模型数据表Special
CREATE VIEW dbo.VW_TopWinCMS_Article_Special
AS
SELECT dbo.TopWinCMS_Article.ID, dbo.TopWinCMS_Special.SpecialName, dbo.TopWinCMS_Article.Title, dbo.TopWinCMS_Article.Hits,
dbo.TopWinCMS_Article.UpdateTime, dbo.TopWinCMS_Article.Pass, dbo.TopWinCMS_Article.OnTop, dbo.TopWinCMS_Article.Elite,
dbo.TopWinCMS_Article.Deleted,
(SELECT COUNT(*)
FROM dbo.TopWinCMS_Comment
WHERE  dbo.TopWinCMS_Article.ModelID = dbo.TopWinCMS_Comment.ModelID and (TopWinCMS_Comment.ContentID = dbo.TopWinCMS_Article.ID))
AS CommentQuantity,
dbo.TopWinCMS_Article.Editor, dbo.TopWinCMS_Article.Stars,
dbo.TopWinCMS_Article.IncludePic, dbo.TopWinCMS_Article.ClassID
FROM dbo.TopWinCMS_Article INNER JOIN
dbo.TopWinCMS_Special ON dbo.TopWinCMS_Article.SpecialID = dbo.TopWinCMS_Special.ID
WHERE (dbo.TopWinCMS_Article.Deleted = 0 and dbo.TopWinCMS_Article.ModelID=2)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Article_Total
AS
SELECT IsNull(SUM(Hits),0) AS 点击数, COUNT(ID) AS 总量,
(SELECT COUNT(ID)
FROM TopWinCMS_Article
WHERE (datediff(D, UpdateTime, getdate())) = 0) AS 今日更新
FROM dbo.TopWinCMS_Article
where dbo.TopWinCMS_Article.Pass=1 and dbo.TopWinCMS_Article.Deleted=0

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.VW_TopWinCMS_Business    Script Date: 2008-02-08 1:18:09 ******/
CREATE VIEW dbo.VW_TopWinCMS_Business
AS
SELECT     dbo.TopWinCMS_Business.ID, dbo.TopWinCMS_Business.MemberID, dbo.TopWinCMS_Business.ModelID, dbo.TopWinCMS_Business.Indent,
dbo.TopWinCMS_Business.Point, dbo.TopWinCMS_Business.PayMoney, dbo.TopWinCMS_Business.Customer, dbo.TopWinCMS_Business.DateTime,
dbo.TopWinCMS_Business.Remark, dbo.TopWinCMS_Business.flag, dbo.TopWinCMS_Member.Name, DATEDIFF(D, GETDATE(),
dbo.TopWinCMS_Business.DateTime) AS DateOff
FROM         dbo.TopWinCMS_Business INNER JOIN
dbo.TopWinCMS_Member ON dbo.TopWinCMS_Business.MemberID = dbo.TopWinCMS_Member.ID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


exec sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[23] 4[38] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1 [50] 2 [25] 3))"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1[56] 4[18] 2) )"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "TopWinCMS_Business"
Begin Extent =
Top = 6
Left = 38
Bottom = 123
Right = 177
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "TopWinCMS_Member"
Begin Extent =
Top = 6
Left = 215
Bottom = 123
Right = 374
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1965
Alias = 1485
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
', N'user', N'dbo', N'view', N'VW_TopWinCMS_Business'
GO
exec sp_addextendedproperty N'MS_DiagramPaneCount', 1, N'user', N'dbo', N'view', N'VW_TopWinCMS_Business'

GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Field
AS
SELECT dbo.TopWinCMS_Field.ID, dbo.TopWinCMS_Field.ModelID,
dbo.TopWinCMS_Model.ModelName, dbo.TopWinCMS_Field.FieldName,
dbo.TopWinCMS_Field.Title, dbo.TopWinCMS_Field.FieldType,
dbo.TopWinCMS_Field.DefaultValue, dbo.TopWinCMS_Field.OrderID,
dbo.TopWinCMS_Field.MaxFieldLength
FROM dbo.TopWinCMS_Field INNER JOIN
dbo.TopWinCMS_Model ON
dbo.TopWinCMS_Field.ModelID = dbo.TopWinCMS_Model.ID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


exec sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[41] 4[21] 2[21] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1[50] 2[25] 3) )"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1 [56] 4 [18] 2))"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "TopWinCMS_Field"
Begin Extent =
Top = 6
Left = 38
Bottom = 317
Right = 324
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "TopWinCMS_Model"
Begin Extent =
Top = 6
Left = 414
Bottom = 325
Right = 821
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
RowHeights = 240
Begin ColumnWidths = 10
Width = 284
Width = 1440
Width = 1440
Width = 1440
Width = 1440
Width = 1440
Width = 1440
Width = 1440
Width = 1440
Width = 1440
End
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 900
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
', N'user', N'dbo', N'view', N'VW_TopWinCMS_Field'
GO
exec sp_addextendedproperty N'MS_DiagramPaneCount', 1, N'user', N'dbo', N'view', N'VW_TopWinCMS_Field'

GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.VW_TopWinCMS_Member    Script Date: 2008-02-08 1:18:09 ******/
CREATE VIEW dbo.VW_TopWinCMS_Member
AS
SELECT     dbo.TopWinCMS_MemberRole.RoleName, dbo.TopWinCMS_MemberRole.RolePower, DATEDIFF(D, dbo.TopWinCMS_Member.LastLoginTime, GETDATE()) AS DateOff,
dbo.TopWinCMS_Member.ID, dbo.TopWinCMS_Member.Name, dbo.TopWinCMS_Member.PSW, dbo.TopWinCMS_Member.QQ, dbo.TopWinCMS_Member.HomePage,
dbo.TopWinCMS_Member.PetName, dbo.TopWinCMS_Member.eMail, dbo.TopWinCMS_Member.Introduce, dbo.TopWinCMS_Member.Coin,
dbo.TopWinCMS_Member.Point, dbo.TopWinCMS_Member.Experience, dbo.TopWinCMS_Member.Mature, dbo.TopWinCMS_Member.Question,
dbo.TopWinCMS_Member.Sex, dbo.TopWinCMS_Member.Answer, dbo.TopWinCMS_Member.MemberRoleID, dbo.TopWinCMS_Member.ActiveType,
dbo.TopWinCMS_Member.LastLoginIP, dbo.TopWinCMS_Member.RegTime, dbo.TopWinCMS_Member.LastLoginTime, dbo.TopWinCMS_Member.IsLocked,
dbo.TopWinCMS_Member.TrueName, dbo.TopWinCMS_Member.MSN, dbo.TopWinCMS_Member.Birthday, dbo.TopWinCMS_Member.Province,
dbo.TopWinCMS_Member.City, dbo.TopWinCMS_Member.ActiveBBS, dbo.TopWinCMS_Member.ActiveBlog, dbo.TopWinCMS_Member.ICQ,
dbo.TopWinCMS_Member.Yahoo, dbo.TopWinCMS_Member.Skype, dbo.TopWinCMS_Member.Location, dbo.TopWinCMS_Member.IdCard,
dbo.TopWinCMS_Member.Mobile, dbo.TopWinCMS_Member.Phone, dbo.TopWinCMS_Member.Address, dbo.TopWinCMS_MemberRole.Rank
FROM         dbo.TopWinCMS_Member INNER JOIN
dbo.TopWinCMS_MemberRole ON dbo.TopWinCMS_Member.MemberRoleID = dbo.TopWinCMS_MemberRole.ID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


exec sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1[50] 2[25] 3) )"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1 [56] 4 [18] 2))"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "TopWinCMS_Member"
Begin Extent =
Top = 6
Left = 38
Bottom = 341
Right = 458
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "TopWinCMS_MemberRole"
Begin Extent =
Top = 6
Left = 632
Bottom = 260
Right = 775
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 900
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
', N'user', N'dbo', N'view', N'VW_TopWinCMS_Member'
GO
exec sp_addextendedproperty N'MS_DiagramPaneCount', 1, N'user', N'dbo', N'view', N'VW_TopWinCMS_Member'

GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Product
AS
SELECT     dbo.TopWinCMS_Product.ID, dbo.TopWinCMS_Product.ProductName, dbo.TopWinCMS_Product.ProductName AS ContentTitle, dbo.TopWinCMS_Product.Hits,
dbo.TopWinCMS_Product.UpdateTime, dbo.TopWinCMS_Product.Pass, dbo.TopWinCMS_Product.OnTop, dbo.TopWinCMS_Product.Elite,
dbo.TopWinCMS_Product.Deleted, dbo.TopWinCMS_Class.ClassName,
(SELECT     COUNT(*) AS Expr1
FROM          dbo.TopWinCMS_Comment
WHERE      (dbo.TopWinCMS_Product.ModelID = ModelID) AND (ContentID = dbo.TopWinCMS_Product.ID)) AS CommentQuantity,
(SELECT     SpecialName
FROM          dbo.TopWinCMS_Special
WHERE      (ID = dbo.TopWinCMS_Product.SpecialID)) AS SpecialName, dbo.TopWinCMS_Product.Editor, dbo.TopWinCMS_Product.ClassID,
dbo.TopWinCMS_Product.SpecialID, dbo.TopWinCMS_Product.Content, dbo.TopWinCMS_Product.Stars, dbo.TopWinCMS_Product.PicUrl,
dbo.TopWinCMS_Product.IncludePic, dbo.TopWinCMS_Product.Rank, dbo.TopWinCMS_Product.ColorStyle, dbo.TopWinCMS_Product.FontStyle,
dbo.TopWinCMS_Product.IsSlide, dbo.TopWinCMS_Product.IsDraft, dbo.TopWinCMS_Product.ContentPass, dbo.TopWinCMS_Product.StaticURL,
dbo.TopWinCMS_Product.ModelID, dbo.TopWinCMS_Product.TemplateFileName, dbo.TopWinCMS_Product.BigPicUrl
FROM         dbo.TopWinCMS_Product INNER JOIN
dbo.TopWinCMS_Class ON dbo.TopWinCMS_Product.ClassID = dbo.TopWinCMS_Class.ID AND dbo.TopWinCMS_Product.ModelID = dbo.TopWinCMS_Class.ModelID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


exec sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1 [50] 2 [25] 3))"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1[56] 4[18] 2) )"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "TopWinCMS_Product"
Begin Extent =
Top = 6
Left = 38
Bottom = 258
Right = 214
End
DisplayFlags = 280
TopColumn = 11
End
Begin Table = "TopWinCMS_Class"
Begin Extent =
Top = 6
Left = 252
Bottom = 123
Right = 428
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 900
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
', N'user', N'dbo', N'view', N'VW_TopWinCMS_Product'
GO
exec sp_addextendedproperty N'MS_DiagramPaneCount', 1, N'user', N'dbo', N'view', N'VW_TopWinCMS_Product'

GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Product_Comment
AS
SELECT dbo.TopWinCMS_Comment.ID, dbo.TopWinCMS_Comment.Name,
dbo.TopWinCMS_Comment.ContentID,
dbo.TopWinCMS_Product.ProductName AS ContentTitle,
dbo.TopWinCMS_Comment.Content, dbo.TopWinCMS_Comment.Pass
FROM dbo.TopWinCMS_Comment INNER JOIN
dbo.TopWinCMS_Product ON
dbo.TopWinCMS_Comment.ModelID = dbo.TopWinCMS_Product.ModelID AND
dbo.TopWinCMS_Comment.ContentID = dbo.TopWinCMS_Product.ID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


exec sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1[50] 2[25] 3) )"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1 [56] 4 [18] 2))"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "TopWinCMS_Comment"
Begin Extent =
Top = 4
Left = 501
Bottom = 215
Right = 810
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "TopWinCMS_Product"
Begin Extent =
Top = 6
Left = 219
Bottom = 215
Right = 404
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
RowHeights = 240
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 1230
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
', N'user', N'dbo', N'view', N'VW_TopWinCMS_Product_Comment'
GO
exec sp_addextendedproperty N'MS_DiagramPaneCount', 1, N'user', N'dbo', N'view', N'VW_TopWinCMS_Product_Comment'

GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Product_Digg
AS
SELECT     dbo.TopWinCMS_Product.ID, dbo.TopWinCMS_Product.ProductName AS ContentTitle, dbo.TopWinCMS_Digg.GoodNum, dbo.TopWinCMS_Digg.BadNum,
dbo.TopWinCMS_Digg.LastUserName
FROM         dbo.TopWinCMS_Product INNER JOIN
dbo.TopWinCMS_Digg ON dbo.TopWinCMS_Product.ModelID = dbo.TopWinCMS_Digg.ModelID AND
dbo.TopWinCMS_Product.ID = dbo.TopWinCMS_Digg.ContentID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Product_DiggDiary
AS
SELECT     dbo.TopWinCMS_Product.ID, dbo.TopWinCMS_Product.ProductName AS ContentTitle, dbo.TopWinCMS_DiggDiary.Name, dbo.TopWinCMS_DiggDiary.IsAgree,
dbo.TopWinCMS_DiggDiary.IP, dbo.TopWinCMS_DiggDiary.CheckInDate
FROM         dbo.TopWinCMS_Product INNER JOIN
dbo.TopWinCMS_DiggDiary ON dbo.TopWinCMS_Product.ModelID = dbo.TopWinCMS_DiggDiary.ModelID AND
dbo.TopWinCMS_Product.ID = dbo.TopWinCMS_DiggDiary.ContentID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

--视图名称格式，VW_模型数据表Special
CREATE VIEW dbo.VW_TopWinCMS_Product_Special
AS
SELECT dbo.TopWinCMS_Product.ID, dbo.TopWinCMS_Special.SpecialName, dbo.TopWinCMS_Product.ProductName, dbo.TopWinCMS_Product.Hits,
dbo.TopWinCMS_Product.UpdateTime, dbo.TopWinCMS_Product.Pass, dbo.TopWinCMS_Product.OnTop, dbo.TopWinCMS_Product.Elite,
dbo.TopWinCMS_Product.Deleted,
(SELECT COUNT(*)
FROM dbo.TopWinCMS_Comment
WHERE  dbo.TopWinCMS_Product.ModelID = dbo.TopWinCMS_Comment.ModelID and (TopWinCMS_Comment.ContentID = dbo.TopWinCMS_Product.ID))
AS CommentQuantity,
dbo.TopWinCMS_Product.Editor, dbo.TopWinCMS_Product.Stars,
dbo.TopWinCMS_Product.IncludePic, dbo.TopWinCMS_Product.ClassID
FROM dbo.TopWinCMS_Product INNER JOIN
dbo.TopWinCMS_Special ON dbo.TopWinCMS_Product.SpecialID = dbo.TopWinCMS_Special.ID
WHERE (dbo.TopWinCMS_Product.Deleted = 0 and dbo.TopWinCMS_Product.ModelID=2)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Product_Total
AS
SELECT IsNull(SUM(Hits),0) AS 点击数, COUNT(ID) AS 总量,
(SELECT COUNT(ID)
FROM TopWinCMS_Product
WHERE (datediff(D, UpdateTime, getdate())) = 0) AS 今日更新
FROM dbo.TopWinCMS_Product
where dbo.TopWinCMS_Product.Pass=1 and dbo.TopWinCMS_Product.Deleted=0

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Soft
AS
SELECT dbo.TopWinCMS_Soft.SoftName, dbo.TopWinCMS_Soft.SoftVersion,
dbo.TopWinCMS_Soft.SoftName + ' ' + dbo.TopWinCMS_Soft.SoftVersion AS ContentTitle,
dbo.TopWinCMS_Soft.Editor, dbo.TopWinCMS_Soft.Hits,
dbo.TopWinCMS_Soft.UpdateTime, dbo.TopWinCMS_Class.ClassName,
(SELECT COUNT(ID) AS Expr1
FROM dbo.TopWinCMS_Comment
WHERE (dbo.TopWinCMS_Soft.ModelID = ModelID) AND
(dbo.TopWinCMS_Soft.ID = ContentID)) AS CommentQuantity,
dbo.TopWinCMS_Soft.ClassID, dbo.TopWinCMS_Soft.ID,
dbo.TopWinCMS_Soft.Deleted, dbo.TopWinCMS_Soft.PicUrl,
dbo.TopWinCMS_Soft.Pass, dbo.TopWinCMS_Soft.SoftSize,
dbo.TopWinCMS_Soft.Stars, dbo.TopWinCMS_Soft.ColorStyle,
dbo.TopWinCMS_Soft.FontStyle, dbo.TopWinCMS_Soft.Content,
dbo.TopWinCMS_Soft.IncludePic, dbo.TopWinCMS_Soft.StaticURL,
dbo.TopWinCMS_Soft.OnTop, dbo.TopWinCMS_Soft.Elite,
dbo.TopWinCMS_Soft.IsDraft, dbo.TopWinCMS_Soft.IsSlide,
dbo.TopWinCMS_Soft.SpecialID, dbo.TopWinCMS_Soft.ModelID,
dbo.TopWinCMS_Soft.TemplateFileName
FROM dbo.TopWinCMS_Soft INNER JOIN
dbo.TopWinCMS_Class ON
dbo.TopWinCMS_Soft.ClassID = dbo.TopWinCMS_Class.ID AND
dbo.TopWinCMS_Soft.ModelID = dbo.TopWinCMS_Class.ModelID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


exec sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[45] 4[16] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1[50] 2[25] 3) )"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1 [56] 4 [18] 2))"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "TopWinCMS_Soft"
Begin Extent =
Top = 6
Left = 38
Bottom = 249
Right = 227
End
DisplayFlags = 280
TopColumn = 32
End
Begin Table = "TopWinCMS_Class"
Begin Extent =
Top = 6
Left = 265
Bottom = 215
Right = 442
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
RowHeights = 240
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 900
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
', N'user', N'dbo', N'view', N'VW_TopWinCMS_Soft'
GO
exec sp_addextendedproperty N'MS_DiagramPaneCount', 1, N'user', N'dbo', N'view', N'VW_TopWinCMS_Soft'

GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE  VIEW dbo.VW_TopWinCMS_SoftDownList
AS
SELECT dbo.TopWinCMS_SoftDownList.SoftID,
dbo.TopWinCMS_SoftServer.ID AS ServerID,
dbo.TopWinCMS_SoftDownList.ID AS SoftDownListID,
dbo.TopWinCMS_SoftServer.ServerName, (dbo.TopWinCMS_SoftServer.DownURL+
dbo.TopWinCMS_SoftDownList.FileName) as DownURL, dbo.TopWinCMS_SoftServer.IsLock,
dbo.TopWinCMS_SoftServer.ServerHTML,dbo.TopWinCMS_SoftDownList.ModelID
FROM dbo.TopWinCMS_SoftDownList INNER JOIN
dbo.TopWinCMS_SoftServer ON
dbo.TopWinCMS_SoftServer.ParentID = dbo.TopWinCMS_SoftDownList.ServerID
union
SELECT dbo.TopWinCMS_SoftDownList.SoftID,
dbo.TopWinCMS_SoftServer.ID AS ServerID,
dbo.TopWinCMS_SoftDownList.ID AS SoftDownListID,
dbo.TopWinCMS_SoftServer.ServerName, (dbo.TopWinCMS_SoftServer.DownURL+
dbo.TopWinCMS_SoftDownList.FileName) as DownURL, dbo.TopWinCMS_SoftServer.IsLock,
dbo.TopWinCMS_SoftServer.ServerHTML,dbo.TopWinCMS_SoftDownList.ModelID
FROM TopWinCMS_SoftServer,TopWinCMS_SoftDownList
where
dbo.TopWinCMS_SoftServer.RootID=0 and dbo.TopWinCMS_SoftServer.id not in (select dbo.TopWinCMS_SoftServer.ParentID from TopWinCMS_SoftServer)
and TopWinCMS_SoftDownList.ServerID =dbo.TopWinCMS_SoftServer.id

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Soft_Comment
AS
SELECT dbo.TopWinCMS_Comment.Name, dbo.TopWinCMS_Comment.ContentID,
dbo.TopWinCMS_Soft.SoftName + dbo.TopWinCMS_Soft.SoftVersion AS ContentTitle,
dbo.TopWinCMS_Comment.Content, dbo.TopWinCMS_Comment.Pass,
dbo.TopWinCMS_Comment.ID
FROM dbo.TopWinCMS_Soft INNER JOIN
dbo.TopWinCMS_Comment ON
dbo.TopWinCMS_Soft.ID = dbo.TopWinCMS_Comment.ContentID AND
dbo.TopWinCMS_Soft.ModelID = dbo.TopWinCMS_Comment.ModelID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


exec sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[41] 4[20] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1[50] 2[25] 3) )"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1 [56] 4 [18] 2))"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "TopWinCMS_Soft"
Begin Extent =
Top = 6
Left = 38
Bottom = 214
Right = 235
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "TopWinCMS_Comment"
Begin Extent =
Top = 6
Left = 526
Bottom = 233
Right = 669
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
RowHeights = 240
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 2700
Alias = 1230
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
', N'user', N'dbo', N'view', N'VW_TopWinCMS_Soft_Comment'
GO
exec sp_addextendedproperty N'MS_DiagramPaneCount', 1, N'user', N'dbo', N'view', N'VW_TopWinCMS_Soft_Comment'

GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Soft_Digg
AS
SELECT     dbo.TopWinCMS_Soft.ID, dbo.TopWinCMS_Soft.SoftName + ' ' + dbo.TopWinCMS_Soft.SoftVersion AS ContentTitle, dbo.TopWinCMS_Digg.GoodNum, dbo.TopWinCMS_Digg.BadNum,
dbo.TopWinCMS_Digg.LastUserName
FROM         dbo.TopWinCMS_Soft INNER JOIN
dbo.TopWinCMS_Digg ON dbo.TopWinCMS_Soft.ModelID = dbo.TopWinCMS_Digg.ModelID AND
dbo.TopWinCMS_Soft.ID = dbo.TopWinCMS_Digg.ContentID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Soft_DiggDiary
AS
SELECT     dbo.TopWinCMS_Soft.ID, dbo.TopWinCMS_Soft.SoftName + ' ' + dbo.TopWinCMS_Soft.SoftVersion AS ContentTitle, dbo.TopWinCMS_DiggDiary.Name, dbo.TopWinCMS_DiggDiary.IsAgree,
dbo.TopWinCMS_DiggDiary.IP, dbo.TopWinCMS_DiggDiary.CheckInDate
FROM         dbo.TopWinCMS_Soft INNER JOIN
dbo.TopWinCMS_DiggDiary ON dbo.TopWinCMS_Soft.ModelID = dbo.TopWinCMS_DiggDiary.ModelID AND
dbo.TopWinCMS_Soft.ID = dbo.TopWinCMS_DiggDiary.ContentID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Soft_LinkErr
AS
SELECT dbo.TopWinCMS_SoftLinkErr.ID, dbo.TopWinCMS_SoftLinkErr.SoftID,
dbo.TopWinCMS_Soft.SoftName + dbo.TopWinCMS_Soft.SoftVersion AS SoftFullName,
dbo.TopWinCMS_SoftLinkErr.Name, dbo.TopWinCMS_SoftLinkErr.Message,
dbo.TopWinCMS_SoftLinkErr.IP, dbo.TopWinCMS_SoftLinkErr.UpDateTime,
dbo.TopWinCMS_Soft.ClassID, dbo.TopWinCMS_SoftLinkErr.Complete,
dbo.TopWinCMS_SoftLinkErr.ModelID
FROM dbo.TopWinCMS_SoftLinkErr INNER JOIN
dbo.TopWinCMS_Soft ON
dbo.TopWinCMS_SoftLinkErr.SoftID = dbo.TopWinCMS_Soft.ID AND
dbo.TopWinCMS_SoftLinkErr.ModelID = dbo.TopWinCMS_Soft.ModelID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


exec sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1[50] 2[25] 3) )"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1 [56] 4 [18] 2))"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "TopWinCMS_SoftLinkErr"
Begin Extent =
Top = 6
Left = 38
Bottom = 229
Right = 254
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "TopWinCMS_Soft"
Begin Extent =
Top = 32
Left = 659
Bottom = 332
Right = 848
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
RowHeights = 240
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 900
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
', N'user', N'dbo', N'view', N'VW_TopWinCMS_Soft_LinkErr'
GO
exec sp_addextendedproperty N'MS_DiagramPaneCount', 1, N'user', N'dbo', N'view', N'VW_TopWinCMS_Soft_LinkErr'

GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Soft_Total
AS
SELECT IsNull(SUM(Hits),0) AS 点击数, COUNT(ID) AS 总量,
(SELECT COUNT(ID)
FROM TopWinCMS_Soft
WHERE (datediff(D, LastHitTime, getdate())) = 0) AS 今日更新
FROM dbo.TopWinCMS_Soft where dbo.TopWinCMS_Soft.Pass=1 and dbo.TopWinCMS_Soft.Deleted=0

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.VW_TopWinCMS_Vote
AS
SELECT dbo.TopWinCMS_Vote.ID, dbo.TopWinCMS_Vote.Title,
dbo.TopWinCMS_Vote.Pass, dbo.TopWinCMS_Vote.DataTime,
COUNT(dbo.TopWinCMS_VoteChoice.ID) AS CountChoice,
SUM(dbo.TopWinCMS_VoteChoice.VoteNum) AS CountVoteNum,
dbo.TopWinCMS_Vote.VoteType
FROM dbo.TopWinCMS_Vote INNER JOIN
dbo.TopWinCMS_VoteChoice ON
dbo.TopWinCMS_Vote.ID = dbo.TopWinCMS_VoteChoice.VoteID
GROUP BY dbo.TopWinCMS_Vote.ID, dbo.TopWinCMS_Vote.Title,
dbo.TopWinCMS_Vote.Pass, dbo.TopWinCMS_Vote.DataTime,
dbo.TopWinCMS_Vote.VoteType

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


exec sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1[50] 2[25] 3) )"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1 [56] 4 [18] 2))"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "TopWinCMS_Vote"
Begin Extent =
Top = 6
Left = 38
Bottom = 288
Right = 231
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "TopWinCMS_VoteChoice"
Begin Extent =
Top = 6
Left = 269
Bottom = 116
Right = 432
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
RowHeights = 240
End
Begin CriteriaPane =
Begin ColumnWidths = 12
Column = 1440
Alias = 900
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
', N'user', N'dbo', N'view', N'VW_TopWinCMS_Vote'
GO
exec sp_addextendedproperty N'MS_DiagramPaneCount', 1, N'user', N'dbo', N'view', N'VW_TopWinCMS_Vote'

GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE  VIEW dbo.VW_TopWinCMS_WorkStatDiary
AS
SELECT username, Type, ModelID,LastTime,
[DayStat] AddDay, [WeekStat] AddWeek,
[MonthStat] AddMonth, [YearStat] AddYear, 0 DelDay, 0 DelWeek, 0 DelMonth,
0 DelYear, 0 EditDay, 0 EditWeek, 0 EditMonth, 0 EditYear
FROM TopWinCMS_WorkStatDiary
WHERE type = 1
UNION
SELECT username, Type, ModelID,LastTime,
0 AddDay, 0 AddWeek, 0 AddMonth, 0 AddYear,
[DayStat] DelDay, [WeekStat] DelWeek, [MonthStat] DelMonth, [YearStat] DelYear,
0 EditDay, 0 EditWeek, 0 EditMonth, 0 EditYear
FROM TopWinCMS_WorkStatDiary
WHERE type = 2
UNION
SELECT username, Type, ModelID,	LastTime,
0 AddDay, 0 AddWeek, 0 AddMonth, 0 AddYear,
0 DelDay, 0 DelWeek, 0 DelMonth, 0 DelYear, [DayStat] EditDay,
[WeekStat] EditWeek, [MonthStat] EditMonth, [YearStat] EditYear
FROM TopWinCMS_WorkStatDiary
WHERE type = 3

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE  VIEW dbo.VW_TopWinCMS_WorkStatDiary_Article
AS
SELECT dbo.VW_TopWinCMS_WorkStatDiary.username,
dbo.TopWinCMS_AdminRole.RoleName,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.AddDay) AS AddDay,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.AddWeek) AS AddWeek,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.AddMonth) AS AddMonth,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.AddYear) AS AddYear,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.DelWeek) AS DelWeek,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.DelDay) AS DelDay,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.DelMonth) AS DelMonth,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.DelYear) AS DelYear,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.EditWeek) AS EditWeek,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.EditMonth) AS EditMonth,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.EditYear) AS EditYear,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.EditDay) AS EditDay
FROM dbo.TopWinCMS_Admin INNER JOIN
dbo.TopWinCMS_AdminRole ON
dbo.TopWinCMS_Admin.RoleID = dbo.TopWinCMS_AdminRole.ID INNER JOIN
dbo.VW_TopWinCMS_WorkStatDiary ON
dbo.TopWinCMS_Admin.UserName = dbo.VW_TopWinCMS_WorkStatDiary.username
WHERE (dbo.VW_TopWinCMS_WorkStatDiary.ModelID = 2)
GROUP BY dbo.VW_TopWinCMS_WorkStatDiary.username,
dbo.TopWinCMS_AdminRole.RoleName

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

 

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

/****** Object:  Stored Procedure dbo.P_TopWinCMS_ArticleGather_Add    Script Date: 2008-02-08 1:18:10 ******/
CREATE PROCEDURE P_TopWinCMS_ArticleGather_Add
@Name nvarchar(2000), @StartUrl nvarchar(2000),@ClassArea nvarchar(2000),
@ClassNextPage nvarchar(2000),@ShowArticleUrl nvarchar(2000),@Title nvarchar(2000),
@Content nvarchar(2000),@ShowArticleNextUrl nvarchar(2000),@From nvarchar(2000),
@Author nvarchar(2000),@UpdateTime nvarchar(2000),@Filter text,
@GatherNum int,@DownImg bit, @ClassID int,
@Pass bit,@Replace text,
@GatherPicArticle bit, @DrawWaterMark bit,
@IsExpert bit
AS
insert into TopWinCMS_ArticleGather
(Name,StartUrl,ClassArea,ClassNextPage,ShowArticleUrl,Title,Content,ShowArticleNextUrl,
ComeFrom,Author,UpdateTime,Filter,GatherNum,DownImg,ClassID,Pass,[Replace],
GatherPicArticle,DrawWaterMark,IsExpert)
values(@Name,@StartUrl,@ClassArea,@ClassNextPage,@ShowArticleUrl,@Title,@Content
,@ShowArticleNextUrl,@From,@Author,@UpdateTime,@Filter,@GatherNum,
@DownImg,@ClassID,@Pass,@Replace,@GatherPicArticle,@DrawWaterMark,@IsExpert)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE P_TopWinCMS_ArticleGather_Edit
@Name nvarchar(2000), @StartUrl nvarchar(2000),@ClassArea nvarchar(2000),
@ClassNextPage nvarchar(2000),@ShowArticleUrl nvarchar(2000),@Title nvarchar(2000),
@Content nvarchar(2000),@ShowArticleNextUrl nvarchar(2000),@From nvarchar(2000),
@Author nvarchar(2000),@UpdateTime nvarchar(2000),@Filter nvarchar(2000),
@GatherNum int,@DownImg bit, @ClassID int,
@ID int,@Pass bit,@Replace text,
@GatherPicArticle bit, @DrawWaterMark bit,@IsExpert bit
AS
update TopWinCMS_ArticleGather
set [Name]=@Name,StartUrl=@StartUrl, ClassArea=@ClassArea
,ClassNextPage=@ClassNextPage, ShowArticleUrl=@ShowArticleUrl ,Title=@Title
,Content=@Content ,ShowArticleNextUrl=@ShowArticleNextUrl,ComeFrom=@From
,Author=@Author,UpdateTime=@UpdateTime,Filter=@Filter
,GatherNum=@GatherNum,DownImg=@DownImg
,ClassID=@ClassID,Pass=@Pass,[Replace]=@Replace,GatherPicArticle=@GatherPicArticle
,DrawWaterMark=@DrawWaterMark,IsExpert=@IsExpert
where Id=@ID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE [P_TopWinCMS_Article_NewArticle]
@ClassID int,
@TOP int
AS
/*字段输出顺序跟要跟程序写的一样。*/
SET NOCOUNT ON;
if @ClassID =0
begin
SET ROWCOUNT @top
select ID,ModelID,ClassID,ClassName,Title,Author,[From],Hits,Stars,'' as Content,ColorStyle,FontStyle,UpdateTime
from VW_TopWinCMS_Article where deleted=0 and Pass=1 order by UpdateTime desc
end
else if @ClassID>0
begin
SET ROWCOUNT @top
select ID,ModelID,ClassID,ClassName,Title,Author,[From],Hits,Stars,Content,ColorStyle,FontStyle,UpdateTime
from VW_TopWinCMS_Article where deleted=0 and Pass=1 and ClassID in (Select ID FROM TopWinCMS_Class where Path Like (Select Path FROM TopWinCMS_Class where ID=@ClassID)+'%') order by UpdateTime desc
end
else if @ClassID=-1
begin
DECLARE @Path nvarchar(200)
DECLARE @SQL NVARCHAR(4000)
DECLARE t_cursor cursor
for SELECT Path From TopWinCMS_Class where ParentID=0 and IsShowInIndex=1 and LinkUrl =N'' and ModelID = (SELECT TOP 1 ID FROM TopWinCMS_Model WHERE DataTable='TopWinCMS_Article') order by RootID
set @SQL=''
open t_cursor
fetch next from t_cursor into @Path
while @@fetch_status=0
begin
set @SQL=@SQL + ' select TOP '+ cast( @TOP as varchar(4))+' ID,ModelID,ClassID,ClassName,Title,Author,[From],Hits,Stars,'''' as Content,ColorStyle,FontStyle,UpdateTime
from VW_TopWinCMS_Article where deleted=0 and Pass=1 and ClassID in
(select ID from TopWinCMS_Class where path like '''+@Path+'%'') order by UpdateTime desc'
fetch next from t_cursor into @Path
end
close t_cursor
deallocate t_cursor
--print(@SQL)
EXEC(@SQL)
end
SET NOCOUNT OFF

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

/*建立模型时自动生成P_表名_XGArticle */
CREATE PROCEDURE P_TopWinCMS_Article_XGArticle
@Top int,
@ID int,
@ModelID int,
@Key nvarchar(200)
AS
/*字段输出的顺序会影响程序执行*/
--读取相关内容
declare @SQL nvarchar(4000)
set @SQL='select top '+cast(@Top as nvarchar(50)) +' ID,ModelID,ClassID,Title,Hits,UpdateTime
from TopWinCMS_Article as A where Deleted = 0 And Pass = 1 and A.id <> '+cast(@ID as nvarchar(50)) +' and A.id in
(select ContentID from TopWinCMS_TagIndexs where ModelID='+ cast(@ModelID as nvarchar(10))+' and TagID in
(select id from TopWinCMS_Tags where  TagName in
(select Myvalues FROM my_split('''+@Key+''', ''|''))))'
--print @SQL
Execute(@SQL)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE  PROCEDURE [P_TopWinCMS_Class_Add]
@ClassID int,
@ClassName nvarchar(100),
@PicPath nvarchar(200),
@LinkUrl nvarchar(100),
@ClassName_EN nvarchar(100),
@TemplateFileName nvarchar(255),
@IsShowInIndex bit,
@ContentAdmin nvarchar(1000),
@ClassAdmin nvarchar(1000),
@ModelID int,
@FilePostfix nvarchar(10) ,
@FilePrefix nvarchar(10) ,
@URLStyle int ,
@ClassFilePostfix nvarchar(10) ,
@ClassFilePrefix nvarchar(10) ,
@ClassURLStyle int ,
@ClassIntro nvarchar(255) ,
@ClassPic nvarchar(255) ,
@ClassDescription nvarchar(500) ,
@ClassKeyWord nvarchar(500) ,
@OpenGrade int ,
@EnableContribute int ,
@EnableComment int
AS
declare @RootID nvarchar(100),@OrderID nvarchar(100),@Path nvarchar(100),@MaxID nvarchar(50)
declare @SelectID nvarchar(100) ,@Count int
if (@ClassID=0)--如果是要添加顶级栏目
begin
--检查是否已经有了栏目
select @Count= Count(ID) from TopWinCMS_Class where ModelID=@ModelID
if (@Count=0)
begin
insert into TopWinCMS_Class
(
ClassName,ParentID,RootID,PicPath,OrderID,
LinkUrl,HaveBaby,ClassName_EN,TemplateFileName,IsShowInIndex,
ContentAdmin,ClassAdmin,ModelID,FilePostfix,FilePrefix,
URLStyle,ClassFilePostfix,ClassFilePrefix,ClassURLStyle,ClassIntro,
ClassPic,ClassDescription,ClassKeyWord,OpenGrade,EnableContribute,
EnableComment
)
values
(
@ClassName,0,0,@PicPath,0,
@LinkUrl,0,@ClassName_EN,@TemplateFileName,@IsShowInIndex,
@ContentAdmin,@ClassAdmin,@ModelID,@FilePostfix,@FilePrefix,
@URLStyle,@ClassFilePostfix,@ClassFilePrefix,@ClassURLStyle,@ClassIntro,
@ClassPic,@ClassDescription,@ClassKeyWord,@OpenGrade,@EnableContribute,
@EnableComment
)
--取得刚刚添加的顶级栏目的ID号
select top 1 @SelectID= ID from TopWinCMS_Class  where ModelID=@ModelID
--更改刚刚添加的顶级栏目的初始根排序为0
update TopWinCMS_Class set RootID = 0  where ID = @SelectID
--更改刚刚添加的顶级栏目的导航条
update TopWinCMS_Class set path =@SelectID + '|' where ID = @SelectID
end
else
begin
--取得上个一级栏目的排序号大小
select @RootID=max(RootID) from TopWinCMS_Class where ModelID=@ModelID
insert into TopWinCMS_Class(ClassName,ParentID,RootID,PicPath
,LinkUrl,OrderID,HaveBaby,ClassName_EN,TemplateFileName,IsShowInIndex,ContentAdmin,ClassAdmin,ModelID,FilePostfix,FilePrefix,
URLStyle,ClassFilePostfix,ClassFilePrefix,ClassURLStyle,ClassIntro,
ClassPic,ClassDescription,ClassKeyWord,OpenGrade,EnableContribute,
EnableComment)
values
(@ClassName,@ClassID,@RootID+1,@PicPath,@LinkUrl,0,0,@ClassName_EN,@TemplateFileName,@IsShowInIndex,@ContentAdmin,@ClassAdmin,@ModelID,@FilePostfix,@FilePrefix,@URLStyle,@ClassFilePostfix,@ClassFilePrefix,@ClassURLStyle,@ClassIntro,@ClassPic,@ClassDescription,@ClassKeyWord,@OpenGrade,@EnableContribute,@EnableComment)
--取得刚刚添加的顶级栏目的ID号
select @SelectID=ID from TopWinCMS_Class where RootID = @RootID+1 and ModelID=@ModelID
--更改刚刚添加的顶级栏目的导航条
update TopWinCMS_Class set path =@SelectID + '|'  where RootID = @RootID+1 and ModelID=@ModelID
end
end
else--如果不是要添加顶级栏目
begin
--取得被选择栏目的相关数据
select @RootID=RootID,@OrderID=OrderID,@Path=Path from TopWinCMS_Class where ID=@ClassID
--被选择的栏目后来排的栏目的排序后退一步（必须是同一个顶级栏目下的,而其同级别的不加）
update TopWinCMS_Class set OrderID=OrderID+1 where OrderID>@OrderID and RootID=@RootID and
ID not in ( select ID from TopWinCMS_Class where path like ''+@path+'%' ) and ModelID=@ModelID
--取得跟将要添加的栏目的同级别栏目的最大的排序ID
select @OrderID=max(OrderID) from TopWinCMS_Class where path like ''+@path+'%' and ModelID=@ModelID
--添加新栏目,排序ID比原先的最大值大1.
insert into TopWinCMS_Class
(
ClassName,ParentID,RootID,OrderID,PicPath,
LinkUrl,Path,HaveBaby,ClassName_EN,TemplateFileName,IsShowInIndex,
ContentAdmin,ClassAdmin,ModelID,FilePostfix,FilePrefix,
URLStyle,ClassFilePostfix,ClassFilePrefix,ClassURLStyle,ClassIntro,
ClassPic,ClassDescription,ClassKeyWord,OpenGrade,EnableContribute,
EnableComment
)
values
(@ClassName,@ClassID,@RootID,@OrderID+1,@PicPath,@LinkUrl,@Path,0,@ClassName_EN,@TemplateFileName,@IsShowInIndex,@ContentAdmin,@ClassAdmin,@ModelID,@FilePostfix,@FilePrefix,@URLStyle,@ClassFilePostfix,@ClassFilePrefix,@ClassURLStyle,@ClassIntro,@ClassPic,@ClassDescription,@ClassKeyWord,@OpenGrade,@EnableContribute,@EnableComment)
--给父栏目的子栏目计数加1
update TopWinCMS_Class set HaveBaby=HaveBaby+1 where ID=@ClassID
--跟刚刚添加的栏目加上栏目导航
select @MaxID=max(ID) from TopWinCMS_Class
set @Path=@Path + @MaxID + '|'
update TopWinCMS_Class set Path=@Path where ID=@MaxID
end
select @@identity

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE [P_TopWinCMS_Class_Delete] @ID int AS
--删除栏目
declare
@ModelID int ,
@parentID int,
@OrderID int ,
@RootID int,
@Count int,
@path nvarchar(300)
SET NOCOUNT ON;
select @ModelID=ModelID,@parentID=parentID,@path=path,@OrderID=OrderID,@RootID=RootID from TopWinCMS_Class where ID=@ID
select @Count=Count(*) from TopWinCMS_Class where path like ''+@path+'%' and ModelID=@ModelID
if(@OrderID>0)
begin
--它的父栏目减一
update TopWinCMS_Class set Havebaby=Havebaby-1 where ID=@parentID
--与它同一个顶级栏目而又派在它后面的栏目排序减一
--update class set orderID=orderid-1 where path like ''+@path+'%'
--连同它的子栏目一起删除
delete from TopWinCMS_Class where path like ''+@path+'%' and ModelID=@ModelID
--排在它后面的栏目顶上去，而且是要同一个一级栏目的栏目
update TopWinCMS_Class set OrderID=OrderID-@Count where OrderID>=@OrderID+@Count and RootID=@RootID and ModelID=@ModelID
end
else--如果删的是一级栏目连同它的子栏目一起删除
begin
delete from TopWinCMS_Class where path like ''+@path+'%' and ModelID=@ModelID
update TopWinCMS_Class set RootID=RootID-1 where RootID>@RootID and ModelID=@ModelID
end
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE [P_TopWinCMS_Class_OrderByMove] @ID int ,@type nvarchar(30) AS
declare @ModelID int,@OrderID int,@parentID int,@MaxID int,@X int,@Y int ,@RootID int
declare @path1 nvarchar (300)--被进行操作的栏目的导航栏
declare @path2 nvarchar (300)
SET NOCOUNT ON;
select
@ModelID=ModelID,
@OrderID=OrderID ,
@path1=path,
@parentID=parentID,
@RootID =RootID from TopWinCMS_Class where ID=@ID
if(@type='up')
begin
if(@OrderID>0)
begin
--同级别的上面的栏目
select @path2 = path from TopWinCMS_Class
where OrderID=@OrderID-1 and parentID = @parentID
select @X=count(ID) from TopWinCMS_Class where path like ''+@path1+'%' and ModelID=@ModelID--被移上的栏目
select @Y=Count(ID) from TopWinCMS_Class where path like ''+@path2+'%' and ModelID=@ModelID
update TopWinCMS_Class set OrderID =OrderID - @Y where path like ''+@path1+'%' and ModelID=@ModelID--移上去
update TopWinCMS_Class set OrderID =OrderID + @X where path like ''+@path2+'%' and ModelID=@ModelID--移下去
end
else if(@OrderID=0)
begin
select @X=count(*) from TopWinCMS_Class where RootID<@RootID and ModelID=@ModelID
if (@X>0)--被选择的栏目上面还有栏目的时候才允许执行
begin
update TopWinCMS_Class set RootID =RootID +1 where RootID =@RootID-1 and ModelID=@ModelID
update TopWinCMS_Class set RootID =RootID -1 where path like ''+@path1+'%' and ModelID=@ModelID
end
end
end
if(@type='down')
begin
if(@OrderID>0)
begin
select @path2 = path from TopWinCMS_Class
where OrderID=@OrderID+1 and parentID = @parentID  and ModelID=@ModelID
select @X=count(ID) from TopWinCMS_Class where path like ''+@path1+'%' and ModelID=@ModelID--被移下的栏目
select @Y=Count(ID) from TopWinCMS_Class where path like ''+@path2+'%' and ModelID=@ModelID--被移上的栏目
update TopWinCMS_Class set OrderID =OrderID + @Y where path like ''+@path1+'%' and ModelID=@ModelID--移下去
update TopWinCMS_Class set OrderID =OrderID - @X where path like ''+@path2+'%' and ModelID=@ModelID--移上去
end
else if(@OrderID=0)
begin
select @X=count(*) from TopWinCMS_Class where RootID>@RootID and ModelID=@ModelID
if (@X>0)--被选择的栏目下面还有栏目的时候才允许执行
begin
update TopWinCMS_Class set RootID =RootID -1 where RootID =@RootID+1 and ModelID=@ModelID
update TopWinCMS_Class set RootID =RootID +1 where path like ''+@path1+'%' and ModelID=@ModelID
end
end
end
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE  PROCEDURE [P_TopWinCMS_Class_Path]
@ClassID int
AS
SET NOCOUNT ON
declare @Path nvarchar(300)
select @Path=Path from TopWinCMS_Class where id=@ClassID
select ID,ModelID,ClassName,ClassName_EN,LinkUrl from TopWinCMS_Class
where ID in (select Myvalues FROM my_split(@path, '|'))
SET NOCOUNT OFF

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE [P_TopWinCMS_Class_Show]
@ClassID int,
@ModelID int
as
--被选择的栏目的下级栏目及其层次的栏目
declare @DataTable nvarchar(50)
select @DataTable= DataTable from TopWinCMS_Model where ID=@ModelID
declare @SQL nvarchar (4000)
set @SQL='SELECT ID,ModelID,ClassName,ClassName_EN,LinkURL,
(SELECT count(ID) FROM '+ @DataTable +'
WHERE Pass=1 and Deleted=0 and ClassID=TopWinCMS_Class.ID) AS CountNum
FROM TopWinCMS_Class WHERE ParentID='+ cast( @ClassID as nvarchar(10))
exec(@SQL)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE [P_TopWinCMS_CountData]
@TableName nvarchar(100),
@WHERE nvarchar(4000)
AS
SET NOCOUNT ON;
declare @SQL nvarchar(4000)
set @SQL = 'Select Count(*) From ' + @TableName + ' WHERE ' + @WHERE
exec (@SQL)
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE  PROCEDURE [P_TopWinCMS_Digo_Add]
@ModelID int,
@ContentID int,
@Type int,
@LastUserName Nvarchar(50)
AS
SET NOCOUNT ON;
if exists(select ID from TopWinCMS_Digg where  ModelID = @ModelID and  ContentID=@ContentID  )
begin
if(@Type=1)
UPDATE TopWinCMS_Digg SET
[GoodNum] = GoodNum+1, [LastUserName] = @LastUserName,[LastDiggDate] = getdate()
WHERE [ModelID]=@ModelID and ContentID=@ContentID
else
UPDATE TopWinCMS_Digg SET
[BadNum] = BadNum+1, [LastUserName] = @LastUserName,[LastDiggDate] = getdate()
WHERE [ModelID]=@ModelID and ContentID=@ContentID
end
else
begin
INSERT INTO TopWinCMS_Digg
(
[ModelID],[ContentID],[GoodNum],[BadNum],[LastUserName],[LastDiggDate]
)
VALUES
(
@ModelID,@ContentID,0,0,@LastUserName,getdate()
)
end
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE P_TopWinCMS_GuestBook_Add
@name nvarchar(50),
@email nvarchar(100),
@Content nvarchar(2000),
@IP nvarchar(50),
@face nvarchar(50),
@humor nvarchar(50),
@qq nvarchar (13),
@home nvarchar(50),
@Privacy nvarchar(1)
AS
insert into TopWinCMS_GuestBook
([name],email,Content,IP,face,humor,qq,home,Privacy)
values
(@name,@email,@Content,@IP,@face,@humor,@qq,@home,@Privacy)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE P_TopWinCMS_Log_Add
@Admin nvarchar(50) ,
@Type nvarchar(12) ,
@Event nvarchar(250)
AS
declare @Count int
SET NOCOUNT ON;
select @Count=Count(ID) from TopWinCMS_Log
if (@Count>1000)
begin
Delete from TopWinCMS_Log where ID
= (select top 1 id from TopWinCMS_Log order by CheckInDate asc)
end
INSERT INTO TopWinCMS_Log
(
[Admin],[Type],[Event]
)
VALUES
(
@Admin,@Type,@Event
)
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE P_TopWinCMS_Member_Add
@Name nvarchar(50) ,
@PSW nvarchar(32) ,
@HomePage nvarchar(50) ,
@QQ nvarchar(50) ,
@PetName nvarchar(50) ,
@Introduce nvarchar(255) ,
@eMail nvarchar(150) ,
@Coin int ,
@Point int ,
@Question nvarchar(255) ,
@Answer nvarchar(255) ,
@Sex char(4) ,
@MemberRoleID int ,
@ActiveBBS bit ,
@ActiveBlog bit ,
@LastLoginIP nvarchar(50) ,
@TrueName nvarchar(50) ,
@MSN nvarchar(50) ,
@Birthday datetime ,
@Province nvarchar(50) ,
@City nvarchar(50) ,
@ICQ varchar(12) ,
@Yahoo varchar(40) ,
@Skype varchar(40) ,
@Location nvarchar(50) ,
@IdCard varchar(20) ,
@Mobile varchar(20) ,
@Phone varchar(20) ,
@Address nvarchar(255)
AS
set nocount on
if not exists(select ID from TopWinCMS_Member where [Name]=@Name)
begin
INSERT INTO TopWinCMS_Member
(
[Name],[PSW],[HomePage],[QQ],[PetName],[Introduce],[eMail],[Coin],[Point],[Question],[Answer],[Sex],[MemberRoleID],[ActiveBBS],[ActiveBlog],[LastLoginIP],[TrueName],[MSN],[Birthday],[Province],[City],[ICQ],[Yahoo],[Skype],[Location],[IdCard],[Mobile],[Phone],[Address]
)
VALUES
(
@Name,@PSW,@HomePage,@QQ,@PetName,@Introduce,@eMail,@Coin,@Point,@Question,@Answer,@Sex,@MemberRoleID,@ActiveBBS,@ActiveBlog,@LastLoginIP,@TrueName,@MSN,@Birthday,@Province,@City,@ICQ,@Yahoo,@Skype,@Location,@IdCard,@Mobile,@Phone,@Address
)
end
set nocount off

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE [P_TopWinCMS_Member_TryLogin]
@Name nvarchar(50),
@PSW nvarchar(32),
@LastLoginIP nvarchar(50)
AS
BEGIN
SET NOCOUNT ON;
if exists(select ID from TopWinCMS_Member where IsLocked=0 and Name=@Name and PSW=@PSW)
begin
update TopWinCMS_Member set LastLoginTime=getdate() ,LastLoginIP=@LastLoginIP where Name=@Name
/*
select M.ID as ID,[Name],[PetName],[Coin],[Point],[MemberRoleID],[RolePower],[RoleName],Rank,ActiveType from TopWinCMS_Member as M inner join TopWinCMS_MemberRole as R on M.MemberRoleID=R.ID where Name=@Name
*/
select 1
end
else
begin
select 0
end
SET NOCOUNT OFF
END

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROC [P_TopWinCMS_PageList]
@TableName    sysname,              --要分页显示的表名
@FieldKey  nvarchar(1000),      --用于定位记录的主键(惟一键)字段,可以是逗号分隔的多个字段
@PageNo int=1,              --要显示的页码
@PageSize  int=10,                --每页的大小(记录数)
@Fields nvarchar(1000)='',      --以逗号分隔的要显示的字段列表,如果不指定,则显示所有字段
@OrderField nvarchar(1000)='',      --以逗号分隔的排序字段列表,可以指定在字段后面指定DESC/ASC,用于指定排序顺序
@WHERE nvarchar(1000)=''    --查询条件
--@PageCount int OUTPUT            --总页数
AS
SET NOCOUNT ON
if(@WHERE='none' or @WHERE='')
set @WHERE=' 1=1'
declare @SQL varchar(8000)
if @PageNo=1
begin
set @SQL= 'Select Top '+cast(@PageSize as varchar(50)) +' '+ @Fields  +' From '+ @TableName +' WHERE '+@WHERE+' Order By '+ @OrderField
print @SQL
exec (@SQL)
end
else
begin
declare @CurPageNum int;
declare @nextpagenum int;
set @CurPageNum= (@PageNo-1 ) * @Pagesize
set @nextpagenum= @PageNo * @Pagesize
set @SQL='select '+@Fields+' from ( select top '+cast(@nextpagenum as varchar)+' * from '
+@TableName+' WHERE '+@WHERE+' order by '+@OrderField+' ) as '+@TableName+' where '+@FieldKey+' not in (
select top '+cast(@curpagenum as varchar)+' '+@FieldKey+' from '+@TableName+' WHERE '+@WHERE+'
order by '+@OrderField  +') order by ' + @OrderField
print @SQL
execute(@SQL)
end
SET NOCOUNT OFF

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE [P_TopWinCMS_Product_NewProduct]
@ClassID int,
@top int
AS
if @ClassID =0
begin
SET ROWCOUNT @top
select ID,ModelID,ClassID,ClassName,ProductName,Hits,Stars,PicUrl,BigPicUrl,UpdateTime,ColorStyle,FontStyle,'' as Content
from VW_TopWinCMS_Product where deleted=0 and Pass=1 order by UpdateTime desc
end
else if @ClassID>0
begin
SET ROWCOUNT @top
select ID,ModelID,ClassID,ClassName,ProductName,Hits,Stars,PicUrl,BigPicUrl,UpdateTime,ColorStyle,FontStyle,Content
from VW_TopWinCMS_Product where deleted=0 and Pass=1 and ClassID in (Select ID FROM TopWinCMS_Class where Path Like (Select Path FROM TopWinCMS_Class where ID=@ClassID)+'%') order by UpdateTime desc
end
else if @ClassID=-1
begin
DECLARE @Path nvarchar(200)
DECLARE @SQL NVARCHAR(4000)
DECLARE t_cursor cursor
for SELECT Path From TopWinCMS_Class where ParentID=0 and IsShowInIndex=1 and LinkUrl =N'' and ModelID = (SELECT TOP 1 ID FROM TopWinCMS_Model WHERE DataTable='TopWinCMS_Product') order by RootID
set @SQL=''
open t_cursor
fetch next from t_cursor into @Path
while @@fetch_status=0
begin
set @SQL=@SQL + ' select TOP '+ cast( @TOP as varchar(4))+' ID,ModelID,ClassID,ClassName,ProductName,Hits,Stars,PicUrl,BigPicUrl,UpdateTime,ColorStyle,FontStyle,'''' as Content
from VW_TopWinCMS_Product where deleted=0 and Pass=1 and ClassID in
(select ID from TopWinCMS_Class where path like '''+@Path+'%'') order by UpdateTime desc'
fetch next from t_cursor into @Path
end
close t_cursor
deallocate t_cursor
--print(@SQL)
EXEC(@SQL)
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

/*建立模型时自动生成P_表名_XGProduct */
CREATE PROCEDURE [P_TopWinCMS_Product_XGProduct]
@Top int,
@ID int,
@ModelID int,
@Key nvarchar(200)
AS
/*输出字段顺序要跟程序里面一致*/
--读取相关内容
declare @SQL nvarchar(4000)
set @SQL='select top '+cast(@Top as nvarchar(50)) +' ID,ClassID,ModelID,ProductName,Hits,UpdateTime
from TopWinCMS_Product as A where Deleted = 0 And Pass = 1 and A.id <> '+cast(@ID as nvarchar(50)) +' and A.id in
(select ContentID from TopWinCMS_TagIndexs where ModelID='+ cast(@ModelID as nvarchar(10))+' and TagID in
(select id from TopWinCMS_Tags where  TagName in
(select Myvalues FROM my_split('''+@Key+''', ''|''))))'
--print @SQL
Execute(@SQL)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE [P_TopWinCMS_RepaiRights]
@BaseModelID varchar,
@NewModelID int
AS
declare @T table(
[ID] [varchar](50) NOT NULL,
[Name] [nvarchar](50) NULL,
[ModelID] [varchar](4) NULL ,
[Code] [nvarchar](50) NULL,
[RootID] [int] NULL,
[OrderID] [int] NULL,
[ParentID] [varchar](50) NULL,
[IsAdmin] [int] NULL
)
Insert @T ([ID],[Name],[ModelID],[Code], [RootID], [OrderID], [ParentID], [IsAdmin] ) select [ID],[Name],[ModelID],[Code], [RootID], [OrderID], [ParentID], [IsAdmin]
from TopWinCMS_Rights where ModelID=@BaseModelID ORDER BY RootID,OrderID
declare @NewID varchar(50)
set @NewID=NewID()
--declare @NewModelID int
--select @NewModelID=Max([ID]) from TopWinCMS_Model
declare @MaxRootID int
select @MaxRootID=Max([RootID])+1 from TopWinCMS_Rights where ModelID<>''
declare @i int
select @i=count(*) from @T
print(@i)
while(@i>0)
begin
declare @ID [varchar](50)
declare @Name [nvarchar](50)
declare @ModelID [varchar](4)
declare @Code [nvarchar](50)
declare @RootID [int]
declare @OrderID [int]
declare @ParentID [varchar]
declare @IsAdmin [int]
select top 1 @ID=[ID],@Name=[Name],@ModelID=[ModelID],@Code=[Code], @RootID=[RootID], @OrderID=[OrderID], @ParentID=[ParentID],@IsAdmin=[IsAdmin] from @T
print(@ID)
if @i=0
begin
insert into
TopWinCMS_Rights
([ID],[ModelID], [Name], [Code], [RootID], [OrderID], [ParentID], [IsAdmin])
VALUES
(@NewID,@NewModelID,@Name,@Code,@MaxRootID,@OrderID,'',1)
end
else
begin
insert into
TopWinCMS_Rights
([ID],[ModelID], [Name], [Code], [RootID], [OrderID], [ParentID], [IsAdmin])
VALUES (NewID(),@NewModelID,@Name,@Code,@MaxRootID,@OrderID,@NewID,1)
end
set @i=@i-1
DELETE FROM @T WHERE ID=@ID
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE  PROCEDURE P_TopWinCMS_RepalceField
@ModelID int ,
@ClassField nvarchar(1000) ,
@OldString nvarchar(4000) ,
@NewString nvarchar(4000) ,
@ReplaceType int
AS
declare @Sql nvarchar(4000)
declare @TableName varchar(50)
select @TableName=DataTable from TopWinCMS_Model where ID=@ModelID
set @Sql='UPDATA ' + @TableName

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE P_TopWinCMS_SoftServer_Add
@ModelID int,
@ParentID int,
@ServerName nvarchar(255),
@DownURL nvarchar(255),
@ServerHTML nvarchar(255)
AS
declare @RootID int
SET NOCOUNT ON;
if(@ParentID=0)
begin
select @RootID=isnull(Max([RootID]),-1) from TopWinCMS_SoftServer where ParentID=0
INSERT INTO TopWinCMS_SoftServer
(
[ModelID],[ServerName],[DownURL],[ParentID],[RootID],[OrderID],[ServerHTML]
)
VALUES
(
@ModelID,@ServerName,@DownURL,0,@RootID+1,0,@ServerHTML
)
end
else
begin
declare @OrderID int
select @OrderID=max(OrderID) from TopWinCMS_SoftServer
where ParentID=@ParentID
select @RootID=RootID from TopWinCMS_SoftServer where ID =@ParentID
INSERT INTO TopWinCMS_SoftServer
(
[ModelID],[ServerName],[DownURL],[ParentID],[RootID],[OrderID],[ServerHTML]
)
VALUES
(
@ModelID,@ServerName,@DownURL,@ParentID,@RootID,@OrderID+1,@ServerHTML
)
end
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE P_TopWinCMS_SoftServer_Delete
@ID int
AS
declare @RootID int
declare @OrderID int
declare @ParentID int
SET NOCOUNT ON;
select @ParentID=ParentID,@RootID=RootID,@OrderID=OrderID from TopWinCMS_SoftServer where ID=@ID
if(@ParentID>0)
begin
delete from TopWinCMS_SoftServer where ID=@ID
update TopWinCMS_SoftServer set OrderID=OrderID-1  where ParentID =@ParentID and OrderID>@OrderID
end
else
begin
delete from TopWinCMS_SoftServer where ID=@ID
update TopWinCMS_SoftServer set RootID=RootID-1  where RootID>@RootID
end
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE P_TopWinCMS_Soft_DownLoads @ID int AS
declare @LastHitTime datetime
SET NOCOUNT ON;
select @LastHitTime=LastHitTime from TopWinCMS_Soft where ID=@ID
update TopWinCMS_Soft set Hits=Hits+1 where ID=@ID
if datediff(D,@LastHitTime ,getdate())<=0
update TopWinCMS_Soft set DayHits=DayHits+1 where ID=@ID
else
update TopWinCMS_Soft set DayHits= 1 where ID=@ID
if datediff(ww,@LastHitTime,getdate())<=0
update TopWinCMS_Soft set WeekHits= WeekHits+1 where ID=@ID
else
update TopWinCMS_Soft set WeekHits= 1 where ID=@ID
if datediff(m,@LastHitTime,getdate())<=0
update TopWinCMS_Soft set MonthHits= MonthHits+1 where ID=@ID
else
update TopWinCMS_Soft set MonthHits= 1 where ID=@ID
update TopWinCMS_Soft set LastHitTime= getdate() where ID=@ID
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE [P_TopWinCMS_Soft_NewSoft]
@ClassID int,
@TOP int
AS
/*字段输出顺序要跟程序里面的一样*/
SET NOCOUNT ON
if @ClassID =0
begin
SET ROWCOUNT @top
select ID,ModelID,ClassID,ClassName,SoftName,SoftVersion,SoftSize,ColorStyle,FontStyle,UpdateTime,Stars,Hits,'' as Content
from VW_TopWinCMS_Soft where deleted=0 and Pass=1
order by UpdateTime desc
end
else if @ClassID>0
begin
SET ROWCOUNT @top
select ID,ModelID,ClassID,ClassName,SoftName,SoftVersion,SoftSize,ColorStyle,FontStyle,UpdateTime,Stars,Hits,Content
from VW_TopWinCMS_Soft
where deleted=0 and Pass=1 and ClassID in (Select ID FROM TopWinCMS_Class where Path Like (Select Path FROM TopWinCMS_Class where ID=@ClassID)+'%')
order by UpdateTime desc
end
else if @ClassID=-1
begin
DECLARE @Path nvarchar(200)
DECLARE @SQL NVARCHAR(4000)
DECLARE t_cursor cursor
for SELECT Path From TopWinCMS_Class where ParentID=0 and IsShowInIndex=1 and LinkUrl =N'' and ModelID = (SELECT TOP 1 ID FROM TopWinCMS_Model WHERE DataTable='TopWinCMS_Soft') order by RootID
set @SQL=''
open t_cursor
fetch next from t_cursor into @Path
while @@fetch_status=0
begin
set @SQL=@SQL + ' select TOP '+ cast( @TOP as varchar(4))+' ID,ModelID,ClassID,ClassName,SoftName,SoftVersion,SoftSize,ColorStyle,FontStyle,UpdateTime,Stars,Hits,'''' as Content
from VW_TopWinCMS_Soft where deleted=0 and Pass=1 and ClassID in
(select ID from TopWinCMS_Class where path like '''+@Path+'%'') order by UpdateTime desc'
fetch next from t_cursor into @Path
end
close t_cursor
deallocate t_cursor
--print(@SQL)
EXEC(@SQL)
end
SET NOCOUNT OFF

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE  PROCEDURE [P_TopWinCMS_Soft_XGSoft]
@Top int,
@ID int,
@ModelID int,
@Key nvarchar(200)
AS
--读取相关内容
declare @SQL nvarchar(4000)
set @SQL='select top '+cast(@Top as nvarchar(50)) +' ID,ModelID,ClassID,ClassName,SoftName,SoftVersion,SoftSize,
Stars,Hits,ColorStyle,FontStyle,UpdateTime
from VW_TopWinCMS_Soft as A where Deleted = 0 And Pass = 1 and A.id <> '+cast(@ID as nvarchar(50)) +' and A.id in
(select ContentID from TopWinCMS_TagIndexs where ModelID='+ cast(@ModelID as nvarchar(10))+' and TagID in
(select id from TopWinCMS_Tags where  TagName in
(select Myvalues FROM my_split('''+@Key+''', ''|''))))'
--print @SQL
Execute(@SQL)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE  PROCEDURE [P_TopWinCMS_Special_Add]
@SpecialID int,
@ModelID int,
@SpecialName nvarchar(100),
@SpecialName_EN nvarchar(100),
@LinkUrl nvarchar(100),
@IsShowInIndex int,
@TemplateFileName nvarchar(255),
@ContentAdmin nvarchar(1000),
@SpecialAdmin nvarchar(1000),
@SpecialFilePostfix nvarchar(10) ,
@SpecialFilePrefix nvarchar(10) ,
@SpecialURLStyle nvarchar(50) ,
@SpecialIntro nvarchar(255) ,
@SpecialPic nvarchar(255) ,
@SpecialDescription nvarchar(500) ,
@SpecialKeyWord nvarchar(500) ,
@OpenGrade int
AS
declare @RootID nvarchar(100),@OrderID nvarchar(100),@Path nvarchar(100),@MaxID nvarchar(50)
declare @SelectID nvarchar(100) ,@Count int
if (@SpecialID=0)--如果是要添加顶级栏目
begin
--检查是否已经有了栏目
select @Count= Count(ID) from TopWinCMS_Special
if (@Count=0)
begin
insert into TopWinCMS_Special
(
SpecialName,ParentID,RootID,OrderID,
LinkUrl,HaveBaby,SpecialName_EN,TemplateFileName,IsShowInIndex,
ContentAdmin,SpecialAdmin,ModelID,SpecialFilePostfix,
SpecialFilePrefix,SpecialURLStyle,SpecialIntro,
SpecialPic,SpecialDescription,SpecialKeyWord,OpenGrade
)
values
(
@SpecialName,0,0,0,
@LinkUrl,0,@SpecialName_EN,@TemplateFileName,@IsShowInIndex,
@ContentAdmin,@SpecialAdmin,@ModelID,
@SpecialFilePostfix,@SpecialFilePrefix,@SpecialURLStyle,@SpecialIntro,
@SpecialPic,@SpecialDescription,@SpecialKeyWord,@OpenGrade
)
--取得刚刚添加的顶级栏目的ID号
select top 1 @SelectID= ID from TopWinCMS_Special
--更改刚刚添加的顶级栏目的初始根排序为0
update TopWinCMS_Special set RootID = 0  where ID = @SelectID
--更改刚刚添加的顶级栏目的导航条
update TopWinCMS_Special set path =@SelectID + '|' where ID = @SelectID
end
else
begin
--取得上个一级栏目的排序号大小
select @RootID=max(RootID) from TopWinCMS_Special
insert into TopWinCMS_Special
(
SpecialName,ParentID,RootID,
LinkUrl,OrderID,HaveBaby,SpecialName_EN,TemplateFileName,
IsShowInIndex,ContentAdmin,SpecialAdmin,ModelID,
SpecialFilePostfix,SpecialFilePrefix,SpecialURLStyle,
SpecialIntro,SpecialPic,SpecialDescription,SpecialKeyWord,OpenGrade
)
values
(@SpecialName,@SpecialID,@RootID+1,@LinkUrl,0,0,@SpecialName_EN,@TemplateFileName,
@IsShowInIndex,@ContentAdmin,@SpecialAdmin,@ModelID,
@SpecialFilePostfix,@SpecialFilePrefix,@SpecialURLStyle,@SpecialIntro,@SpecialPic,
@SpecialDescription,@SpecialKeyWord,@OpenGrade)
--取得刚刚添加的顶级栏目的ID号
select @SelectID=ID from TopWinCMS_Special where RootID = @RootID+1
--更改刚刚添加的顶级栏目的导航条
update TopWinCMS_Special set path =@SelectID + '|'  where RootID = @RootID+1
end
end
else--如果不是要添加顶级栏目
begin
--取得被选择栏目的相关数据
select @RootID=RootID,@OrderID=OrderID,@Path=Path from TopWinCMS_Special where ID=@SpecialID
--被选择的栏目后来排的栏目的排序后退一步（必须是同一个顶级栏目下的,而其同级别的不加）
update TopWinCMS_Special set OrderID=OrderID+1 where OrderID>@OrderID and RootID=@RootID and
ID not in ( select ID from TopWinCMS_Special where path like ''+@path+'%' )
--取得跟将要添加的栏目的同级别栏目的最大的排序ID
select @OrderID=max(OrderID) from TopWinCMS_Special where path like ''+@path+'%'
--添加新栏目,排序ID比原先的最大值大1.
insert into TopWinCMS_Special
(
SpecialName,ParentID,RootID,OrderID,
LinkUrl,Path,HaveBaby,SpecialName_EN,TemplateFileName,IsShowInIndex,
ContentAdmin,SpecialAdmin,ModelID,SpecialFilePostfix,SpecialFilePrefix,SpecialURLStyle,SpecialIntro,
SpecialPic,SpecialDescription,SpecialKeyWord,OpenGrade
)
values
(@SpecialName,@SpecialID,@RootID,@OrderID+1,@LinkUrl,@Path,0,@SpecialName_EN,@TemplateFileName,@IsShowInIndex,@ContentAdmin,@SpecialAdmin,@ModelID,@SpecialFilePostfix,@SpecialFilePrefix,@SpecialURLStyle,@SpecialIntro,@SpecialPic,@SpecialDescription,
@SpecialKeyWord,@OpenGrade)
--给父栏目的子栏目计数加1
update TopWinCMS_Special set HaveBaby=HaveBaby+1 where ID=@SpecialID
--跟刚刚添加的栏目加上栏目导航
select @MaxID=max(ID) from TopWinCMS_Special
set @Path=@Path + @MaxID + '|'
update TopWinCMS_Special set Path=@Path where ID=@MaxID
end
select @@identity

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE [P_TopWinCMS_Special_Delete] @ID int AS
--删除栏目
declare @parentID int,@OrderID int ,@RootID int,@Count int,@path nvarchar(300)
SET NOCOUNT ON;
select @parentID=parentID,@path=path,@OrderID=OrderID,@RootID=RootID from TopWinCMS_Special where ID=@ID
select @Count=Count(*) from TopWinCMS_Special where path like ''+@path+'%'
if(@OrderID>0)
begin
--它的父栏目减一
update TopWinCMS_Special set Havebaby=Havebaby-1 where ID=@parentID
--与它同一个顶级栏目而又派在它后面的栏目排序减一
--update Special set orderID=orderid-1 where path like ''+@path+'%'
--连同它的子栏目一起删除
delete from TopWinCMS_Special where path like ''+@path+'%'
--排在它后面的栏目顶上去，而且是要同一个一级栏目的栏目
update TopWinCMS_Special set OrderID=OrderID-@Count where OrderID>=@OrderID+@Count and RootID=@RootID
end
else--如果删的是一级栏目连同它的子栏目一起删除
begin
delete from TopWinCMS_Special where path like ''+@path+'%'
update TopWinCMS_Special set RootID=RootID-1 where RootID>@RootID
end
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE [P_TopWinCMS_Special_FindFellowID]
@SpecialID int
AS
declare @path nvarchar(300)
if @SpecialID =0
begin
select * from TopWinCMS_Special
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE [P_TopWinCMS_Special_OrderByMove] @ID int ,@type nvarchar(30) AS
declare @OrderID int,@parentID int,@MaxID int,@X int,@Y int ,@RootID int
declare @path1 nvarchar (300)--被进行操作的栏目的导航栏
declare @path2 nvarchar (300)
SET NOCOUNT ON;
select @OrderID=OrderID ,@path1=path, @parentID=parentID,@RootID =RootID
from TopWinCMS_Special where ID=@ID
if(@type='up')
begin
if(@OrderID>0)
begin
--同级别的上面的栏目
select @path2 = path from TopWinCMS_Special
where OrderID=@OrderID-1 and parentID = @parentID
select @X=count(ID) from TopWinCMS_Special where path like ''+@path1+'%'--被移上的栏目
select @Y=Count(ID) from TopWinCMS_Special where path like ''+@path2+'%'
update TopWinCMS_Special set OrderID =OrderID - @Y where path like ''+@path1+'%'--移上去
update TopWinCMS_Special set OrderID =OrderID + @X where path like ''+@path2+'%'--移下去
end
else if(@OrderID=0)
begin
select @X=count(*) from TopWinCMS_Special where RootID<@RootID
if (@X>0)--被选择的栏目上面还有栏目的时候才允许执行
begin
update TopWinCMS_Special set RootID =RootID +1 where RootID =@RootID-1
update TopWinCMS_Special set RootID =RootID -1 where path like ''+@path1+'%'
end
end
end
if(@type='down')
begin
if(@OrderID>0)
begin
select @path2 = path from TopWinCMS_Special
where OrderID=@OrderID+1 and parentID = @parentID
select @X=count(ID) from TopWinCMS_Special where path like ''+@path1+'%'--被移下的栏目
select @Y=Count(ID) from TopWinCMS_Special where path like ''+@path2+'%'--被移上的栏目
update TopWinCMS_Special set OrderID =OrderID + @Y where path like ''+@path1+'%'--移下去
update TopWinCMS_Special set OrderID =OrderID - @X where path like ''+@path2+'%'--移上去
end
else if(@OrderID=0)
begin
select @X=count(*) from TopWinCMS_Special where RootID>@RootID
if (@X>0)--被选择的栏目下面还有栏目的时候才允许执行
begin
update TopWinCMS_Special set RootID =RootID -1 where RootID =@RootID+1
update TopWinCMS_Special set RootID =RootID +1 where path like ''+@path1+'%'
end
end
end
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE  PROCEDURE [P_TopWinCMS_Special_Path]
@SpecialID int
AS
SET NOCOUNT ON;
declare @path nvarchar(300)
select @path=path from TopWinCMS_Special where id=@SpecialID
select ID,ModelID,SpecialName,SpecialName_EN,LinkUrl from TopWinCMS_Special
where ID in (select Myvalues FROM my_split(@path, '|'))
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE [P_TopWinCMS_Special_Show]
@SpecialID Int,
@ModelID Int
as
SET NOCOUNT ON;
declare @DataTable nvarchar(50)
select @DataTable= DataTable from TopWinCMS_Model where ID=@ModelID
declare @SQL nvarchar (4000)
set @SQL='select ID,ModelID,SpecialName,SpecialName_EN,LinkURL,
(select count(ID) from '+ @DataTable +'
where Pass=1 and deleted=0 and SpecialID=TopWinCMS_Special.ID) as CountNum
From TopWinCMS_Special where Parentid='+ cast( @SpecialID as nvarchar(10))
exec(@SQL)
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE    PROCEDURE [P_TopWinCMS_Tags]
@tags nvarchar(200),
@ModelID int,
@ContentID int,
@MemberID int
as
if @tags =N''
return
delete TopWinCMS_TagIndexs where ModelID=@ModelID and ContentID=@ContentID
declare
@index int,
@tagid int,
@tag nvarchar(50),
@counts int
SET NOCOUNT ON;
set @index = charindex(N'|', @tags, 0)
while(@index>0)
begin
set @tag = Left(@tags, @index-1)
if exists(select top 1 * from TopWinCMS_Tags where tagName=@tag and ModelID=@ModelID)
begin
select @tagid=id from TopWinCMS_Tags where tagName=@tag and ModelID=@ModelID
select @counts=count(*) from TopWinCMS_TagIndexs where tagid=@tagid
update TopWinCMS_Tags set counts=@counts+1 where id=@tagid and ModelID=@ModelID
end
else
begin
if  @tag <> N''
begin
insert into TopWinCMS_Tags (tagName,ModelID,Counts,ViewCounts,MemberID,Flag)
values(@tag,@ModelID,1,0,@MemberID,0)
select @tagid = @@identity
end
end
insert into TopWinCMS_TagIndexs (ModelID, ContentID, tagid) values(@ModelID, @ContentID, @tagid)
set @tags = Right(@tags, len(@tags)-@index)
set @index = charindex(N'|', @tags, 0)
end
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

/*
初始化关键字
*/
CREATE  PROCEDURE [P_TopWinCMS_Tags_InitData] AS
DECLARE @ID int
DECLARE @Total int
set @ID=1
SET NOCOUNT ON;
select @Total=max(id)+1 from TopWinCMS_Article -- 故意不加where
while(@ID<@Total)
begin
if exists(select ID from TopWinCMS_Article where ID=@ID)
begin
DECLARE @tags nvarchar(200)
DECLARE @ModelID int
DECLARE @ContentID int
DECLARE @MemberID int
select @tags=[Key],@ModelID=ModelID from TopWinCMS_Article where ID=@ID
set @ContentID = @ID
set @MemberID = 0
EXEC [P_TopWinCMS_Tags] @tags, @ModelID, @ContentID, @MemberID
print 'ID:'+ convert(varchar(10),@ID)
end
set @ID=@ID+1
end
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE    PROCEDURE P_TopWinCMS_Templates_UsedIt
@ID int
AS
SET NOCOUNT ON;
update TopWinCMS_Templates set IsUsed = 0 where ID <>@ID
update TopWinCMS_Templates set IsUsed = 1 where ID = @ID
declare @t table (mid int ,DataTable nvarchar(50),BaseModel nvarchar(50))
insert into @t (mid,DataTable,BaseModel) select ID,DataTable,BaseModel From TopWinCMS_Model  where Hide=0
declare @ArticleShow nvarchar(255)
declare @ArticleClass nvarchar(255)
declare @ArticleSpecial nvarchar(255)
declare @ArticleChannelIndex nvarchar(255)
declare @SoftShow nvarchar(255)
declare @SoftClass nvarchar(255)
declare @SoftSpecial nvarchar(255)
declare @SoftChannelIndex nvarchar(255)
declare @ProductShow nvarchar(255)
declare @ProductClass nvarchar(255)
declare @ProductSpecial nvarchar(255)
declare @ProductChannelIndex nvarchar(255)
select
@ArticleShow=ArticleShow ,
@ArticleClass=ArticleClass,
@ArticleSpecial=ArticleSpecial,
@ArticleChannelIndex=ArticleChannelIndex,
@SoftShow=SoftShow,
@SoftClass=SoftClass,
@SoftSpecial=SoftSpecial,
@SoftChannelIndex=SoftChannelIndex,
@ProductShow=ProductShow,
@ProductClass=ProductClass,
@ProductSpecial=ProductSpecial,
@ProductChannelIndex=ProductChannelIndex
FROM TopWinCMS_Templates where ID=@ID
while exists(select * from @t )
begin
declare @mid int
declare @DataTable nvarchar(50)
declare @BaseModel nvarchar(50)
select Top 1 @mid=mid,@DataTable=DataTable,@BaseModel=BaseModel from @t
declare @SQL nvarchar(4000)
if (@BaseModel = 'Soft')
begin
set @SQL='update '+ @DataTable +' SET TemplateFileName='''+ @SoftShow +''''
Execute(@SQL)
--print @SQL
update TopWinCMS_Model SET TemplateFileName=@SoftChannelIndex WHERE ID=@mid
update TopWinCMS_Class SET TemplateFileName=@SoftClass WHERE ModelID=@mid
update TopWinCMS_Special SET TemplateFileName=@SoftSpecial WHERE ModelID=@mid
end
if(@BaseModel = 'Article')
begin
set @SQL='update '+ @DataTable +' SET TemplateFileName='''+ @ArticleShow +''''
Execute(@SQL)
--print @SQL
update TopWinCMS_Model SET TemplateFileName=@ArticleChannelIndex WHERE ID=@mid
update TopWinCMS_Class SET TemplateFileName=@ArticleClass WHERE ModelID=@mid
update TopWinCMS_Special SET TemplateFileName=@ArticleSpecial WHERE ModelID=@mid
end
if(@BaseModel = 'Product')
begin
set @SQL='update '+ @DataTable +' SET TemplateFileName='''+ @ProductShow +''''
Execute(@SQL)
--print @SQL
update TopWinCMS_Model SET TemplateFileName=@ProductChannelIndex WHERE ID=@mid
update TopWinCMS_Class SET TemplateFileName=@ProductClass WHERE ModelID=@mid
update TopWinCMS_Special SET TemplateFileName=@ProductSpecial WHERE ModelID=@mid
end
delete @t where mid=@mid
end
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE P_TopWinCMS_Vote_Add
@Title nvarchar(50) ,
@Pass int ,
@VoteType int ,
@PicUrl nvarchar(255) ,
@EndData datetime ,
@windowsize nvarchar(50) ,
@TemplateFileName nvarchar(255) ,
@LimitIP int
AS
INSERT INTO TopWinCMS_Vote
(
[Title],[Pass], [VoteType],[PicUrl],[EndData],[windowsize],[TemplateFileName],[LimitIP]
)
VALUES
(
@Title,@Pass, @VoteType,@PicUrl,@EndData,@windowsize,@TemplateFileName,@LimitIP
)
select @@identity

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[P_TopWinCMS_Words_InitData]
 
AS
BEGIN
 
	SET NOCOUNT ON;

	declare
	@index int,
	@word nvarchar(50) 
 
	SELECT @index=(charindex(CHAR(13), cast( BanWord as varchar(4000)), 0)) FROM TopWinCMS_Ban
 	while(@index>0)
	begin
		print (@index)
		set @word = Left(@word, @index-1)
	print (@word)
		set @word = Right(@word, len(@word)-@index)
		set @index = charindex(N'|', @word, 0)
	
		SELECT (@word)
	end
 
	SET NOCOUNT OFF;
END

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE    PROCEDURE P_TopWinCMS_WorkStatDiary_SaveDiary
@UserName nvarchar(50),
@Type int ,
@ModelID int
AS
declare @DateTime datetime
set @DateTime = getdate()
SET NOCOUNT ON;
if exists(select top 1 * from TopWinCMS_WorkStatDiary where username=@username and type=@type and ModelID=@ModelID and datediff(D,LastTime ,getdate())=0)
begin
declare @LastTime datetime
select top 1 @LastTime=LastTime from TopWinCMS_WorkStatDiary where username=@username and type=@type and ModelID=@ModelID
order by LastTime desc
--更新当日数据
update TopWinCMS_WorkStatDiary set Stat=Stat+1 , DayStat=DayStat+1 , LastTime= getdate()
where username=@username and type=@type and ModelID=@ModelID
and datediff(D,@LastTime ,getdate())=0
--更新本周数据
update TopWinCMS_WorkStatDiary set WeekStat= WeekStat+1 where username=@username and type=@type and ModelID=@ModelID
and datediff(ww,@LastTime ,getdate())=0
--更新本月数据
update TopWinCMS_WorkStatDiary set MonthStat= MonthStat+1 where username=@username and type=@type and ModelID=@ModelID
and datediff(m,@LastTime ,getdate())=0
--更新本年数据
update TopWinCMS_WorkStatDiary set YearStat= YearStat+1 where username=@username and type=@type and ModelID=@ModelID
and datediff(y,@LastTime ,getdate())=0
end
else
begin
INSERT INTO [TopWinCMS_WorkStatDiary]( [UserName],[Stat], [DayStat], [WeekStat], [MonthStat], [YearStat], [Type], [ModelID], [LastTime])
VALUES(@UserName ,1, 1,1,1,1,@Type,@ModelID,getdate())
end
SET NOCOUNT OFF;

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE  PROCEDURE P_TopWinCMS_WorkStatDiary_Total @ModelID int,@DateTime datetime
AS
SELECT dbo.VW_TopWinCMS_WorkStatDiary.username,
dbo.TopWinCMS_AdminRole.RoleName,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.AddDay) AS AddDay,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.AddWeek) AS AddWeek,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.AddMonth) AS AddMonth,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.AddYear) AS AddYear,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.DelWeek) AS DelWeek,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.DelDay) AS DelDay,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.DelMonth) AS DelMonth,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.DelYear) AS DelYear,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.EditWeek) AS EditWeek,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.EditMonth) AS EditMonth,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.EditYear) AS EditYear,
SUM(dbo.VW_TopWinCMS_WorkStatDiary.EditDay) AS EditDay
FROM dbo.TopWinCMS_Admin INNER JOIN
dbo.TopWinCMS_AdminRole ON
dbo.TopWinCMS_Admin.RoleID = dbo.TopWinCMS_AdminRole.ID INNER JOIN
dbo.VW_TopWinCMS_WorkStatDiary ON
dbo.TopWinCMS_Admin.UserName = dbo.VW_TopWinCMS_WorkStatDiary.username
WHERE (dbo.VW_TopWinCMS_WorkStatDiary.ModelID = @ModelID) and datediff(D,@DateTime ,LastTime)=0
GROUP BY dbo.VW_TopWinCMS_WorkStatDiary.username,
dbo.TopWinCMS_AdminRole.RoleName

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO
 