/****** Object:  Table [ynhtm_Category]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_Category]') AND type in (N'U'))
DROP TABLE [ynhtm_Category]

/****** Object:  Table [ynhtm_Comment]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_Comment]') AND type in (N'U'))
DROP TABLE [ynhtm_Comment]

/****** Object:  StoredProcedure [ynhtm_GetPage]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_GetPage]') AND type in (N'P', N'PC'))
DROP PROCEDURE [ynhtm_GetPage]

/****** Object:  Table [ynhtm_Job]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_Job]') AND type in (N'U'))
DROP TABLE [ynhtm_Job]

/****** Object:  Table [ynhtm_JobTry]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_JobTry]') AND type in (N'U'))
DROP TABLE [ynhtm_JobTry]

/****** Object:  Table [ynhtm_Link]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_Link]') AND type in (N'U'))
DROP TABLE [ynhtm_Link]

/****** Object:  Table [ynhtm_Post]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_Post]') AND type in (N'U'))
DROP TABLE [ynhtm_Post]

/****** Object:  Table [ynhtm_Setting]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_Setting]') AND type in (N'U'))
DROP TABLE [ynhtm_Setting]

/****** Object:  Table [ynhtm_User]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_User]') AND type in (N'U'))
DROP TABLE [ynhtm_User]

/****** Object:  Default [DF_ynhtm_Category_CreateDate]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_Category_CreateDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_Category]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_Category_CreateDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_Category] DROP CONSTRAINT [DF_ynhtm_Category_CreateDate]
END


End

/****** Object:  Default [DF_ynhtm_Comment_PostDate]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_Comment_PostDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_Comment]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_Comment_PostDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_Comment] DROP CONSTRAINT [DF_ynhtm_Comment_PostDate]
END


End

/****** Object:  Default [DF_ynhtm_Job_CreateDate]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_Job_CreateDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_Job]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_Job_CreateDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_Job] DROP CONSTRAINT [DF_ynhtm_Job_CreateDate]
END


End

/****** Object:  Default [DF_ynhtm_JobTry_PostDate]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_JobTry_PostDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_JobTry]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_JobTry_PostDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_JobTry] DROP CONSTRAINT [DF_ynhtm_JobTry_PostDate]
END


End

/****** Object:  Default [DF_ynhtm_Link_CreateDate]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_Link_CreateDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_Link]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_Link_CreateDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_Link] DROP CONSTRAINT [DF_ynhtm_Link_CreateDate]
END


End

/****** Object:  Default [DF_ynhtm_Post_LastDate]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_Post_LastDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_Post]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_Post_LastDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_Post] DROP CONSTRAINT [DF_ynhtm_Post_LastDate]
END


End

/****** Object:  Default [DF_ynhtm_Post_CreateDate]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_Post_CreateDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_Post]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_Post_CreateDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_Post] DROP CONSTRAINT [DF_ynhtm_Post_CreateDate]
END


End

/****** Object:  Default [DF_ynhtm_Setting_CreateDate]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_Setting_CreateDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_Setting]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_Setting_CreateDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_Setting] DROP CONSTRAINT [DF_ynhtm_Setting_CreateDate]
END


End

/****** Object:  Default [DF_ynhtm_User_RegDate]    Script Date: 09/01/2011 23:20:18 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_User_RegDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_User]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_User_RegDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_User] DROP CONSTRAINT [DF_ynhtm_User_RegDate]
END


End

/****** Object:  Table [ynhtm_User]    Script Date: 09/01/2011 23:20:18 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_User]') AND type in (N'U'))
BEGIN
CREATE TABLE [ynhtm_User](
	[UserID] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [nvarchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[PassWord] [char](32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[OAuthQzoneID] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[RealName] [nvarchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Email] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Description] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[IsLock] [bit] NOT NULL,
	[IsAdmin] [bit] NOT NULL,
	[PostCount] [int] NOT NULL,
	[CommentCount] [int] NOT NULL,
	[LoginCount] [int] NOT NULL,
	[LastIP] [nvarchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[LastDate] [datetime] NULL,
	[RegIP] [nvarchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[RegDate] [datetime] NOT NULL,
 CONSTRAINT [PK_ynhtm_User] PRIMARY KEY CLUSTERED 
(
	[UserID] ASC,
	[UserName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[ynhtm_User]') AND name = N'IX_ynhtm_User')
CREATE NONCLUSTERED INDEX [IX_ynhtm_User] ON [ynhtm_User] 
(
	[OAuthQzoneID] ASC,
	[PassWord] ASC,
	[IsLock] ASC,
	[Email] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)

/****** Object:  Table [ynhtm_Setting]    Script Date: 09/01/2011 23:20:18 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_Setting]') AND type in (N'U'))
BEGIN
CREATE TABLE [ynhtm_Setting](
	[SiteName] [nvarchar](80) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[SiteUrl] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[SiteEnabled] [bit] NOT NULL,
	[MetaKeyWord] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[MetaDescr] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Theme] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[WapTheme] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[WapEnabled] [bit] NOT NULL,
	[WapDomain] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[AuthcodeEnabled] [bit] NOT NULL,
	[MapEnabled] [bit] NOT NULL,
	[MapRowCount] [int] NOT NULL,
	[TotalType] [int] NOT NULL,
	[CacheEnabled] [bit] NOT NULL,
	[CacheExpire] [int] NOT NULL,
	[CacheType] [int] NOT NULL,
	[OAuthQzoneEnabled] [bit] NOT NULL,
	[OAuthQzoneAppID] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[OAuthQzoneAppKey] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[UserCount] [int] NOT NULL,
	[RssEnabled] [bit] NOT NULL,
	[RssRowCount] [int] NOT NULL,
	[RssShowType] [int] NOT NULL,
	[PageSize] [int] NOT NULL,
	[PostCount] [int] NOT NULL,
	[CommentEnabled] [bit] NOT NULL,
	[CommentSort] [int] NOT NULL,
	[CommentPageSize] [int] NOT NULL,
	[CommentAudit] [int] NOT NULL,
	[CommentDirty] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[CommentCount] [int] NOT NULL,
	[PicMaskEnabled] [bit] NOT NULL,
	[PicMaskFile] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[PicMaskPos] [int] NOT NULL,
	[PicQuality] [int] NOT NULL,
	[UpfileCount] [int] NOT NULL,
	[UpfileSize] [bigint] NOT NULL,
	[JobCount] [int] NOT NULL,
	[JobTryCount] [int] NOT NULL,
	[CodeHead] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[CodeFoot] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[CreateDate] [datetime] NOT NULL
)
END

/****** Object:  Table [ynhtm_Post]    Script Date: 09/01/2011 23:20:18 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_Post]') AND type in (N'U'))
BEGIN
CREATE TABLE [ynhtm_Post](
	[PostID] [int] IDENTITY(1,1) NOT NULL,
	[CategoryID] [int] NULL,
	[UserID] [int] NOT NULL,
	[Url] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Rewrite] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Theme] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Face] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Title] [nvarchar](80) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[TitleStyle] [int] NOT NULL,
	[TitleColor] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Summary] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Content] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Source] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Author] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Tags] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Enabled] [bit] NOT NULL,
	[IsTop] [bit] NOT NULL,
	[IsHide] [bit] NOT NULL,
	[IsPic] [bit] NOT NULL,
	[IsFace] [bit] NOT NULL,
	[ViewCount] [int] NOT NULL,
	[CommentEnabled] [bit] NOT NULL,
	[CommentCount] [int] NOT NULL,
	[LastDate] [datetime] NOT NULL,
	[PostDate] [datetime] NOT NULL,
 CONSTRAINT [PK_ynhtm_Post] PRIMARY KEY CLUSTERED 
(
	[PostID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[ynhtm_Post]') AND name = N'IX_ynhtm_Post')
CREATE NONCLUSTERED INDEX [IX_ynhtm_Post] ON [ynhtm_Post] 
(
	[CategoryID] ASC,
	[UserID] ASC,
	[Title] ASC,
	[Tags] ASC,
	[Enabled] ASC,
	[IsTop] ASC,
	[IsHide] ASC,
	[IsPic] ASC,
	[IsFace] ASC,
	[ViewCount] ASC,
	[CommentCount] ASC,
	[LastDate] ASC,
	[PostDate] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)

/****** Object:  Table [ynhtm_Link]    Script Date: 09/01/2011 23:20:18 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_Link]') AND type in (N'U'))
BEGIN
CREATE TABLE [ynhtm_Link](
	[LinkID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Url] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Logo] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[DisplayOrder] [int] NOT NULL,
	[CreateDate] [datetime] NOT NULL,
 CONSTRAINT [PK_ynhtm_Link] PRIMARY KEY CLUSTERED 
(
	[LinkID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[ynhtm_Link]') AND name = N'IX_ynhtm_Link')
CREATE NONCLUSTERED INDEX [IX_ynhtm_Link] ON [ynhtm_Link] 
(
	[DisplayOrder] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)

/****** Object:  Table [ynhtm_JobTry]    Script Date: 09/01/2011 23:20:18 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_JobTry]') AND type in (N'U'))
BEGIN
CREATE TABLE [ynhtm_JobTry](
	[TryID] [int] IDENTITY(1,1) NOT NULL,
	[JobID] [int] NOT NULL,
	[RealName] [nvarchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Sex] [int] NULL,
	[Wedding] [int] NULL,
	[Bday] [datetime] NULL,
	[School] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Contact] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Addr] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[EducationNote] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[WorkNote] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Remark] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[FileUrl] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[IPAddr] [nvarchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[PostDate] [datetime] NOT NULL,
 CONSTRAINT [PK_ynhtm_JobTry] PRIMARY KEY CLUSTERED 
(
	[TryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[ynhtm_JobTry]') AND name = N'IX_ynhtm_JobTry')
CREATE NONCLUSTERED INDEX [IX_ynhtm_JobTry] ON [ynhtm_JobTry] 
(
	[RealName] ASC,
	[Contact] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)

/****** Object:  Table [ynhtm_Job]    Script Date: 09/01/2011 23:20:18 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_Job]') AND type in (N'U'))
BEGIN
CREATE TABLE [ynhtm_Job](
	[JobID] [int] IDENTITY(1,1) NOT NULL,
	[Type] [int] NULL,
	[Url] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Rewrite] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Theme] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Enabled] [bit] NOT NULL,
	[ViewCount] [int] NOT NULL,
	[TryCount] [int] NOT NULL,
	[Name] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Area] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Count] [int] NULL,
	[Salary] [money] NULL,
	[Sex] [int] NULL,
	[Age] [int] NULL,
	[Degree] [int] NULL,
	[Experience] [int] NULL,
	[Content] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[EndDate] [datetime] NULL,
	[CreateDate] [datetime] NOT NULL,
 CONSTRAINT [PK_ynhtm_Job] PRIMARY KEY CLUSTERED 
(
	[JobID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[ynhtm_Job]') AND name = N'IX_ynhtm_Job')
CREATE NONCLUSTERED INDEX [IX_ynhtm_Job] ON [ynhtm_Job] 
(
	[Type] ASC,
	[Rewrite] ASC,
	[Enabled] ASC,
	[Name] ASC,
	[Area] ASC,
	[Count] ASC,
	[Salary] ASC,
	[Sex] ASC,
	[Age] ASC,
	[Degree] ASC,
	[Experience] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)

/****** Object:  StoredProcedure [ynhtm_GetPage]    Script Date: 09/01/2011 23:20:18 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_GetPage]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [ynhtm_GetPage]
@Table NVARCHAR(MAX),
@Order NVARCHAR(MAX),
@PageSize INT = 10,
@PageIndex INT = 1,
@RecordCount INT = NULL OUTPUT,
@Query NVARCHAR(MAX) = NULL,
@Field NVARCHAR(MAX) = N''*''
AS
DECLARE @SQL NVARCHAR(MAX)

--合并查询条件
IF(@Query != N'''' AND @Query IS NOT NULL)
	SET @Query = N'' WHERE '' + @Query
ELSE
	SET @Query = N''''

--取得记录总数
IF(@RecordCount IS NOT NULL)
BEGIN
	SET @SQL = N''SELECT @RecordCount = COUNT(0) FROM '' + @Table + @Query
	EXEC sp_executesql @SQL, N''@RecordCount INT OUTPUT'', @RecordCount = @RecordCount OUTPUT
END

IF(@PageSize < 1) SET @PageSize = 10
IF(@PageIndex < 1 OR @PageIndex > CEILING(@RecordCount / CAST(@PAGESIZE AS FLOAT))) SET @PageIndex = 1

--查询数据
IF @PageIndex = 1
	SET @SQL = N''SELECT TOP '' + STR(@PageSize)  + N'' '' +  @Field + N'' FROM '' + @Table + @Query + N'' '' + @Order
ELSE
	SET @SQL = N''SELECT * FROM(SELECT ROW_NUMBER() OVER('' + @Order + N'') AS RowNumber, '' + @Field + N'' FROM '' + @Table + @Query + N'') as tmp WHERE RowNumber BETWEEN '' + STR((@PageIndex - 1) * @PageSize + 1) + N'' AND '' + STR(@PageIndex * @PageSize);

EXEC(@SQL)' 
END

/****** Object:  Table [ynhtm_Comment]    Script Date: 09/01/2011 23:20:18 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_Comment]') AND type in (N'U'))
BEGIN
CREATE TABLE [ynhtm_Comment](
	[CommentID] [int] IDENTITY(1,1) NOT NULL,
	[PostID] [int] NOT NULL,
	[UserID] [int] NULL,
	[IsAudit] [bit] NOT NULL,
	[IsWap] [bit] NOT NULL,
	[Name] [nvarchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Email] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Content] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[IPAddr] [nvarchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[PostDate] [datetime] NOT NULL,
 CONSTRAINT [PK_ynhtm_Comment] PRIMARY KEY CLUSTERED 
(
	[CommentID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[ynhtm_Comment]') AND name = N'IX_ynhtm_Comment')
CREATE NONCLUSTERED INDEX [IX_ynhtm_Comment] ON [ynhtm_Comment] 
(
	[PostID] ASC,
	[UserID] ASC,
	[IsAudit] ASC,
	[IsWap] ASC,
	[Name] ASC,
	[Email] ASC,
	[IPAddr] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)

/****** Object:  Table [ynhtm_Category]    Script Date: 09/01/2011 23:20:18 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ynhtm_Category]') AND type in (N'U'))
BEGIN
CREATE TABLE [ynhtm_Category](
	[CategoryID] [int] IDENTITY(1,1) NOT NULL,
	[Url] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Name] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[RssEnabled] [bit] NOT NULL,
	[MapEnabled] [bit] NOT NULL,
	[Rewrite] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[HomeTheme] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ListTheme] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[PostTheme] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[PostCount] [int] NOT NULL,
	[CommentCount] [int] NOT NULL,
	[DisplayOrder] [int] NOT NULL,
	[CreateDate] [datetime] NOT NULL,
 CONSTRAINT [PK_ynhtm_Category] PRIMARY KEY CLUSTERED 
(
	[CategoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[ynhtm_Category]') AND name = N'IX_ynhtm_Category')
CREATE NONCLUSTERED INDEX [IX_ynhtm_Category] ON [ynhtm_Category] 
(
	[Rewrite] ASC,
	[RssEnabled] ASC,
	[MapEnabled] ASC,
	[DisplayOrder] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)

/****** Object:  Default [DF_ynhtm_Category_CreateDate]    Script Date: 09/01/2011 23:20:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_Category_CreateDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_Category]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_Category_CreateDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_Category] ADD  CONSTRAINT [DF_ynhtm_Category_CreateDate]  DEFAULT (getdate()) FOR [CreateDate]
END


End

/****** Object:  Default [DF_ynhtm_Comment_PostDate]    Script Date: 09/01/2011 23:20:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_Comment_PostDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_Comment]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_Comment_PostDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_Comment] ADD  CONSTRAINT [DF_ynhtm_Comment_PostDate]  DEFAULT (getdate()) FOR [PostDate]
END


End

/****** Object:  Default [DF_ynhtm_Job_CreateDate]    Script Date: 09/01/2011 23:20:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_Job_CreateDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_Job]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_Job_CreateDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_Job] ADD  CONSTRAINT [DF_ynhtm_Job_CreateDate]  DEFAULT (getdate()) FOR [CreateDate]
END


End

/****** Object:  Default [DF_ynhtm_JobTry_PostDate]    Script Date: 09/01/2011 23:20:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_JobTry_PostDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_JobTry]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_JobTry_PostDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_JobTry] ADD  CONSTRAINT [DF_ynhtm_JobTry_PostDate]  DEFAULT (getdate()) FOR [PostDate]
END


End

/****** Object:  Default [DF_ynhtm_Link_CreateDate]    Script Date: 09/01/2011 23:20:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_Link_CreateDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_Link]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_Link_CreateDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_Link] ADD  CONSTRAINT [DF_ynhtm_Link_CreateDate]  DEFAULT (getdate()) FOR [CreateDate]
END


End

/****** Object:  Default [DF_ynhtm_Post_LastDate]    Script Date: 09/01/2011 23:20:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_Post_LastDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_Post]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_Post_LastDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_Post] ADD  CONSTRAINT [DF_ynhtm_Post_LastDate]  DEFAULT (getdate()) FOR [LastDate]
END


End

/****** Object:  Default [DF_ynhtm_Post_CreateDate]    Script Date: 09/01/2011 23:20:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_Post_CreateDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_Post]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_Post_CreateDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_Post] ADD  CONSTRAINT [DF_ynhtm_Post_CreateDate]  DEFAULT (getdate()) FOR [PostDate]
END


End

/****** Object:  Default [DF_ynhtm_Setting_CreateDate]    Script Date: 09/01/2011 23:20:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_Setting_CreateDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_Setting]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_Setting_CreateDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_Setting] ADD  CONSTRAINT [DF_ynhtm_Setting_CreateDate]  DEFAULT (getdate()) FOR [CreateDate]
END


End

/****** Object:  Default [DF_ynhtm_User_RegDate]    Script Date: 09/01/2011 23:20:18 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[DF_ynhtm_User_RegDate]') AND parent_object_id = OBJECT_ID(N'[ynhtm_User]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ynhtm_User_RegDate]') AND type = 'D')
BEGIN
ALTER TABLE [ynhtm_User] ADD  CONSTRAINT [DF_ynhtm_User_RegDate]  DEFAULT (getdate()) FOR [RegDate]
END


End
