USE [master]
GO
/****** Object:  Database [dnt3]    Script Date: 06/10/2013 22:25:57 ******/
CREATE DATABASE [dnt3] ON  PRIMARY 
( NAME = N'dnt3', FILENAME = N'D:\db\dnt3.mdf' , SIZE = 875520KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'dnt3_log', FILENAME = N'D:\db\dnt3_log.ldf' , SIZE = 470144KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [dnt3] SET COMPATIBILITY_LEVEL = 90
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [dnt3].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [dnt3] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [dnt3] SET ANSI_NULLS OFF
GO
ALTER DATABASE [dnt3] SET ANSI_PADDING OFF
GO
ALTER DATABASE [dnt3] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [dnt3] SET ARITHABORT OFF
GO
ALTER DATABASE [dnt3] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [dnt3] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [dnt3] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [dnt3] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [dnt3] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [dnt3] SET CURSOR_DEFAULT  GLOBAL
GO
ALTER DATABASE [dnt3] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [dnt3] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [dnt3] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [dnt3] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [dnt3] SET  DISABLE_BROKER
GO
ALTER DATABASE [dnt3] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [dnt3] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [dnt3] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [dnt3] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [dnt3] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [dnt3] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [dnt3] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [dnt3] SET  READ_WRITE
GO
ALTER DATABASE [dnt3] SET RECOVERY FULL
GO
ALTER DATABASE [dnt3] SET  MULTI_USER
GO
ALTER DATABASE [dnt3] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [dnt3] SET DB_CHAINING OFF
GO
EXEC sys.sp_db_vardecimal_storage_format N'dnt3', N'ON'
GO
USE [dnt3]
GO
/****** Object:  User [fjmarry]    Script Date: 06/10/2013 22:25:57 ******/
CREATE USER [fjmarry] WITHOUT LOGIN WITH DEFAULT_SCHEMA=[dbo]
GO
/****** Object:  StoredProcedure [dbo].[n_page]    Script Date: 06/10/2013 22:25:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--ҳʾ
CREATE PROC [dbo].[n_page]
@tbname     sysname,           --Ҫҳʾı
@FieldKey   sysname,           --ڶλ¼(Ωһ)ֶ,ֻǵֶ
@PageCurrent int=1,             --Ҫʾҳ
@PageSize   int=10,            --ÿҳĴС(¼)
@FieldShow  nvarchar(1000)='',  --ԶŷָҪʾֶб,ָ,ʾֶ
@FieldOrder  nvarchar(1000)='', --Զŷֶָб,ֶָκָDESC/ASCָ˳
@Where     nvarchar(3000)='',  --ѯ
@PageCount  int OUTPUT,        --ҳ
@RecordCount int OUTPUT
AS
DECLARE @sql nvarchar(4000)
SET NOCOUNT ON
/*
--ǷЧ
IF OBJECT_ID(@tbname) IS NULL
BEGIN
RAISERROR(N'"%s"',1,16,@tbname)
RETURN
END
IF OBJECTPROPERTY(OBJECT_ID(@tbname),N'IsTable')=0
AND OBJECTPROPERTY(OBJECT_ID(@tbname),N'IsView')=0
AND OBJECTPROPERTY(OBJECT_ID(@tbname),N'IsTableFunction')=0
BEGIN
RAISERROR(N'"%s"Ǳͼֵ߱',1,16,@tbname)
RETURN
END
*/
--ҳֶμ
IF ISNULL(@FieldKey,N'')=''
BEGIN
RAISERROR(N'ҳҪΩһ',1,16)
RETURN
END
--鼰淶
IF ISNULL(@PageCurrent,0)<1 SET @PageCurrent=1
IF ISNULL(@PageSize,0)<1 SET @PageSize=10
IF ISNULL(@FieldShow,N'')=N'' SET @FieldShow=N'*'
IF ISNULL(@FieldOrder,N'')=N''
SET @FieldOrder=N''
ELSE
SET @FieldOrder=N'ORDER BY '+LTRIM(@FieldOrder)
IF ISNULL(@Where,N'')=N''
SET @Where=N''
ELSE
SET @Where=N'WHERE ('+@Where+N')'
--@PageCountΪNULLֵ,ҳ(ƿֻڵһμҳ,Ժʱ,ҳظ洢,ٴμҳ,ڲҳĴ,Ը@PageCountֵ)
IF @PageCount IS NULL
BEGIN
SET @sql=N'SELECT @PageCount=COUNT(*)'
+N' FROM '+@tbname
+N' '+@Where
EXEC sp_executesql @sql,N'@PageCount int OUTPUT',@PageCount OUTPUT
set @RecordCount=@PageCount
SET @PageCount=(@PageCount+@PageSize-1)/@PageSize
END
--ҳʾTOPNֵ
DECLARE @TopN varchar(20),@TopN1 varchar(20)
SELECT @TopN=@PageSize,
@TopN1=@PageCurrent*@PageSize
--һҳֱʾ
IF @PageCurrent=1
EXEC(N'SELECT TOP '+@TopN
+N' '+@FieldShow
+N' FROM '+@tbname
+N' '+@Where
+N' '+@FieldOrder)
ELSE
BEGIN
SELECT @PageCurrent=@TopN1,
@sql=N'SELECT @n=@n-1,@s=CASE WHEN @n<'+@TopN
+N' THEN @s+N'',''+QUOTENAME(RTRIM(CAST('+@FieldKey
+N' as varchar(8000))),N'''''''') ELSE N'''' END FROM '+@tbname
+N' '+@Where
+N' '+@FieldOrder
SET ROWCOUNT @PageCurrent
EXEC sp_executesql @sql,
N'@n int,@s nvarchar(4000) OUTPUT',
@PageCurrent,@sql OUTPUT
SET ROWCOUNT 0
IF @sql=N''
EXEC(N'SELECT TOP 0'
+N' '+@FieldShow
+N' FROM '+@tbname)
ELSE
BEGIN
SET @sql=STUFF(@sql,1,1,N'')
--ִвѯ
EXEC(N'SELECT TOP '+@TopN
+N' '+@FieldShow
+N' FROM '+@tbname
+N' WHERE '+@FieldKey
+N' IN('+@sql
+N') '+@FieldOrder)
END
END
GO
/****** Object:  Table [dbo].[mry_userinfoext]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_userinfoext](
	[extid] [int] IDENTITY(1,1) NOT NULL,
	[uid] [int] NULL,
	[askstores] [int] NULL,
	[askposts] [int] NULL,
	[asktopics] [int] NULL,
 CONSTRAINT [PK_MRY_USERINFOEXT] PRIMARY KEY CLUSTERED 
(
	[extid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'չ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_userinfoext', @level2type=N'COLUMN',@level2name=N'extid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_userinfoext', @level2type=N'COLUMN',@level2name=N'uid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ʴ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_userinfoext', @level2type=N'COLUMN',@level2name=N'askstores'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ʴ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_userinfoext', @level2type=N'COLUMN',@level2name=N'askposts'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ʴ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_userinfoext', @level2type=N'COLUMN',@level2name=N'asktopics'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ûϢչ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_userinfoext'
GO
/****** Object:  Table [dbo].[mry_picturealbum]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_picturealbum](
	[albumid] [int] IDENTITY(1,1) NOT NULL,
	[pcid] [int] NULL,
	[cid] [int] NULL,
	[albumname] [nvarchar](100) NULL,
	[piccount] [int] NULL,
	[clicks] [int] NULL,
	[picurl] [nvarchar](50) NULL,
 CONSTRAINT [PK_MRY_PICTUREALBUM] PRIMARY KEY CLUSTERED 
(
	[albumid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_picturealbum', @level2type=N'COLUMN',@level2name=N'albumid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ḹ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_picturealbum', @level2type=N'COLUMN',@level2name=N'pcid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_picturealbum', @level2type=N'COLUMN',@level2name=N'cid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_picturealbum', @level2type=N'COLUMN',@level2name=N'albumname'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƭ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_picturealbum', @level2type=N'COLUMN',@level2name=N'piccount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_picturealbum', @level2type=N'COLUMN',@level2name=N'clicks'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͼƬ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_picturealbum', @level2type=N'COLUMN',@level2name=N'picurl'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͼ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_picturealbum'
GO
/****** Object:  Table [dbo].[mry_personuser]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_personuser](
	[puid] [int] IDENTITY(1,1) NOT NULL,
	[bbsuid] [int] NULL,
	[face] [nvarchar](80) NULL,
	[engagementdate] [datetime] NULL,
	[marrydate] [datetime] NULL,
	[lastvisits] [nvarchar](500) NULL,
	[picount] [int] NULL,
	[albumcount] [int] NULL,
	[visits] [int] NULL,
	[lastvisitIP] [nvarchar](15) NULL,
	[married] [bit] NULL,
 CONSTRAINT [PK_MRY_PERSONUSER] PRIMARY KEY CLUSTERED 
(
	[puid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personuser', @level2type=N'COLUMN',@level2name=N'puid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̳û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personuser', @level2type=N'COLUMN',@level2name=N'bbsuid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ҵͷ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personuser', @level2type=N'COLUMN',@level2name=N'face'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personuser', @level2type=N'COLUMN',@level2name=N'engagementdate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personuser', @level2type=N'COLUMN',@level2name=N'marrydate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personuser', @level2type=N'COLUMN',@level2name=N'lastvisits'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͼƬ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personuser', @level2type=N'COLUMN',@level2name=N'picount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personuser', @level2type=N'COLUMN',@level2name=N'albumcount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personuser', @level2type=N'COLUMN',@level2name=N'visits'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personuser', @level2type=N'COLUMN',@level2name=N'lastvisitIP'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personuser', @level2type=N'COLUMN',@level2name=N'married'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personuser'
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopiclistbytypedate]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gettopiclistbytypedate]
@pagesize int,
@pageindex int,
@startnum int,
@condition varchar(1000),
@orderby varchar(100),
@ascdesc int
AS

DECLARE @strsql varchar(5000)
DECLARE @sorttype varchar(5)

IF @ascdesc=0
   SET @sorttype='ASC'
ELSE
   SET @sorttype='DESC'

IF @pageindex = 1
	BEGIN
		SET @strsql = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[typeid],[title],[special],[price],[hide],[readperm],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],[lastpostid],[lastposterid],[highlight],[digest],[displayorder],[closed],[attachment],[magic],[rate] FROM [dnt_topics] WHERE [displayorder]>=0'+@condition+' ORDER BY '+@orderby+' '+@sorttype
	END
ELSE
           IF @sorttype='DESC'
	BEGIN
		SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[typeid],[title],[special],[price],[hide],[readperm],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],[lastpostid],[lastposterid],[highlight],[digest],[displayorder],[closed],[attachment],[magic],[rate] FROM [dnt_topics] WHERE ['+@orderby+'] < (SELECT min(['+@orderby+']) FROM (SELECT TOP ' + STR((@pageindex-1)*@pagesize-@startnum) + ' ['+@orderby+']  FROM [dnt_topics] WHERE  [displayorder]>=0'+@condition+' ORDER BY  '+@orderby+' '+@sorttype+')AS tblTmp ) AND [displayorder]>=0'+@condition+' ORDER BY  '+@orderby+' '+@sorttype
	END
      ELSE
             BEGIN
		SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[typeid],[title],[special],[price],[hide],[readperm],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],[lastpostid],[lastposterid],[highlight],[digest],[displayorder],[closed],[attachment],[magic],[rate] FROM [dnt_topics] WHERE ['+@orderby+'] > (SELECT MAX(['+@orderby+']) FROM (SELECT TOP ' + STR((@pageindex-1)*@pagesize-@startnum) + ' ['+@orderby+'] FROM [dnt_topics] WHERE [displayorder]>=0'+@condition+' ORDER BY  '+@orderby+' '+@sorttype+')AS tblTmp ) AND [displayorder]>=0'+@condition+' ORDER BY '+@orderby+' '+@sorttype
            END

EXEC(@strsql)
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopiclistbytype]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gettopiclistbytype]
@pagesize int,
@pageindex int,
@startnum int,
@condition varchar(1000),
@ascdesc int
AS
DECLARE @strSQL varchar(5000)

DECLARE @sorttype varchar(5)

IF @ascdesc=0
   SET @sorttype='ASC'
ELSE
   SET @sorttype='DESC'

IF @pageindex = 1
	BEGIN
		SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[typeid],[title],[price],[hide],[readperm],

[special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],

[lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[rate] FROM 

[dnt_topics] WHERE  [displayorder]>=0' + @condition + ' ORDER BY [lastpostid] '+@sorttype +',  [tid] '+@sorttype
	END
ELSE
	BEGIN
		IF @sorttype='DESC'
		BEGIN
			SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[typeid],[title],[price],[hide],[readperm],
	
	[special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],
	
	[lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[rate] FROM 
	
	[dnt_topics] WHERE [lastpostid] < (SELECT min([lastpostid])  FROM (SELECT TOP ' + STR
	
	((@pageindex-1)*@pagesize-@startnum) + ' [lastpostid] FROM [dnt_topics] WHERE  [displayorder]>=0' + @condition + ' ORDER BY [tid] ' + @sorttype + ' , [lastpostid] ' + @sorttype + ') AS tblTmp ) 
	
	AND  [displayorder]>=0' + @condition +' ORDER BY [lastpostid] '+@sorttype +',  [tid] '+@sorttype
		END
		ELSE
		BEGIN
			SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[typeid],[title],[price],[hide],[readperm],
	
	[special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],
	
	[lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic] FROM 
	
	[dnt_topics] WHERE [lastpostid] > (SELECT MAX([lastpostid])  FROM (SELECT TOP ' + STR
	
	((@pageindex-1)*@pagesize-@startnum) + ' [lastpostid] FROM [dnt_topics] WHERE  [displayorder]>=0' + @condition + ' ORDER BY [tid] ' + @sorttype + ' , [lastpostid] ' + @sorttype + ') AS tblTmp ) 
	
	AND  [displayorder]>=0' + @condition +' ORDER BY [lastpostid] '+@sorttype +',  [tid] '+@sorttype
		END
	END
EXEC(@strSQL)
GO
/****** Object:  Table [dbo].[mry_asktopics]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_asktopics](
	[topcid] [int] IDENTITY(1,1) NOT NULL,
	[uid] [int] NULL,
	[poster] [nvarchar](20) NULL,
	[cateid] [int] NULL,
	[subcateid] [int] NULL,
	[subject] [nvarchar](100) NULL,
	[topicdescr] [nvarchar](80) NULL,
	[askdescr] [nvarchar](80) NULL,
	[keywords] [nvarchar](50) NULL,
	[contentfile] [nvarchar](80) NULL,
	[store] [int] NULL,
	[asks] [int] NULL,
	[hots] [int] NULL,
	[questiondate] [datetime] NULL,
	[appendcontentfile] [nvarchar](80) NULL,
	[donedate] [datetime] NULL,
	[isbest] [bit] NULL,
	[isquick] [bit] NULL,
	[isanonymity] [bit] NULL,
	[ishide] [bit] NULL,
	[isdone] [bit] NULL,
	[issysget] [bit] NULL,
	[lastaskdate] [datetime] NULL,
 CONSTRAINT [PK_MRY_ASKTOPICS] PRIMARY KEY CLUSTERED 
(
	[topcid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ʴ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'topcid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'uid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'poster'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'cateid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ӷ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'subcateid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'subject'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'topicdescr'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'askdescr'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ؼ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'keywords'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'contentfile'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͷ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'store'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ش' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'asks'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'hots'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ѯ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'questiondate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'appendcontentfile'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ʱ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'donedate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ǷӼ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'isbest'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƿ񾫻' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'isquick'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƿ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'isanonymity'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƿ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'ishide'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƿ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'isdone'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƿץȡ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'issysget'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ظ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics', @level2type=N'COLUMN',@level2name=N'lastaskdate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ʴ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_asktopics'
GO
/****** Object:  Table [dbo].[mry_news]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_news](
	[newsid] [int] IDENTITY(1,1) NOT NULL,
	[parentcid] [int] NULL,
	[cid] [int] NULL,
	[title] [nvarchar](100) NULL,
	[descr] [nvarchar](255) NULL,
	[keywords] [nvarchar](100) NULL,
	[postdate] [datetime] NULL,
	[newssource] [nvarchar](50) NULL,
	[editorname] [nvarchar](20) NULL,
	[contentfile] [nvarchar](80) NULL,
	[browsecount] [int] NULL,
	[discuscount] [int] NULL,
	[picurl] [nvarchar](50) NULL,
	[recommand] [bit] NULL,
 CONSTRAINT [PK_MRY_NEWS] PRIMARY KEY CLUSTERED 
(
	[newsid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ѷ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news', @level2type=N'COLUMN',@level2name=N'newsid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'һ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news', @level2type=N'COLUMN',@level2name=N'parentcid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news', @level2type=N'COLUMN',@level2name=N'cid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'±' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news', @level2type=N'COLUMN',@level2name=N'title'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ѶҪ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news', @level2type=N'COLUMN',@level2name=N'descr'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ؼ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news', @level2type=N'COLUMN',@level2name=N'keywords'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news', @level2type=N'COLUMN',@level2name=N'postdate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Դ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news', @level2type=N'COLUMN',@level2name=N'newssource'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'༭' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news', @level2type=N'COLUMN',@level2name=N'editorname'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ļ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news', @level2type=N'COLUMN',@level2name=N'contentfile'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news', @level2type=N'COLUMN',@level2name=N'browsecount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'۴' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news', @level2type=N'COLUMN',@level2name=N'discuscount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͼ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news', @level2type=N'COLUMN',@level2name=N'picurl'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ǷƼ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news', @level2type=N'COLUMN',@level2name=N'recommand'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ѶϢ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_news'
GO
/****** Object:  Table [dbo].[mry_friendlinks]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_friendlinks](
	[flid] [int] IDENTITY(1,1) NOT NULL,
	[sitename] [nvarchar](10) NULL,
	[keywords] [nvarchar](10) NULL,
	[picurl] [nvarchar](50) NULL,
	[url] [nvarchar](255) NULL,
	[ishome] [bit] NULL,
	[isbusiness] [bit] NULL,
 CONSTRAINT [PK_MRY_FRIENDLINKS] PRIMARY KEY CLUSTERED 
(
	[flid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ӱ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_friendlinks', @level2type=N'COLUMN',@level2name=N'flid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'վ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_friendlinks', @level2type=N'COLUMN',@level2name=N'sitename'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ؼ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_friendlinks', @level2type=N'COLUMN',@level2name=N'keywords'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͼƬַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_friendlinks', @level2type=N'COLUMN',@level2name=N'picurl'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_friendlinks', @level2type=N'COLUMN',@level2name=N'url'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƿҳ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_friendlinks', @level2type=N'COLUMN',@level2name=N'ishome'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƿ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_friendlinks', @level2type=N'COLUMN',@level2name=N'isbusiness'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_friendlinks'
GO
/****** Object:  Table [dbo].[mry_chineselunisolar]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_chineselunisolar](
	[clid] [int] IDENTITY(1,1) NOT NULL,
	[cldate] [datetime] NULL,
	[payable] [nvarchar](255) NULL,
	[taboo] [nvarchar](255) NULL,
	[conflict] [nvarchar](255) NULL,
	[lunar] [nvarchar](255) NULL,
 CONSTRAINT [PK_MRY_CHINESELUNISOLAR] PRIMARY KEY CLUSTERED 
(
	[clid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_chineselunisolar', @level2type=N'COLUMN',@level2name=N'clid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_chineselunisolar', @level2type=N'COLUMN',@level2name=N'cldate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_chineselunisolar', @level2type=N'COLUMN',@level2name=N'payable'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_chineselunisolar', @level2type=N'COLUMN',@level2name=N'taboo'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_chineselunisolar', @level2type=N'COLUMN',@level2name=N'conflict'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ũ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_chineselunisolar', @level2type=N'COLUMN',@level2name=N'lunar'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'й' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_chineselunisolar'
GO
/****** Object:  Table [dbo].[mry_businessuser]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_businessuser](
	[buid] [int] IDENTITY(1,1) NOT NULL,
	[parentcid] [int] NULL,
	[cid] [int] NULL,
	[bbsuid] [int] NULL,
	[companyname] [nvarchar](20) NULL,
	[logo] [nvarchar](80) NULL,
	[viplevel] [smallint] NULL,
	[officetimes] [nvarchar](25) NULL,
	[tel] [nvarchar](25) NULL,
	[fax] [nvarchar](25) NULL,
	[email] [nvarchar](100) NULL,
	[mobile] [nvarchar](25) NULL,
	[siteurl] [nvarchar](100) NULL,
	[address] [nvarchar](100) NULL,
	[privince] [nvarchar](10) NULL,
	[city] [nvarchar](10) NULL,
	[qq] [nvarchar](20) NULL,
	[msn] [nvarchar](50) NULL,
	[contact] [nvarchar](10) NULL,
	[descrfile] [nvarchar](80) NULL,
	[pricesfile] [nvarchar](80) NULL,
	[solutionsfile] [nvarchar](80) NULL,
	[joindate] [datetime] NULL,
	[gradevotes] [int] NULL,
	[totalgrade] [float] NULL,
	[grade] [nvarchar](300) NULL,
	[visits] [int] NULL,
	[lastvisitIP] [nvarchar](15) NULL,
	[lastvisits] [nvarchar](500) NULL,
	[albumcount] [int] NULL,
	[photocount] [int] NULL,
	[couponcount] [int] NULL,
 CONSTRAINT [PK_MRY_BUSINESSUSER] PRIMARY KEY CLUSTERED 
(
	[buid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼ұ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'buid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼һ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'parentcid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼Ҷ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'cid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̳û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'bbsuid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'˾' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'companyname'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'˾־LOGO' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'logo'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Աȼ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'viplevel'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ӫҵʱ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'officetimes'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ϵ绰' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'tel'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'fax'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ʼ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'email'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ƶ绰' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'mobile'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ٷվ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'siteurl'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'˾ַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'address'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ʡ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'privince'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'city'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'QQ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'qq'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'MSN' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'msn'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ϵ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'contact'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̽ļ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'descrfile'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'񱨼' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'pricesfile'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ɹ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'solutionsfile'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'סʱ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'joindate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͶƱ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'gradevotes'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'totalgrade'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼JSON' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'grade'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'visits'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'lastvisitIP'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'lastvisits'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'albumcount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƭ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'photocount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Żȯ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser', @level2type=N'COLUMN',@level2name=N'couponcount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessuser'
GO
/****** Object:  StoredProcedure [dbo].[dnt_resetuserspostcount]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_resetuserspostcount]
@posttablename NVARCHAR(50)
AS
EXEC('
		UPDATE dnt_users
		SET posts = posts + leftTable.postcount 
		FROM dnt_users 
		INNER JOIN (SELECT posterid,COUNT(pid) postcount FROM '+@posttablename+' GROUP BY posterid) AS leftTable
		ON dnt_users.[uid] = leftTable.posterid
		WHERE dnt_users.[uid] = leftTable.posterid
	')
GO
/****** Object:  Table [dbo].[dnt_searchcaches]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_searchcaches](
	[searchid] [int] IDENTITY(1,1) NOT NULL,
	[keywords] [nvarchar](255) NOT NULL,
	[searchstring] [nvarchar](255) NOT NULL,
	[ip] [varchar](15) NOT NULL,
	[uid] [int] NOT NULL,
	[groupid] [int] NOT NULL,
	[postdatetime] [datetime] NOT NULL,
	[expiration] [datetime] NOT NULL,
	[topics] [int] NOT NULL,
	[tids] [text] NOT NULL,
 CONSTRAINT [PK_dnt_searchindex] PRIMARY KEY CLUSTERED 
(
	[searchid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [getsearchid] ON [dbo].[dnt_searchcaches] 
(
	[searchstring] ASC,
	[groupid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_scheduledevents]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_scheduledevents](
	[scheduleID] [int] IDENTITY(1,1) NOT NULL,
	[key] [varchar](50) NOT NULL,
	[lastexecuted] [datetime] NOT NULL,
	[servername] [varchar](100) NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[mry_ads]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_ads](
	[adid] [int] IDENTITY(1,1) NOT NULL,
	[keywords] [nvarchar](20) NULL,
	[chsname] [nvarchar](20) NULL,
	[disptext] [nvarchar](50) NULL,
	[newsid] [int] NULL,
	[isnews] [bit] NULL,
	[picurl] [nvarchar](50) NULL,
	[url] [nvarchar](255) NULL,
 CONSTRAINT [PK_MRY_ADS] PRIMARY KEY CLUSTERED 
(
	[adid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_ads', @level2type=N'COLUMN',@level2name=N'adid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ؼ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_ads', @level2type=N'COLUMN',@level2name=N'keywords'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_ads', @level2type=N'COLUMN',@level2name=N'chsname'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_ads', @level2type=N'COLUMN',@level2name=N'disptext'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ű' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_ads', @level2type=N'COLUMN',@level2name=N'newsid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƿ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_ads', @level2type=N'COLUMN',@level2name=N'isnews'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͼƬַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_ads', @level2type=N'COLUMN',@level2name=N'picurl'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ӵַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_ads', @level2type=N'COLUMN',@level2name=N'url'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ϣ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_ads'
GO
/****** Object:  Table [dbo].[dnt_words]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_words](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[admin] [nvarchar](20) NOT NULL,
	[find] [nvarchar](255) NOT NULL,
	[replacement] [nvarchar](255) NOT NULL,
 CONSTRAINT [PK_dnt_words] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_users]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_users](
	[uid] [int] IDENTITY(1,1) NOT NULL,
	[username] [nchar](50) NOT NULL,
	[nickname] [nchar](20) NOT NULL,
	[password] [char](32) NOT NULL,
	[secques] [char](8) NOT NULL,
	[spaceid] [int] NOT NULL,
	[gender] [int] NOT NULL,
	[adminid] [int] NOT NULL,
	[groupid] [smallint] NOT NULL,
	[groupexpiry] [int] NOT NULL,
	[extgroupids] [char](60) NOT NULL,
	[regip] [char](15) NOT NULL,
	[joindate] [smalldatetime] NOT NULL,
	[lastip] [char](15) NOT NULL,
	[lastvisit] [datetime] NOT NULL,
	[lastactivity] [datetime] NOT NULL,
	[lastpost] [datetime] NOT NULL,
	[lastpostid] [int] NOT NULL,
	[lastposttitle] [nchar](60) NOT NULL,
	[posts] [int] NOT NULL,
	[digestposts] [smallint] NOT NULL,
	[oltime] [int] NOT NULL,
	[pageviews] [int] NOT NULL,
	[credits] [int] NOT NULL,
	[extcredits1] [decimal](18, 2) NOT NULL,
	[extcredits2] [decimal](18, 2) NOT NULL,
	[extcredits3] [decimal](18, 2) NOT NULL,
	[extcredits4] [decimal](18, 2) NOT NULL,
	[extcredits5] [decimal](18, 2) NOT NULL,
	[extcredits6] [decimal](18, 2) NOT NULL,
	[extcredits7] [decimal](18, 2) NOT NULL,
	[extcredits8] [decimal](18, 2) NOT NULL,
	[avatarshowid] [int] NOT NULL,
	[email] [char](50) NOT NULL,
	[bday] [char](10) NOT NULL,
	[sigstatus] [int] NOT NULL,
	[tpp] [int] NOT NULL,
	[ppp] [int] NOT NULL,
	[templateid] [smallint] NOT NULL,
	[pmsound] [int] NOT NULL,
	[showemail] [int] NOT NULL,
	[invisible] [int] NOT NULL,
	[newpm] [int] NOT NULL,
	[newpmcount] [int] NOT NULL,
	[accessmasks] [int] NOT NULL,
	[onlinestate] [int] NOT NULL,
	[newsletter] [int] NOT NULL,
	[salt] [nchar](6) NOT NULL,
 CONSTRAINT [PK_dnt_members] PRIMARY KEY CLUSTERED 
(
	[uid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [email] ON [dbo].[dnt_users] 
(
	[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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [emailsecques] ON [dbo].[dnt_users] 
(
	[username] ASC,
	[email] ASC,
	[secques] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [groupid] ON [dbo].[dnt_users] 
(
	[groupid] ASC,
	[adminid] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [password] ON [dbo].[dnt_users] 
(
	[username] ASC,
	[password] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [pwsecques] ON [dbo].[dnt_users] 
(
	[username] ASC,
	[password] ASC,
	[secques] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [regip] ON [dbo].[dnt_users] 
(
	[regip] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [username] ON [dbo].[dnt_users] 
(
	[username] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_usergroups]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_usergroups](
	[groupid] [smallint] IDENTITY(1,1) NOT NULL,
	[radminid] [int] NOT NULL,
	[type] [smallint] NULL,
	[system] [smallint] NOT NULL,
	[grouptitle] [nvarchar](50) NOT NULL,
	[creditshigher] [int] NOT NULL,
	[creditslower] [int] NOT NULL,
	[stars] [int] NOT NULL,
	[color] [char](7) NOT NULL,
	[groupavatar] [nvarchar](60) NOT NULL,
	[readaccess] [int] NOT NULL,
	[allowvisit] [int] NOT NULL,
	[allowpost] [int] NOT NULL,
	[allowreply] [int] NOT NULL,
	[allowpostpoll] [int] NOT NULL,
	[allowdirectpost] [int] NOT NULL,
	[allowgetattach] [int] NOT NULL,
	[allowpostattach] [int] NOT NULL,
	[allowvote] [int] NOT NULL,
	[allowmultigroups] [int] NOT NULL,
	[allowsearch] [int] NOT NULL,
	[allowavatar] [int] NOT NULL,
	[allowcstatus] [int] NOT NULL,
	[allowuseblog] [int] NOT NULL,
	[allowinvisible] [int] NOT NULL,
	[allowtransfer] [int] NOT NULL,
	[allowsetreadperm] [int] NOT NULL,
	[allowsetattachperm] [int] NOT NULL,
	[allowhidecode] [int] NOT NULL,
	[allowhtml] [int] NOT NULL,
	[allowcusbbcode] [int] NOT NULL,
	[allownickname] [int] NOT NULL,
	[allowsigbbcode] [int] NOT NULL,
	[allowsigimgcode] [int] NOT NULL,
	[allowviewpro] [int] NOT NULL,
	[allowviewstats] [int] NOT NULL,
	[disableperiodctrl] [int] NOT NULL,
	[reasonpm] [int] NOT NULL,
	[maxprice] [smallint] NOT NULL,
	[maxpmnum] [smallint] NOT NULL,
	[maxsigsize] [smallint] NOT NULL,
	[maxattachsize] [int] NOT NULL,
	[maxsizeperday] [int] NOT NULL,
	[attachextensions] [char](100) NOT NULL,
	[raterange] [nchar](500) NOT NULL,
	[allowspace] [smallint] NOT NULL,
	[maxspaceattachsize] [int] NOT NULL,
	[maxspacephotosize] [int] NOT NULL,
	[allowdebate] [int] NOT NULL,
	[allowbonus] [int] NOT NULL,
	[minbonusprice] [smallint] NOT NULL,
	[maxbonusprice] [smallint] NOT NULL,
	[allowtrade] [int] NOT NULL,
	[allowdiggs] [int] NOT NULL,
 CONSTRAINT [PK_dnt_usergroups] PRIMARY KEY CLUSTERED 
(
	[groupid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[dnt_userfields]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_userfields](
	[uid] [int] NOT NULL,
	[website] [nvarchar](80) NOT NULL,
	[icq] [varchar](12) NOT NULL,
	[qq] [varchar](12) NOT NULL,
	[yahoo] [varchar](40) NOT NULL,
	[msn] [varchar](40) NOT NULL,
	[skype] [varchar](40) NOT NULL,
	[location] [nvarchar](50) NOT NULL,
	[customstatus] [nvarchar](50) NOT NULL,
	[avatar] [nvarchar](255) NOT NULL,
	[avatarwidth] [int] NOT NULL,
	[avatarheight] [int] NOT NULL,
	[medals] [varchar](300) NOT NULL,
	[bio] [nvarchar](500) NOT NULL,
	[signature] [nvarchar](500) NOT NULL,
	[sightml] [nvarchar](1000) NOT NULL,
	[authstr] [varchar](20) NOT NULL,
	[authtime] [smalldatetime] NOT NULL,
	[authflag] [tinyint] NOT NULL,
	[realname] [nvarchar](10) NOT NULL,
	[idcard] [varchar](20) NOT NULL,
	[mobile] [varchar](20) NOT NULL,
	[phone] [varchar](20) NOT NULL,
	[ignorepm] [nvarchar](1000) NOT NULL,
 CONSTRAINT [PK_dnt_userfields] PRIMARY KEY CLUSTERED 
(
	[uid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[dnt_ratelog]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_ratelog](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[pid] [int] NOT NULL,
	[uid] [int] NOT NULL,
	[username] [nchar](20) NOT NULL,
	[extcredits] [tinyint] NOT NULL,
	[postdatetime] [datetime] NOT NULL,
	[score] [smallint] NOT NULL,
	[reason] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_dnt_ratelog] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_posts1]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_posts1](
	[pid] [int] NOT NULL,
	[fid] [int] NOT NULL,
	[tid] [int] NOT NULL,
	[parentid] [int] NOT NULL,
	[layer] [int] NOT NULL,
	[poster] [nvarchar](20) NOT NULL,
	[posterid] [int] NOT NULL,
	[title] [nvarchar](60) NOT NULL,
	[postdatetime] [smalldatetime] NOT NULL,
	[message] [ntext] NOT NULL,
	[ip] [nvarchar](15) NOT NULL,
	[lastedit] [nvarchar](50) NOT NULL,
	[invisible] [int] NOT NULL,
	[usesig] [int] NOT NULL,
	[htmlon] [int] NOT NULL,
	[smileyoff] [int] NOT NULL,
	[parseurloff] [int] NOT NULL,
	[bbcodeoff] [int] NOT NULL,
	[attachment] [int] NOT NULL,
	[rate] [int] NOT NULL,
	[ratetimes] [int] NOT NULL,
 CONSTRAINT [PK_dnt_posts1] PRIMARY KEY CLUSTERED 
(
	[pid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [parentid] ON [dbo].[dnt_posts1] 
(
	[parentid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [showtopic] ON [dbo].[dnt_posts1] 
(
	[tid] ASC,
	[invisible] ASC,
	[pid] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [treelist] ON [dbo].[dnt_posts1] 
(
	[tid] ASC,
	[invisible] ASC,
	[parentid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_postid]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_postid](
	[pid] [int] IDENTITY(1,1) NOT NULL,
	[postdatetime] [datetime] NOT NULL,
 CONSTRAINT [PK_dnt_postid] PRIMARY KEY CLUSTERED 
(
	[pid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_postdebatefields]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_postdebatefields](
	[tid] [int] NOT NULL,
	[pid] [int] NOT NULL,
	[opinion] [int] NOT NULL,
	[diggs] [int] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_polls]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_polls](
	[pollid] [int] IDENTITY(1,1) NOT NULL,
	[tid] [int] NOT NULL,
	[displayorder] [int] NOT NULL,
	[multiple] [tinyint] NOT NULL,
	[visible] [tinyint] NOT NULL,
	[maxchoices] [smallint] NOT NULL,
	[expiration] [datetime] NOT NULL,
	[uid] [int] NOT NULL,
	[voternames] [ntext] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [dnt_polls_tid] ON [dbo].[dnt_polls] 
(
	[tid] 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) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_polloptions]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_polloptions](
	[polloptionid] [int] IDENTITY(1,1) NOT NULL,
	[tid] [int] NOT NULL,
	[pollid] [int] NOT NULL,
	[votes] [int] NOT NULL,
	[displayorder] [int] NOT NULL,
	[polloption] [nvarchar](80) NOT NULL,
	[voternames] [ntext] NOT NULL,
 CONSTRAINT [PK_dnt_polloptions] PRIMARY KEY CLUSTERED 
(
	[polloptionid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_pms]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_pms](
	[pmid] [int] IDENTITY(1,1) NOT NULL,
	[msgfrom] [nvarchar](50) NOT NULL,
	[msgfromid] [int] NOT NULL,
	[msgto] [nvarchar](50) NOT NULL,
	[msgtoid] [int] NOT NULL,
	[folder] [smallint] NOT NULL,
	[new] [int] NOT NULL,
	[subject] [nvarchar](60) NOT NULL,
	[postdatetime] [datetime] NOT NULL,
	[message] [ntext] NOT NULL,
 CONSTRAINT [PK_dnt_pms] PRIMARY KEY CLUSTERED 
(
	[pmid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [msgtoid] ON [dbo].[dnt_pms] 
(
	[msgtoid] 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) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_paymentlog]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_paymentlog](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[uid] [int] NOT NULL,
	[tid] [int] NOT NULL,
	[authorid] [int] NOT NULL,
	[buydate] [datetime] NOT NULL,
	[amount] [smallint] NOT NULL,
	[netamount] [smallint] NOT NULL,
 CONSTRAINT [PK_dnt_paymentlog] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_invitation]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_invitation](
	[inviteid] [int] IDENTITY(1,1) NOT NULL,
	[invitecode] [nchar](7) NOT NULL,
	[creatorid] [int] NOT NULL,
	[creator] [nchar](20) NOT NULL,
	[successcount] [int] NOT NULL,
	[createdtime] [smalldatetime] NOT NULL,
	[expiretime] [smalldatetime] NOT NULL,
	[maxcount] [int] NOT NULL,
	[invitetype] [int] NOT NULL,
	[isdeleted] [int] NOT NULL,
 CONSTRAINT [PK_dnt_invitation_inviteid] PRIMARY KEY CLUSTERED 
(
	[inviteid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [code] ON [dbo].[dnt_invitation] 
(
	[invitecode] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [creatorid] ON [dbo].[dnt_invitation] 
(
	[creatorid] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [invitetype] ON [dbo].[dnt_invitation] 
(
	[invitetype] 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) ON [PRIMARY]
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopiclistbydate]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  PROCEDURE [dbo].[dnt_gettopiclistbydate]
@fid int,
@pagesize int,
@pageindex int,
@startnum int,
@condition varchar(100),
@orderby varchar(100),
@ascdesc int
AS

DECLARE @strsql varchar(5000)
DECLARE @sorttype varchar(5)

IF @ascdesc=0
   SET @sorttype='ASC'
ELSE
   SET @sorttype='DESC'

IF @pageindex = 1
	BEGIN
		SET @strsql = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[title],[price],[typeid],[readperm],[hide],[special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],[lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[rate] FROM [dnt_topics] WHERE [fid]=' +STR(@fid) + ' AND [displayorder]=0'+@condition+' ORDER BY '+@orderby+' '+@sorttype
	END
ELSE
           IF @sorttype='DESC'
	BEGIN
		SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[title],[price],[typeid],[hide],[readperm],[special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],[lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[rate] FROM [dnt_topics] WHERE ['+@orderby+'] < (SELECT min(['+@orderby+']) FROM (SELECT TOP ' + STR((@pageindex-1)*@pagesize-@startnum) + ' ['+@orderby+']  FROM [dnt_topics] WHERE [fid]=' +STR(@fid) + ' AND [displayorder]=0'+@condition+' ORDER BY  '+@orderby+' '+@sorttype+')AS tblTmp ) AND [fid]=' +STR(@fid) + ' AND [displayorder]=0'+@condition+' ORDER BY  '+@orderby+' '+@sorttype
	END
      ELSE
             BEGIN
		SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[title],[price],[hide],[typeid],[readperm],[special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],[lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[rate] FROM [dnt_topics] WHERE ['+@orderby+'] > (SELECT MAX(['+@orderby+']) FROM (SELECT TOP ' + STR((@pageindex-1)*@pagesize-@startnum) + ' ['+@orderby+'] FROM [dnt_topics] WHERE [fid]=' +STR(@fid) + ' AND [displayorder]=0'+@condition+' ORDER BY  '+@orderby+' '+@sorttype+')AS tblTmp ) AND [fid]=' +STR(@fid) + ' AND [displayorder]=0'+@condition+' ORDER BY '+@orderby+' '+@sorttype
            END
EXEC(@strsql)
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopiclistbycondition]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gettopiclistbycondition]
@fid int,
@pagesize int,
@pageindex int,
@startnum int,
@condition varchar(80)
AS
DECLARE @strSQL varchar(5000)

IF @pageindex = 1
	BEGIN
		SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [rate],[tid],[iconid],[typeid],[title],[price],[hide],[readperm],

[special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],

[lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[special] FROM 

[dnt_topics] WHERE [fid]=' +STR(@fid) + ' AND [displayorder]=0' + @condition + ' ORDER BY [lastpostid] DESC'
	END
ELSE
	BEGIN
		SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +'[rate], [tid],[iconid],[typeid],[title],[price],[hide],[readperm],

[special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],

[lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[special] FROM 

[dnt_topics] WHERE [lastpostid] < (SELECT min([lastpostid])  FROM (SELECT TOP ' + STR

((@pageindex-1)*@pagesize-@startnum) + ' [lastpostid] FROM [dnt_topics] WHERE [fid]=' +STR

(@fid) + ' AND [displayorder]=0' + @condition + ' ORDER BY [lastpostid] DESC) AS tblTmp ) 

AND [fid]=' +STR(@fid) + ' AND [displayorder]=0' + @condition + ' ORDER BY [lastpostid] DESC'
	END
EXEC(@strSQL)
GO
/****** Object:  StoredProcedure [dbo].[dnt_resetLastRepliesInfoOftopics]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_resetLastRepliesInfoOftopics]
@posttable NVARCHAR(20)
AS
EXEC('
		UPDATE dnt_topics 
		SET dnt_topics.replies = lastPostTable.posts, 
			lastpost = lastPostTable.postdatetime, 
			lastposterid = lastPostTable.posterid, 
			lastposter = lastPostTable.poster, 
			lastpostid = lastPostTable.pid 
		FROM dnt_topics
		INNER JOIN  (
						SELECT leftTable.tid,leftTable.posterid,leftTable.pid,leftTable.poster,leftTable.postdatetime,rightTable.posts FROM '+@posttable+' AS leftTable 
						LEFT JOIN (SELECT tid,COUNT(*)-1 posts,MAX(pid) maxpid FROM '+@posttable+' GROUP BY tid) AS rightTable
						ON leftTable.pid = rightTable.maxpid
						WHERE leftTable.pid = rightTable.maxpid
					) AS lastPostTable
		ON dnt_topics.tid = lastPostTable.tid
		WHERE dnt_topics.tid = lastPostTable.tid AND dnt_topics.lastpostid <> lastPostTable.pid
	')
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateuseronlinestates]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateuseronlinestates] 
@uidlist varchar(5000) = '' 
AS

EXEC ('UPDATE [dnt_users] SET [onlinestate]=0,[lastactivity]=GETDATE() WHERE [uid] IN ('+@uidlist+')')
GO
/****** Object:  Table [dbo].[dnt_debates]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_debates](
	[tid] [int] NOT NULL,
	[positiveopinion] [nvarchar](200) NOT NULL,
	[negativeopinion] [nvarchar](200) NOT NULL,
	[terminaltime] [datetime] NOT NULL,
	[positivediggs] [int] NOT NULL,
	[negativediggs] [int] NOT NULL,
 CONSTRAINT [PK_dnt_debate] PRIMARY KEY CLUSTERED 
(
	[tid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_debatediggs]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_debatediggs](
	[tid] [int] NOT NULL,
	[pid] [int] NOT NULL,
	[digger] [nchar](20) NOT NULL,
	[diggerid] [int] NOT NULL,
	[diggerip] [nchar](15) NOT NULL,
	[diggdatetime] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_creditslog]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_creditslog](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[uid] [int] NOT NULL,
	[fromto] [int] NOT NULL,
	[sendcredits] [tinyint] NOT NULL,
	[receivecredits] [tinyint] NOT NULL,
	[send] [float] NOT NULL,
	[receive] [float] NOT NULL,
	[paydate] [datetime] NOT NULL,
	[operation] [tinyint] NOT NULL,
 CONSTRAINT [PK_dnt_creditslog] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  StoredProcedure [dbo].[dnt_deleteattachmentbyaidlist]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_deleteattachmentbyaidlist]
@aidlist VARCHAR(500)
AS
EXEC('DELETE FROM [dnt_attachments] WHERE [aid] IN ('+@aidlist+')')
GO
/****** Object:  StoredProcedure [dbo].[dnt_deleteattachmentbytidlist]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_deleteattachmentbytidlist]
@tidlist VARCHAR(500)
AS
EXEC('DELETE FROM [dnt_attachments] WHERE [tid] IN ('+@tidlist+')')
GO
/****** Object:  StoredProcedure [dbo].[dnt_getattentiontopics]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getattentiontopics] 

@fid varchar(255)='',
@tpp int,
@pageid int,
@condition nvarchar(255)=''
AS

DECLARE @pagetop int,@strSQL varchar(5000)

SET @pagetop = (@pageid-1)*@tpp
IF @pageid = 1
	BEGIN
		SET @strSQL = 'SELECT TOP  ' +STR( @tpp) + '  * FROM [dnt_topics] WHERE [displayorder]>=0  AND [attention]=1'
                     	
		IF @fid<>'0'
                            SELECT  @strSQL=@strSQL+'  AND [fid] IN ('+@fid+')'


                            IF @condition<>''
                            SELECT  @strSQL=@strSQL+@condition

                           SELECT @strSQL=@strSQL+'  ORDER BY [lastpost] DESC'
                            

      
	END
ELSE
	BEGIN
		SET @strSQL = 'SELECT TOP  ' +STR( @tpp) + '  * FROM [dnt_topics]  WHERE [tid] < (SELECT MIN([tid])  FROM (SELECT TOP '+STR(@pagetop)+' [tid] FROM [dnt_topics]   WHERE [displayorder]>=0  AND [attention]=1'
		

		 IF @fid<>'0'
 
                            SELECT  @strSQL=@strSQL+'  AND [fid] IN ('+@fid+')'
                          


                            IF @condition<>''
                            SELECT  @strSQL=@strSQL+@condition
                     

                          SELECT @strSQL=@strSQL+'   ORDER BY [tid] DESC'


                          SELECT @strSQL=@strSQL+'  )  AS T) '

		 IF @fid<>'0'
 
                           SELECT  @strSQL=@strSQL+'  AND [fid] IN ('+@fid+')'

			    IF @condition<>''
                            SELECT  @strSQL=@strSQL+@condition


                           SELECT @strSQL=@strSQL+'  AND [displayorder]>=0  AND [attention]=1 ORDER BY [tid] DESC'

                                 
	END
EXEC(@strSQL)
GO
/****** Object:  StoredProcedure [dbo].[dnt_getattachpaymentlogbyuid]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getattachpaymentlogbyuid]
@attachidlist varchar(2000),
@uid int
AS
EXEC('
		SELECT 
		[aid]
		FROM [dnt_attachpaymentlog] 
		WHERE [uid] = '+@uid+ ' AND [dnt_attachpaymentlog].[aid] IN ('+@attachidlist+')
	')
GO
/****** Object:  StoredProcedure [dbo].[dnt_getorderscount]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getorderscount]
@searchcondition varchar(1000)
AS
BEGIN
DECLARE @script VARCHAR(1000)
SET @script= 'SELECT COUNT([orderid]) FROM [dnt_orders] '+@searchcondition
EXEC(@script)
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_getorderlist]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getorderlist]
@searchcondition varchar(1000)
AS
BEGIN
DECLARE @script VARCHAR(1000)
SET @script= 'SELECT TOP 20 [orderid],[ordercode],[uid],[buyer],[paytype],[tradeno],[price],[orderstatus],[createdtime],[confirmedtime]
,[credit],[amount] FROM [dnt_orders] '+@searchcondition+' ORDER BY [orderid] DESC'
EXEC(@script)
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_getfavoriteslistbyalbum]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getfavoriteslistbyalbum]
@uid int,
@pagesize int,
@pageindex int
AS
DECLARE @strSQL varchar(5000)


SET @strSQL='SELECT [f].[tid], [f].[uid], [albumid], [albumcateid], [userid] AS [posterid], [username] AS [poster], [title], [description], [logo], [password], [imgcount], [views], [type], [createdatetime] AS [postdatetime] FROM [dnt_favorites] [f],[dnt_albums] [albums] WHERE [f].[tid]=[albums].[albumid] AND [f].[typeid]=1 AND [f].[uid]=' + STR(@uid)

IF @pageindex = 1
	BEGIN
		SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +'  [tid], [uid], [albumid], [albumcateid], [posterid], [poster], [title], [description], [logo], [password], [imgcount], [views], [type], [postdatetime]  FROM (' + @strSQL + ') f' + '  ORDER BY [tid] DESC'
	END
ELSE
	BEGIN
		SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +'  [tid], [uid], [albumid], [albumcateid], [posterid], [poster], [title], [description], [logo], [password], [imgcount], [views], [type], [postdatetime]  FROM (' + @strSQL + ') f1 WHERE [tid] < (SELECT MIN([tid]) FROM (SELECT TOP ' + STR((@pageindex-1)*@pagesize) + ' [tid] FROM (' + @strSQL + ') f2' + '  ORDER BY [tid] DESC) AS tblTmp)' + '  ORDER BY [tid] DESC'
	END

EXEC(@strSQL)
GO
/****** Object:  StoredProcedure [dbo].[dnt_gethottopicscount]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gethottopicscount]
@fid int,
@timebetween int
AS
DECLARE @strSQL varchar(4000)
DECLARE @strSQLByFid nvarchar(200)
DECLARE @strSQLByDate nvarchar(200)
DECLARE @pagetop int
IF @fid<>0
SET @strSQLByFid=' AND [fid]='+STR(@fid)+'' 

IF @timebetween<>0
SET @strSQLByDate=' AND DATEDIFF(DAY,[postdatetime],GETDATE())<=' + STR(@timebetween)

SET @strSQL = 'SELECT COUNT(1) FROM [dnt_topics] WHERE 1=1 '+@strSQLByFid+@strSQLByDate
EXEC(@strSQL)
GO
/****** Object:  StoredProcedure [dbo].[dnt_getpostcountbyuid]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_getpostcountbyuid]
@uid INT,
@posttablename VARCHAR(50)
AS
EXEC ('SELECT COUNT([pid]) AS [postcount] FROM [' + @posttablename + '] WHERE [posterid] = ' + @uid)
GO
/****** Object:  Table [dbo].[dnt_bonuslog]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_bonuslog](
	[tid] [int] NOT NULL,
	[authorid] [int] NOT NULL,
	[answerid] [int] NOT NULL,
	[answername] [nchar](20) NOT NULL,
	[pid] [int] NOT NULL,
	[dateline] [datetime] NOT NULL,
	[bonus] [int] NOT NULL,
	[extid] [tinyint] NOT NULL,
	[isbest] [int] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_bbcodes]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_bbcodes](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[available] [int] NOT NULL,
	[tag] [varchar](100) NOT NULL,
	[icon] [varchar](50) NULL,
	[example] [nvarchar](255) NOT NULL,
	[params] [int] NOT NULL,
	[nest] [int] NOT NULL,
	[explanation] [ntext] NULL,
	[replacement] [ntext] NULL,
	[paramsdescript] [ntext] NULL,
	[paramsdefvalue] [ntext] NULL,
 CONSTRAINT [PK_dnt_bbcodes] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [dnt_bbcodes_available] ON [dbo].[dnt_bbcodes] 
(
	[available] 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) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_banned]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_banned](
	[id] [smallint] NOT NULL,
	[ip1] [smallint] NOT NULL,
	[ip2] [smallint] NOT NULL,
	[ip3] [smallint] NOT NULL,
	[ip4] [smallint] NOT NULL,
	[admin] [nvarchar](50) NOT NULL,
	[dateline] [datetime] NOT NULL,
	[expiration] [datetime] NOT NULL,
 CONSTRAINT [PK_dnt_banned] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_attachtypes]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_attachtypes](
	[id] [smallint] IDENTITY(1,1) NOT NULL,
	[extension] [varchar](256) NOT NULL,
	[maxsize] [int] NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[dnt_attachpaymentlog]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_attachpaymentlog](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[uid] [int] NOT NULL,
	[username] [nchar](20) NOT NULL,
	[aid] [int] NOT NULL,
	[authorid] [int] NOT NULL,
	[postdatetime] [datetime] NOT NULL,
	[amount] [int] NOT NULL,
	[netamount] [int] NOT NULL,
 CONSTRAINT [PK_dnt_attachpaymentlog] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_dnt_attachpaymentlog_uid] ON [dbo].[dnt_attachpaymentlog] 
(
	[uid] ASC,
	[aid] 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) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_attachments]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_attachments](
	[aid] [int] IDENTITY(1,1) NOT NULL,
	[uid] [int] NOT NULL,
	[tid] [int] NOT NULL,
	[pid] [int] NOT NULL,
	[postdatetime] [datetime] NOT NULL,
	[readperm] [int] NOT NULL,
	[filename] [nchar](100) NOT NULL,
	[description] [nchar](100) NOT NULL,
	[filetype] [nchar](50) NOT NULL,
	[filesize] [int] NOT NULL,
	[attachment] [nchar](100) NOT NULL,
	[downloads] [int] NOT NULL,
	[width] [int] NOT NULL,
	[height] [int] NOT NULL,
	[attachprice] [int] NOT NULL,
 CONSTRAINT [PK_dnt_attachments] PRIMARY KEY CLUSTERED 
(
	[aid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [pid] ON [dbo].[dnt_attachments] 
(
	[pid] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [tid] ON [dbo].[dnt_attachments] 
(
	[tid] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [uid] ON [dbo].[dnt_attachments] 
(
	[uid] 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) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_announcements]    Script Date: 06/10/2013 22:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_announcements](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[poster] [nvarchar](20) NOT NULL,
	[posterid] [int] NOT NULL,
	[title] [nvarchar](250) NOT NULL,
	[displayorder] [int] NOT NULL,
	[starttime] [datetime] NOT NULL,
	[endtime] [datetime] NOT NULL,
	[message] [ntext] NOT NULL,
 CONSTRAINT [PK_dnt_announcements] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_advertisements]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_advertisements](
	[advid] [int] IDENTITY(1,1) NOT NULL,
	[available] [int] NOT NULL,
	[type] [nvarchar](50) NOT NULL,
	[displayorder] [int] NOT NULL,
	[title] [nvarchar](50) NOT NULL,
	[targets] [nvarchar](255) NOT NULL,
	[starttime] [datetime] NOT NULL,
	[endtime] [datetime] NOT NULL,
	[code] [ntext] NOT NULL,
	[parameters] [ntext] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_adminvisitlog]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_adminvisitlog](
	[visitid] [int] IDENTITY(1,1) NOT NULL,
	[uid] [int] NULL,
	[username] [nvarchar](20) NOT NULL,
	[groupid] [int] NULL,
	[grouptitle] [nvarchar](50) NOT NULL,
	[ip] [varchar](15) NULL,
	[postdatetime] [datetime] NULL,
	[actions] [nvarchar](100) NOT NULL,
	[others] [nvarchar](200) NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[dnt_admingroups]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_admingroups](
	[admingid] [smallint] NOT NULL,
	[alloweditpost] [tinyint] NOT NULL,
	[alloweditpoll] [tinyint] NOT NULL,
	[allowstickthread] [tinyint] NOT NULL,
	[allowmodpost] [tinyint] NOT NULL,
	[allowdelpost] [tinyint] NOT NULL,
	[allowmassprune] [tinyint] NOT NULL,
	[allowrefund] [tinyint] NOT NULL,
	[allowcensorword] [tinyint] NOT NULL,
	[allowviewip] [tinyint] NOT NULL,
	[allowbanip] [tinyint] NOT NULL,
	[allowedituser] [tinyint] NOT NULL,
	[allowmoduser] [tinyint] NOT NULL,
	[allowbanuser] [tinyint] NOT NULL,
	[allowpostannounce] [tinyint] NOT NULL,
	[allowviewlog] [tinyint] NOT NULL,
	[disablepostctrl] [tinyint] NOT NULL,
	[allowviewrealname] [tinyint] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_forums]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_forums](
	[fid] [int] IDENTITY(1,1) NOT NULL,
	[parentid] [int] NOT NULL,
	[layer] [smallint] NOT NULL,
	[pathlist] [nchar](3000) NOT NULL,
	[parentidlist] [char](300) NOT NULL,
	[subforumcount] [int] NOT NULL,
	[name] [nchar](50) NOT NULL,
	[status] [int] NOT NULL,
	[colcount] [smallint] NOT NULL,
	[displayorder] [int] NOT NULL,
	[templateid] [smallint] NOT NULL,
	[topics] [int] NOT NULL,
	[curtopics] [int] NOT NULL,
	[posts] [int] NOT NULL,
	[todayposts] [int] NOT NULL,
	[lasttid] [int] NOT NULL,
	[lasttitle] [nchar](60) NOT NULL,
	[lastpost] [datetime] NOT NULL,
	[lastposterid] [int] NOT NULL,
	[lastposter] [nchar](20) NOT NULL,
	[allowsmilies] [int] NOT NULL,
	[allowrss] [int] NOT NULL,
	[allowhtml] [int] NOT NULL,
	[allowbbcode] [int] NOT NULL,
	[allowimgcode] [int] NOT NULL,
	[allowblog] [int] NOT NULL,
	[istrade] [int] NOT NULL,
	[allowpostspecial] [int] NOT NULL,
	[allowspecialonly] [int] NULL,
	[alloweditrules] [int] NOT NULL,
	[allowthumbnail] [int] NOT NULL,
	[allowtag] [int] NOT NULL,
	[recyclebin] [int] NOT NULL,
	[modnewposts] [int] NOT NULL,
	[jammer] [int] NOT NULL,
	[disablewatermark] [int] NOT NULL,
	[inheritedmod] [int] NOT NULL,
	[autoclose] [smallint] NOT NULL,
 CONSTRAINT [PK_dnt_forums] PRIMARY KEY CLUSTERED 
(
	[fid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [IX_dnt_forums_status] ON [dbo].[dnt_forums] 
(
	[status] ASC,
	[layer] ASC,
	[parentid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_forumlinks]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_forumlinks](
	[id] [smallint] IDENTITY(1,1) NOT NULL,
	[displayorder] [int] NOT NULL,
	[name] [nvarchar](100) NOT NULL,
	[url] [nvarchar](100) NOT NULL,
	[note] [nvarchar](200) NOT NULL,
	[logo] [nvarchar](100) NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_forumfields]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_forumfields](
	[fid] [int] NOT NULL,
	[password] [nvarchar](16) NOT NULL,
	[icon] [varchar](255) NULL,
	[postcredits] [varchar](255) NULL,
	[replycredits] [varchar](255) NULL,
	[redirect] [varchar](255) NULL,
	[attachextensions] [varchar](255) NULL,
	[rules] [text] NULL,
	[topictypes] [text] NULL,
	[viewperm] [text] NULL,
	[postperm] [text] NULL,
	[replyperm] [text] NULL,
	[getattachperm] [text] NULL,
	[postattachperm] [text] NULL,
	[moderators] [ntext] NULL,
	[description] [ntext] NULL,
	[applytopictype] [tinyint] NOT NULL,
	[postbytopictype] [tinyint] NOT NULL,
	[viewbytopictype] [tinyint] NOT NULL,
	[topictypeprefix] [tinyint] NOT NULL,
	[permuserlist] [ntext] NULL,
	[seokeywords] [nvarchar](500) NULL,
	[seodescription] [nvarchar](500) NULL,
	[rewritename] [nvarchar](20) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [dnt_forumfields_fid] ON [dbo].[dnt_forumfields] 
(
	[fid] 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) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_favorites]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_favorites](
	[uid] [int] NOT NULL,
	[tid] [int] NOT NULL,
	[typeid] [tinyint] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_failedlogins]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_failedlogins](
	[ip] [char](15) NOT NULL,
	[errcount] [smallint] NOT NULL,
	[lastupdate] [smalldatetime] NOT NULL,
 CONSTRAINT [PK_dnt_failedlogins] PRIMARY KEY CLUSTERED 
(
	[ip] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  StoredProcedure [dbo].[dnt_getlastpostbyfid]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_getlastpostbyfid]
@fid INT,
@posttablename VARCHAR(50)
AS
EXEC ('SELECT TOP 1 [tid], [title], [postdatetime], [posterid], [poster], [pid] 
FROM [' + @posttablename + '] 
WHERE [fid] = ' + @fid +
'ORDER BY [pid] DESC')
GO
/****** Object:  StoredProcedure [dbo].[dnt_getsitemapnewtopics]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getsitemapnewtopics]
@fidlist VARCHAR(500)
AS
IF @fidlist<>''
     BEGIN
      DECLARE @strSQL VARCHAR(5000)
      SET @strSQL = 'SELECT TOP 20 [tid], [fid], [title], [poster], [postdatetime], [lastpost], [replies], [views], [digest] FROM [dnt_topics] WHERE [fid] 
NOT IN ('+@fidlist +') ORDER BY [tid] DESC' 
     END
ELSE
     BEGIN
      SET @strSQL = 'SELECT TOP 20 [tid], [fid], [title], [poster], [postdatetime], [lastpost], [replies], [views], [digest] FROM [dnt_topics] ORDER BY [tid] 
DESC'
     END
  EXEC(@strSQL)
GO
/****** Object:  StoredProcedure [dbo].[dnt_getdesignatepostcount]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_getdesignatepostcount]
@fid INT,
@posttablename VARCHAR(50)
AS
EXEC ('SELECT COUNT([pid]) AS [postcount] FROM [' + @posttablename + '] WHERE [fid] = ' + @fid)
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettodaypostcountbyuid]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_gettodaypostcountbyuid]
@uid INT,
@posttablename VARCHAR(50)
AS
EXEC ('SELECT COUNT([pid]) AS [postcount] 
FROM [' + @posttablename + '] 
WHERE [posterid] = ' + @uid + ' AND DATEDIFF(day, [postdatetime], GETDATE()) = 0')
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopiccountbytype]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gettopiccountbytype]
@condition varchar(4000)
AS
DECLARE @sql varchar(4100)
set @sql ='SELECT COUNT(tid) FROM [dnt_topics] WHERE [displayorder]>-1 AND [closed]<=1 '+@condition
exec(@sql)
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopiccountbycondition]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gettopiccountbycondition]
@fid int,
@state int=0,
@condition varchar(80)=null
AS
DECLARE @sql varchar(500)
IF @state=-1
	BEGIN
		set @sql ='SELECT COUNT(tid) FROM [dnt_topics] WHERE [fid]='+str(@fid)+' AND [displayorder]>-1 AND [closed]<=1'+@condition
	END
ELSE
	BEGIN
set @sql ='SELECT COUNT(tid) FROM [dnt_topics] WHERE [fid]='+str(@fid)+' AND [displayorder]>-1 AND [closed]='+str(@state)+' AND [closed]<=1'+@condition
	END
exec(@sql)
GO
/****** Object:  Table [dbo].[dnt_help]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_help](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[title] [nvarchar](100) NOT NULL,
	[message] [ntext] NULL,
	[pid] [int] NOT NULL,
	[orderby] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_navs]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_navs](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[parentid] [int] NOT NULL,
	[name] [char](50) NOT NULL,
	[title] [char](255) NOT NULL,
	[url] [char](255) NOT NULL,
	[target] [tinyint] NOT NULL,
	[type] [tinyint] NOT NULL,
	[available] [tinyint] NOT NULL,
	[displayorder] [int] NOT NULL,
	[highlight] [tinyint] NOT NULL,
	[level] [tinyint] NOT NULL,
 CONSTRAINT [PK_id] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[dnt_mytopics]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_mytopics](
	[uid] [int] NOT NULL,
	[tid] [int] NOT NULL,
	[dateline] [smalldatetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_myposts]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_myposts](
	[uid] [int] NOT NULL,
	[tid] [int] NOT NULL,
	[pid] [int] NOT NULL,
	[dateline] [smalldatetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_myattachments]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_myattachments](
	[aid] [int] NOT NULL,
	[uid] [int] NOT NULL,
	[attachment] [nchar](100) NOT NULL,
	[description] [nchar](100) NOT NULL,
	[postdatetime] [datetime] NOT NULL,
	[downloads] [int] NOT NULL,
	[filename] [nchar](100) NOT NULL,
	[pid] [int] NOT NULL,
	[tid] [int] NOT NULL,
	[extname] [nvarchar](50) NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_moderators]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_moderators](
	[uid] [int] NOT NULL,
	[fid] [smallint] NOT NULL,
	[displayorder] [smallint] NOT NULL,
	[inherited] [smallint] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_moderatormanagelog]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_moderatormanagelog](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[moderatoruid] [int] NULL,
	[moderatorname] [nvarchar](50) NULL,
	[groupid] [int] NULL,
	[grouptitle] [nvarchar](50) NULL,
	[ip] [varchar](15) NULL,
	[postdatetime] [datetime] NULL,
	[fid] [int] NULL,
	[fname] [nvarchar](100) NULL,
	[tid] [int] NULL,
	[title] [varchar](200) NULL,
	[actions] [varchar](50) NULL,
	[reason] [nvarchar](200) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [dnt_moderatormanagelog_tid] ON [dbo].[dnt_moderatormanagelog] 
(
	[tid] 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) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_medalslog]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_medalslog](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[adminname] [nvarchar](50) NULL,
	[adminid] [int] NULL,
	[ip] [nvarchar](15) NULL,
	[postdatetime] [datetime] NULL,
	[username] [nvarchar](50) NULL,
	[uid] [int] NULL,
	[actions] [nvarchar](100) NULL,
	[medals] [int] NULL,
	[reason] [nvarchar](100) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_medals]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_medals](
	[medalid] [smallint] NOT NULL,
	[name] [nvarchar](50) NOT NULL,
	[available] [int] NOT NULL,
	[image] [varchar](30) NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[dnt_locations]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_locations](
	[lid] [int] IDENTITY(1,1) NOT NULL,
	[city] [nvarchar](50) NOT NULL,
	[state] [nvarchar](50) NOT NULL,
	[country] [nvarchar](50) NOT NULL,
	[zipcode] [nvarchar](20) NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_orders]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_orders](
	[orderid] [int] IDENTITY(10000,1) NOT NULL,
	[ordercode] [char](32) NOT NULL,
	[uid] [int] NOT NULL,
	[buyer] [char](20) NOT NULL,
	[paytype] [tinyint] NOT NULL,
	[tradeno] [char](32) NULL,
	[price] [decimal](18, 2) NOT NULL,
	[orderstatus] [tinyint] NOT NULL,
	[createdtime] [smalldatetime] NOT NULL,
	[confirmedtime] [smalldatetime] NULL,
	[credit] [tinyint] NOT NULL,
	[amount] [int] NOT NULL,
 CONSTRAINT [PK_dnt_orders_orderid] PRIMARY KEY CLUSTERED 
(
	[orderid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [dnt_orders_ordercode] ON [dbo].[dnt_orders] 
(
	[ordercode] 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) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_onlinetime]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_onlinetime](
	[uid] [int] NOT NULL,
	[thismonth] [smallint] NOT NULL,
	[total] [int] NOT NULL,
	[lastupdate] [datetime] NOT NULL,
 CONSTRAINT [PK_dnt_onlinetime] PRIMARY KEY CLUSTERED 
(
	[uid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_onlinelist]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_onlinelist](
	[groupid] [smallint] NOT NULL,
	[displayorder] [int] NULL,
	[title] [nvarchar](50) NOT NULL,
	[img] [varchar](50) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[dnt_online]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_online](
	[olid] [int] IDENTITY(1,1) NOT NULL,
	[userid] [int] NOT NULL,
	[ip] [varchar](15) NOT NULL,
	[username] [nvarchar](20) NOT NULL,
	[nickname] [nvarchar](20) NOT NULL,
	[password] [char](32) NOT NULL,
	[groupid] [smallint] NOT NULL,
	[olimg] [varchar](80) NOT NULL,
	[adminid] [smallint] NOT NULL,
	[invisible] [smallint] NOT NULL,
	[action] [smallint] NOT NULL,
	[lastactivity] [smallint] NOT NULL,
	[lastposttime] [datetime] NOT NULL,
	[lastpostpmtime] [datetime] NOT NULL,
	[lastsearchtime] [datetime] NOT NULL,
	[lastupdatetime] [datetime] NOT NULL,
	[forumid] [int] NOT NULL,
	[forumname] [nvarchar](50) NOT NULL,
	[titleid] [int] NOT NULL,
	[title] [nvarchar](80) NOT NULL,
	[verifycode] [varchar](10) NOT NULL,
	[newpms] [smallint] NOT NULL,
	[newnotices] [smallint] NOT NULL,
 CONSTRAINT [PK_dnt_online] PRIMARY KEY CLUSTERED 
(
	[olid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [forum] ON [dbo].[dnt_online] 
(
	[userid] ASC,
	[forumid] ASC,
	[invisible] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [forumid] ON [dbo].[dnt_online] 
(
	[forumid] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [invisible] ON [dbo].[dnt_online] 
(
	[userid] ASC,
	[invisible] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [ip] ON [dbo].[dnt_online] 
(
	[userid] ASC,
	[ip] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [password] ON [dbo].[dnt_online] 
(
	[userid] ASC,
	[password] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_notices]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_notices](
	[nid] [int] IDENTITY(1,1) NOT NULL,
	[uid] [int] NOT NULL,
	[type] [smallint] NOT NULL,
	[new] [tinyint] NOT NULL,
	[posterid] [int] NOT NULL,
	[poster] [nchar](20) NOT NULL,
	[note] [ntext] NOT NULL,
	[postdatetime] [datetime] NOT NULL,
 CONSTRAINT [PK_dnt_notices_nid] PRIMARY KEY CLUSTERED 
(
	[nid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [uid] ON [dbo].[dnt_notices] 
(
	[uid] DESC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_topictypes]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_topictypes](
	[typeid] [int] IDENTITY(1,1) NOT NULL,
	[displayorder] [int] NOT NULL,
	[name] [nvarchar](30) NOT NULL,
	[description] [nvarchar](500) NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_topictags]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_topictags](
	[tagid] [int] NOT NULL,
	[tid] [int] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_topictagcaches]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_topictagcaches](
	[tid] [int] NOT NULL,
	[linktid] [int] NOT NULL,
	[linktitle] [nchar](60) NOT NULL
) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_dnt_topictagcaches_tid] ON [dbo].[dnt_topictagcaches] 
(
	[tid] ASC
)
INCLUDE ( [linktid],
[linktitle]) 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) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_topics]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_topics](
	[tid] [int] IDENTITY(1,1) NOT NULL,
	[fid] [smallint] NOT NULL,
	[iconid] [tinyint] NOT NULL,
	[typeid] [int] NOT NULL,
	[readperm] [int] NOT NULL,
	[price] [smallint] NOT NULL,
	[poster] [nchar](20) NOT NULL,
	[posterid] [int] NOT NULL,
	[title] [nchar](60) NOT NULL,
	[attention] [int] NOT NULL,
	[postdatetime] [datetime] NOT NULL,
	[lastpost] [datetime] NOT NULL,
	[lastpostid] [int] NOT NULL,
	[lastposter] [nchar](20) NOT NULL,
	[lastposterid] [int] NOT NULL,
	[views] [int] NOT NULL,
	[replies] [int] NOT NULL,
	[displayorder] [int] NOT NULL,
	[highlight] [varchar](500) NOT NULL,
	[digest] [tinyint] NOT NULL,
	[rate] [int] NOT NULL,
	[hide] [int] NOT NULL,
	[attachment] [int] NOT NULL,
	[moderated] [tinyint] NOT NULL,
	[closed] [int] NOT NULL,
	[magic] [int] NOT NULL,
	[identify] [int] NOT NULL,
	[special] [tinyint] NOT NULL,
 CONSTRAINT [PK_dnt_topics] PRIMARY KEY NONCLUSTERED 
(
	[tid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE UNIQUE CLUSTERED INDEX [list] ON [dbo].[dnt_topics] 
(
	[fid] ASC,
	[displayorder] ASC,
	[lastpostid] DESC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [displayorder] ON [dbo].[dnt_topics] 
(
	[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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [displayorder_fid] ON [dbo].[dnt_topics] 
(
	[displayorder] ASC,
	[fid] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [fid] ON [dbo].[dnt_topics] 
(
	[fid] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [fid_displayorder] ON [dbo].[dnt_topics] 
(
	[fid] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [list_date] ON [dbo].[dnt_topics] 
(
	[fid] ASC,
	[displayorder] ASC,
	[postdatetime] ASC,
	[lastpostid] DESC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [list_replies] ON [dbo].[dnt_topics] 
(
	[fid] ASC,
	[displayorder] ASC,
	[postdatetime] ASC,
	[replies] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [list_tid] ON [dbo].[dnt_topics] 
(
	[fid] ASC,
	[displayorder] ASC,
	[tid] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [list_views] ON [dbo].[dnt_topics] 
(
	[fid] ASC,
	[displayorder] ASC,
	[postdatetime] ASC,
	[views] 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) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [tid] ON [dbo].[dnt_topics] 
(
	[tid] DESC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_topicidentify]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_topicidentify](
	[identifyid] [int] IDENTITY(1,1) NOT NULL,
	[name] [nvarchar](50) NOT NULL,
	[filename] [varchar](50) NOT NULL,
 CONSTRAINT [PK_dnt_topicidentify] PRIMARY KEY CLUSTERED 
(
	[identifyid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[dnt_templates]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_templates](
	[templateid] [smallint] IDENTITY(1,1) NOT NULL,
	[directory] [varchar](100) NOT NULL,
	[name] [nvarchar](50) NOT NULL,
	[author] [nvarchar](100) NOT NULL,
	[createdate] [nvarchar](50) NOT NULL,
	[ver] [nvarchar](100) NOT NULL,
	[fordntver] [nvarchar](100) NOT NULL,
	[copyright] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_dnt_templates] PRIMARY KEY CLUSTERED 
(
	[templateid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[dnt_tags]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_tags](
	[tagid] [int] IDENTITY(1,1) NOT NULL,
	[tagname] [nchar](10) NOT NULL,
	[userid] [int] NOT NULL,
	[postdatetime] [datetime] NOT NULL,
	[orderid] [int] NOT NULL,
	[color] [char](6) NOT NULL,
	[count] [int] NOT NULL,
	[fcount] [int] NOT NULL,
	[pcount] [int] NOT NULL,
	[scount] [int] NOT NULL,
	[vcount] [int] NOT NULL,
	[gcount] [int] NOT NULL,
 CONSTRAINT [PK_dnt_tags] PRIMARY KEY CLUSTERED 
(
	[tagid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[dnt_tablelist]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnt_tablelist](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[createdatetime] [datetime] NOT NULL,
	[description] [nvarchar](50) NOT NULL,
	[mintid] [int] NOT NULL,
	[maxtid] [int] NOT NULL,
 CONSTRAINT [PK_dnt_tablelist] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_statvars]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_statvars](
	[type] [char](20) NOT NULL,
	[variable] [char](20) NOT NULL,
	[value] [text] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[dnt_stats]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_stats](
	[type] [char](10) NOT NULL,
	[variable] [char](20) NOT NULL,
	[count] [int] NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE UNIQUE CLUSTERED INDEX [IX_dnt_statvars] ON [dbo].[dnt_stats] 
(
	[type] ASC,
	[variable] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = ON, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[dnt_statistics]    Script Date: 06/10/2013 22:26:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_statistics](
	[totaltopic] [int] NOT NULL,
	[totalpost] [int] NOT NULL,
	[totalusers] [int] NOT NULL,
	[lastusername] [nchar](20) NOT NULL,
	[lastuserid] [int] NOT NULL,
	[highestonlineusercount] [int] NULL,
	[highestonlineusertime] [smalldatetime] NULL,
	[yesterdayposts] [int] NOT NULL,
	[highestposts] [int] NOT NULL,
	[highestpostsdate] [char](10) NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  UserDefinedFunction [dbo].[dnt_split]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[dnt_split]
(
 @splitstring NVARCHAR(4000),
 @separator CHAR(1) = ','
)
RETURNS @splitstringstable TABLE
(
 [item] NVARCHAR(200)
)
AS
BEGIN
    DECLARE @currentindex INT
    DECLARE @nextindex INT
    DECLARE @returntext NVARCHAR(200)

    SELECT @currentindex=1

    WHILE(@currentindex<=datalength(@splitstring)/2)
    BEGIN
        SELECT @nextindex=charindex(@separator,@splitstring,@currentindex)
        IF(@nextindex=0 OR @nextindex IS NULL)
            SELECT @nextindex=datalength(@splitstring)/2+1
        
        SELECT @returntext=substring(@splitstring,@currentindex,@nextindex-@currentindex)

        INSERT INTO @splitstringstable([item])
        VALUES(@returntext)
        
        SELECT @currentindex=@nextindex+1
    END
    RETURN
END
GO
/****** Object:  Table [dbo].[dnt_smilies]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dnt_smilies](
	[id] [int] NOT NULL,
	[displayorder] [int] NOT NULL,
	[type] [int] NOT NULL,
	[code] [nvarchar](30) NOT NULL,
	[url] [varchar](60) NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [IX_dnt_smilies_type] ON [dbo].[dnt_smilies] 
(
	[type] ASC,
	[displayorder] ASC,
	[id] ASC
)
INCLUDE ( [code],
[url]) 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) ON [PRIMARY]
GO
/****** Object:  StoredProcedure [dbo].[dnt_shrinklog]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_shrinklog]  
@DBName  nchar(50) 
AS
Begin
	exec('BACKUP LOG ['+@DBName+']  WITH NO_LOG')
	exec('DBCC  SHRINKDATABASE(['+@DBName+'])')
End
GO
/****** Object:  StoredProcedure [dbo].[dnt_setlastexecutescheduledeventdatetime]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_setlastexecutescheduledeventdatetime]
(
	@key VARCHAR(100),
	@servername VARCHAR(100),
	@lastexecuted DATETIME
)
AS
DELETE FROM [dnt_scheduledevents] WHERE ([key]=@key) AND ([lastexecuted] < DATEADD([day], - 7, GETDATE()))

INSERT [dnt_scheduledevents] ([key], [servername], [lastexecuted]) Values (@key, @servername, @lastexecuted)
GO
/****** Object:  StoredProcedure [dbo].[dnt_setcurrenttopics]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_setcurrenttopics]
@fid int
AS
UPDATE 
[dnt_forums] 
SET [curtopics] = (SELECT COUNT(tid) FROM [dnt_topics] WHERE [displayorder] >= 0 AND [fid]=@fid) WHERE [fid]=@fid
GO
/****** Object:  StoredProcedure [dbo].[dnt_neatenrelatetopic]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_neatenrelatetopic]
AS
BEGIN
	DECLARE @tagid int
	DECLARE [tag_cursor] CURSOR FOR	
	SELECT DISTINCT [tagid] FROM [dnt_topictags]
	OPEN [tag_cursor]
	FETCH NEXT FROM [tag_cursor] INTO @tagid
	WHILE @@FETCH_STATUS = 0
		BEGIN
			INSERT INTO [dnt_topictagcaches] 
			SELECT [t1].[tid],[t2].[tid],[t2].[title] FROM (SELECT [tid] FROM [dnt_topictags]
				WHERE [tagid] = @tagid) AS [t1],(SELECT [t].[tid],[t].[title] FROM [dnt_topics] AS [t],[dnt_topictags] AS [tt] 
				WHERE [tt].[tagid] = @tagid AND [t].[tid] = [tt].[tid] AND [t].[displayorder] >=0) AS [t2] 
			WHERE [t1].[tid] <> [t2].[tid] AND NOT EXISTS (SELECT 1 FROM [dnt_topictagcaches] WHERE [tid]=[t1].[tid] AND [linktid]=[t2].[tid])
			

			FETCH NEXT FROM [tag_cursor] INTO @tagid
		END
	CLOSE [tag_cursor]
	DEALLOCATE [tag_cursor]

END
GO
/****** Object:  StoredProcedure [dbo].[dnt_isinvitecodeexist]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_isinvitecodeexist]
@code nchar(8)
AS
BEGIN
SELECT COUNT(1) FROM [dnt_invitation] WHERE [invitecode]=@code AND [isdeleted] =0
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_getusers]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_getusers]
@start_uid INT,
@end_uid INT
AS
SELECT [uid] FROM [dnt_users] WHERE [uid] >= @start_uid AND [uid]<=@end_uid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getuserlistbygroupid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_getuserlistbygroupid]
@groupIdList VARCHAR(500)
AS
SELECT 
[uid],
[username],
[nickname],
[password],
[secques],
[spaceid],
[gender],
[adminid],
[groupid],
[groupexpiry],
[extgroupids],
[regip],
[joindate],
[lastip],
[lastvisit],
[lastactivity],
[lastpost],
[lastpostid],
[lastposttitle],
[posts],
[digestposts],
[oltime],
[pageviews],
[credits],
[extcredits1],
[extcredits2],
[extcredits3],
[extcredits4],
[extcredits5],
[extcredits6],
[extcredits7],
[extcredits8],
[avatarshowid],
[email],
[bday],
[sigstatus],
[tpp],
[ppp],
[templateid],
[pmsound],
[showemail],
[invisible],
[newpm],
[newpmcount],
[accessmasks],
[onlinestate],
[newsletter],
[salt]
FROM [dnt_users] WHERE [groupid] IN (SELECT [item] FROM [dnt_split](@groupIdList, ','))
GO
/****** Object:  StoredProcedure [dbo].[dnt_getuserlist]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getuserlist]
@pagesize int,
@pageindex int,
@column varchar(20),
@ordertype AS varchar(5)
AS
DECLARE @startRow int,
		@endRow	int
SET @startRow = (@pageindex - 1) * @pagesize + 1
SET @endRow = @startRow + @pagesize - 1

IF (@ordertype = 'DESC')
BEGIN
	IF (@column = 'username')
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[username] DESC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	ELSE IF (@column = 'credits')
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[credits] DESC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	ELSE IF (@column = 'posts')
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[posts] DESC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	ELSE IF (@column = 'admin')
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[adminid] ASC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid] WHERE [dnt_users].[adminid] > 0) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	ELSE IF (@column = 'lastactivity')
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[lastactivity] DESC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	ELSE IF (@column = 'joindate')
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[joindate] DESC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	ELSE IF (@column = 'oltime')
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[oltime] DESC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	ELSE
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[uid] DESC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
END
ELSE
BEGIN
	IF (@column = 'username')
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[username] ASC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	ELSE IF (@column = 'credits')
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[credits] ASC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	ELSE IF (@column = 'posts')
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[posts] ASC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	ELSE IF (@column = 'admin')
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[adminid] DESC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid] WHERE [dnt_users].[adminid] > 0) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	ELSE IF (@column = 'lastactivity')
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[lastactivity] ASC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	ELSE IF (@column = 'joindate')
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[joindate] ASC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	ELSE IF (@column = 'oltime')
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[oltime] ASC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	ELSE
	BEGIN
		SELECT 
			[USERS].[uid], 
			[USERS].[groupid], 
			[USERS].[username], 
			[USERS].[nickname], 
			[USERS].[joindate], 
			[USERS].[credits], 
			[USERS].[posts], 
			[USERS].[email], 
			[USERS].[lastactivity], 
			[USERS].[oltime], 
			[USERS].[location] 
		FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[uid] ASC ) AS ROWID,
			[dnt_users].[uid], 
			[dnt_users].[groupid], 
			[dnt_users].[username], 
			[dnt_users].[nickname], 
			[dnt_users].[joindate], 
			[dnt_users].[credits], 
			[dnt_users].[posts], 
			[dnt_users].[email], 
			[dnt_users].[lastactivity], 
			[dnt_users].[oltime], 
			[dnt_userfields].[location]
		FROM [dnt_users]
		LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_getuserinvitecodecount]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getuserinvitecodecount]
@creatorid int
AS
BEGIN
SELECT COUNT(1) FROM [dnt_invitation] WHERE [creatorid]=@creatorid AND [invitetype]=3 AND [isdeleted]=0
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_getuserinfobyip]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getuserinfobyip]
@regip char(15)
AS

SELECT TOP 1 [u].[uid], [u].[username], [u].[nickname], [u].[password], [u].[secques], [u].[spaceid], [u].[gender], [u].[adminid], [u].[groupid], [u].[groupexpiry], [u].[extgroupids], [u].[regip], [u].[joindate], [u].[lastip], [u].[lastvisit], [u].[lastactivity], [u].[lastpost], [u].[lastpostid], [u].[lastposttitle], [u].[posts], [u].[digestposts], [u].[oltime], [u].[pageviews], [u].[credits], [u].[extcredits1], [u].[extcredits2], [u].[extcredits3], [u].[extcredits4], [u].[extcredits5], [u].[extcredits6], [u].[extcredits7], [u].[extcredits8], [u].[avatarshowid], [u].[email], [u].[bday], [u].[sigstatus], [u].[tpp], [u].[ppp], [u].[templateid], [u].[pmsound], [u].[showemail], [u].[invisible], [u].[newpm], [u].[newpmcount], [u].[accessmasks], [u].[onlinestate], [u].[newsletter],[u].[salt], [uf].[website], [uf].[icq], [uf].[qq], [uf].[yahoo], [uf].[msn], [uf].[skype], [uf].[location], [uf].[customstatus], [uf].[avatar], [uf].[avatarwidth], [uf].[avatarheight], [uf].[medals], [uf].[bio], [uf].[signature], [uf].[sightml], [uf].[authstr], [uf].[authtime], [uf].[authflag], [uf].[realname], [uf].[idcard], [uf].[mobile], [uf].[phone], [uf].[ignorepm] FROM [dnt_users] [u] LEFT JOIN [dnt_userfields] [uf] ON [u].[uid]=[uf].[uid] WHERE [u].[regip]=@regip ORDER BY [u].[uid] DESC
GO
/****** Object:  StoredProcedure [dbo].[dnt_getuserinfo]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getuserinfo]
@uid int
AS
SELECT TOP 1 
[dnt_users].[accessmasks], 
[dnt_users].[adminid],
[dnt_users].[avatarshowid],
[dnt_users].[bday],
[dnt_users].[credits],
[dnt_users].[digestposts],
[dnt_users].[email],
[dnt_users].[extcredits1],
[dnt_users].[extcredits2],
[dnt_users].[extcredits3],
[dnt_users].[extcredits4],
[dnt_users].[extcredits5],
[dnt_users].[extcredits6],
[dnt_users].[extcredits7],
[dnt_users].[extcredits8],
[dnt_users].[extgroupids],
[dnt_users].[gender],
[dnt_users].[groupexpiry],
[dnt_users].[groupid],
[dnt_users].[invisible],
[dnt_users].[joindate],
[dnt_users].[lastactivity],
[dnt_users].[lastip],
[dnt_users].[lastpost],
[dnt_users].[lastpostid],
[dnt_users].[lastposttitle],
[dnt_users].[lastvisit],
[dnt_users].[newpm],
[dnt_users].[newpmcount],
[dnt_users].[newsletter],
[dnt_users].[nickname],
[dnt_users].[oltime],
[dnt_users].[onlinestate],
[dnt_users].[pageviews],
[dnt_users].[password],
[dnt_users].[pmsound],
[dnt_users].[posts],
[dnt_users].[ppp],
[dnt_users].[regip],
[dnt_users].[secques],
[dnt_users].[showemail],
[dnt_users].[sigstatus],
[dnt_users].[spaceid],
[dnt_users].[templateid],
[dnt_users].[tpp],
[dnt_users].[uid],
[dnt_users].[username],
[dnt_users].[salt],
[dnt_userfields].[authflag],
[dnt_userfields].[authstr],
[dnt_userfields].[authtime],
[dnt_userfields].[avatar],
[dnt_userfields].[avatarheight],
[dnt_userfields].[avatarwidth],
[dnt_userfields].[bio],
[dnt_userfields].[customstatus],
[dnt_userfields].[icq],
[dnt_userfields].[idcard],
[dnt_userfields].[ignorepm],
[dnt_userfields].[location],
[dnt_userfields].[medals],
[dnt_userfields].[mobile],
[dnt_userfields].[msn],
[dnt_userfields].[phone],
[dnt_userfields].[qq],
[dnt_userfields].[realname],
[dnt_userfields].[sightml],
[dnt_userfields].[signature],
[dnt_userfields].[skype],
[dnt_userfields].[uid],
[dnt_userfields].[website],
[dnt_userfields].[yahoo]
FROM [dnt_users] LEFT JOIN [dnt_userfields] ON [dnt_users].[uid]=[dnt_userfields].[uid] 
WHERE [dnt_users].[uid]=@uid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getuseridbyemail]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getuseridbyemail]
@email char(50)
AS

SELECT TOP 1 [uid] FROM [dnt_users] WHERE [email]=@email
GO
/****** Object:  StoredProcedure [dbo].[dnt_getunauditpost]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getunauditpost]
@lastposter NVARCHAR(20),
@lastposterid INT
AS
UPDATE [dnt_topics] 
SET [lastposter]=@lastposter  
WHERE [lastposterid]=@lastposterid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getunauditnewtopicbycondition]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getunauditnewtopicbycondition]
@fidlist NVARCHAR(500),
@pagesize int,
@displayorder INT,
@pageindex int
AS
DECLARE @startRow int,
		@endRow int
SET @startRow = (@pageindex - 1) * @pagesize + 1
SET @endRow = @startRow + @pagesize -1
IF @fidlist = '0'
BEGIN
	SELECT 
	[TOPICS].[rate], 
	[TOPICS].[fid], 
	[TOPICS].[tid],
	[TOPICS].[iconid],
	[TOPICS].[typeid],
	[TOPICS].[title],
	[TOPICS].[price],
	[TOPICS].[hide],
	[TOPICS].[readperm],
	[TOPICS].[poster],
	[TOPICS].[posterid],
	[TOPICS].[replies],
	[TOPICS].[views],
	[TOPICS].[postdatetime],
	[TOPICS].[lastpost],
	[TOPICS].[lastposter],
	[TOPICS].[lastpostid],
	[TOPICS].[lastposterid],
	[TOPICS].[highlight],
	[TOPICS].[digest],
	[TOPICS].[displayorder],
	[TOPICS].[attachment],
	[TOPICS].[closed],
	[TOPICS].[magic],
	[TOPICS].[special] 
	FROM(SELECT ROW_NUMBER() OVER(ORDER BY [tid] DESC)AS ROWID,
	[dnt_topics].[rate], 
	[dnt_topics].[fid], 
	[dnt_topics].[tid],
	[dnt_topics].[iconid],
	[dnt_topics].[typeid],
	[dnt_topics].[title],
	[dnt_topics].[price],
	[dnt_topics].[hide],
	[dnt_topics].[readperm],
	[dnt_topics].[poster],
	[dnt_topics].[posterid],
	[dnt_topics].[replies],
	[dnt_topics].[views],
	[dnt_topics].[postdatetime],
	[dnt_topics].[lastpost],
	[dnt_topics].[lastposter],
	[dnt_topics].[lastpostid],
	[dnt_topics].[lastposterid],
	[dnt_topics].[highlight],
	[dnt_topics].[digest],
	[dnt_topics].[displayorder],
	[dnt_topics].[attachment],
	[dnt_topics].[closed],
	[dnt_topics].[magic],
	[dnt_topics].[special] 
	FROM [dnt_topics]
	WHERE [displayorder] = @displayorder) AS TOPICS
	WHERE ROWID BETWEEN @startRow AND @endRow
END
ELSE
BEGIN
	SELECT 
	[TOPICS].[rate], 
	[TOPICS].[fid], 
	[TOPICS].[tid],
	[TOPICS].[iconid],
	[TOPICS].[typeid],
	[TOPICS].[title],
	[TOPICS].[price],
	[TOPICS].[hide],
	[TOPICS].[readperm],
	[TOPICS].[poster],
	[TOPICS].[posterid],
	[TOPICS].[replies],
	[TOPICS].[views],
	[TOPICS].[postdatetime],
	[TOPICS].[lastpost],
	[TOPICS].[lastposter],
	[TOPICS].[lastpostid],
	[TOPICS].[lastposterid],
	[TOPICS].[highlight],
	[TOPICS].[digest],
	[TOPICS].[displayorder],
	[TOPICS].[attachment],
	[TOPICS].[closed],
	[TOPICS].[magic],
	[TOPICS].[special] 
	FROM(SELECT ROW_NUMBER() OVER(ORDER BY [tid] DESC)AS ROWID,
	[dnt_topics].[rate], 
	[dnt_topics].[fid], 
	[dnt_topics].[tid],
	[dnt_topics].[iconid],
	[dnt_topics].[typeid],
	[dnt_topics].[title],
	[dnt_topics].[price],
	[dnt_topics].[hide],
	[dnt_topics].[readperm],
	[dnt_topics].[poster],
	[dnt_topics].[posterid],
	[dnt_topics].[replies],
	[dnt_topics].[views],
	[dnt_topics].[postdatetime],
	[dnt_topics].[lastpost],
	[dnt_topics].[lastposter],
	[dnt_topics].[lastpostid],
	[dnt_topics].[lastposterid],
	[dnt_topics].[highlight],
	[dnt_topics].[digest],
	[dnt_topics].[displayorder],
	[dnt_topics].[attachment],
	[dnt_topics].[closed],
	[dnt_topics].[magic],
	[dnt_topics].[special] 
	FROM [dnt_topics]
	WHERE [displayorder] = @displayorder AND fid IN (@fidlist)) AS TOPICS
	WHERE ROWID BETWEEN @startRow AND @endRow	
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_getunauditnewtopic]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_getunauditnewtopic]
AS
SELECT 
	[tid],
	[fid],
	[iconid],
	[typeid],
	[readperm],
	[price],
	[poster],
	[posterid],
	[title],
	[attention],
	[postdatetime],
	[lastpost],
	[lastpostid],
	[lastposter],
	[lastposterid],
	[views],
	[replies],
	[displayorder],
	[highlight],
	[digest],
	[rate],
	[hide],
	[attachment],
	[moderated],
	[closed],
	[magic],
	[identify],
	[special]
FROM dnt_topics
WHERE [displayorder] = -2 OR [displayorder] = -3 
ORDER BY [tid] DESC
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettotaltopiccount]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_gettotaltopiccount]
AS
SELECT COUNT([tid]) AS [topicscount] FROM [dnt_topics]
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopusers]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_gettopusers]
@statcont INT,
@lastuid INT
AS
SELECT TOP (@statcont) [uid] FROM [dnt_users] WHERE [uid] > @lastuid
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettoptopiclist]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gettoptopiclist]
@fid int,
@pagesize int,
@pageindex int,
@tids varchar(500)
AS
DECLARE @startRow int,
		@endRow int
SET @startROW = ( @pageindex - 1 ) * @pagesize + 1
SET @endRow = @startRow +  @pagesize -1

SELECT 
[TOPICS].[rate], 
[TOPICS].[tid],
[TOPICS].[fid],
[TOPICS].[typeid],
[TOPICS].[iconid],
[TOPICS].[title],
[TOPICS].[price],
[TOPICS].[hide],
[TOPICS].[readperm], 
[TOPICS].[special],
[TOPICS].[poster],
[TOPICS].[posterid],
[TOPICS].[views],
[TOPICS].[postdatetime],
[TOPICS].[lastpost],
[TOPICS].[lastposter],
[TOPICS].[lastpostid],
[TOPICS].[lastposterid],
[TOPICS].[replies],
[TOPICS].[highlight],
[TOPICS].[digest],
[TOPICS].[displayorder],
[TOPICS].[closed],
[TOPICS].[attachment],
[TOPICS].[magic] 
FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_topics].[displayorder] DESC,[dnt_topics].[lastpost] DESC) AS ROWID,
[dnt_topics].[rate], 
[dnt_topics].[tid],
[dnt_topics].[fid],
[dnt_topics].[typeid],
[dnt_topics].[iconid],
[dnt_topics].[title],
[dnt_topics].[price],
[dnt_topics].[hide],
[dnt_topics].[readperm], 
[dnt_topics].[special],
[dnt_topics].[poster],
[dnt_topics].[posterid],
[dnt_topics].[views],
[dnt_topics].[postdatetime],
[dnt_topics].[lastpost],
[dnt_topics].[lastposter],
[dnt_topics].[lastpostid],
[dnt_topics].[lastposterid],
[dnt_topics].[replies],
[dnt_topics].[highlight],
[dnt_topics].[digest],
[dnt_topics].[displayorder],
[dnt_topics].[closed],
[dnt_topics].[attachment],
[dnt_topics].[magic]
FROM [dnt_topics]
WHERE [displayorder]>0 AND CHARINDEX(','+RTRIM([dnt_topics].[tid])+',', ','+@tids+',')>0)AS TOPICS
WHERE ROWID BETWEEN @startRow AND @endRow
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopictids]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_gettopictids]
@statcount INT,
@lasttid INT
AS
SELECT TOP(@statcount) [tid] FROM [dnt_topics] WHERE [tid] > @lasttid ORDER BY [tid]
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopictags]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gettopictags]
@topicid int
AS

SELECT 
t.[color],
t.[count],
t.[fcount],
t.[gcount],
t.[orderid],
t.[pcount],
t.[postdatetime],
t.[scount],
t.[tagid],
t.[tagname],
t.[userid],
t.[vcount]
FROM [dnt_tags] t, [dnt_topictags] tt 
WHERE tt.[tagid] = t.[tagid] AND tt.[tid] = @topicid 
ORDER BY [orderid]
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopics]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_gettopics]
@start_tid INT,
@end_tid INT
AS
SELECT [tid] 
FROM [dnt_topics] 
WHERE [tid] >= @start_tid AND [tid]<=@end_tid 
ORDER BY [tid]
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopiccount]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gettopiccount]
@fid int
AS
SELECT [curtopics] FROM [dnt_forums] WHERE [fid] = @fid
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopforumfids]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_gettopforumfids]
@lastfid INT,
@statcount INT
AS
SELECT TOP(@statcount) [fid] FROM [dnt_forums] WHERE [fid] > @lastfid
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettodayusercreatedinvitecode]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gettodayusercreatedinvitecode]
@creatorid int
AS
BEGIN
SELECT COUNT(1) FROM [dnt_invitation] WHERE [creatorid]=@creatorid AND [invitetype]=2 AND (GETDATE()- [createdtime])<1
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettodayuploadedfilesize]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gettodayuploadedfilesize] 
@uid int

AS

SELECT SUM([filesize]) AS [todaysize] FROM [dnt_attachments] WHERE [uid]=@uid AND DATEDIFF(d,[postdatetime],GETDATE())=0
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettaginfo]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gettaginfo]
@tagid int
AS
SELECT 
[tagid],
[tagname],
[userid],
[postdatetime],
[orderid],
[color],
[count],
[fcount],
[pcount],
[scount],
[vcount],
[gcount] 
FROM [dnt_tags] 
WHERE [tagid]=@tagid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getsubforumcount]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_getsubforumcount]
@fid INT
AS
SELECT COUNT(fid) FROM [dnt_forums] WHERE [parentid]=@fid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getdebatepostlist1]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getdebatepostlist1] 
                    	@tid int,
                    	@opinion int,
                    	@pagesize int,
                    	@pageindex int
                    AS
                    	DECLARE @startRow int,
                                @endRow int
                    	SET @startRow = (@pageindex - 1) * @pagesize + 1
                    	SET	@endRow = @startRow + @pagesize - 1

                    SELECT * FROM ( SELECT ROW_NUMBER() OVER(ORDER BY [pid]) AS ROWID,
                    [dnt_posts1].[attachment],
                    [dnt_posts1].[bbcodeoff],
                    [dnt_posts1].[fid],
                    [dnt_posts1].[htmlon],
                    [dnt_posts1].[invisible],
                    [dnt_posts1].[ip],
                    [dnt_posts1].[lastedit],
                    [dnt_posts1].[layer],
                    [dnt_posts1].[message],
                    [dnt_posts1].[parentid],
                    [dnt_posts1].[parseurloff],
                    [dnt_posts1].[pid],
                    [dnt_posts1].[postdatetime],
                    [dnt_posts1].[poster],
                    [dnt_posts1].[posterid],
                    [dnt_posts1].[rate],
                    [dnt_posts1].[ratetimes],
                    [dnt_posts1].[smileyoff],
                    [dnt_posts1].[tid],
                    [dnt_posts1].[title],
                    [dnt_posts1].[usesig],
                    [dnt_users].[accessmasks], 
                    [dnt_users].[adminid],
                    [dnt_users].[avatarshowid],
                    [dnt_users].[bday],
                    [dnt_users].[credits],
                    [dnt_users].[digestposts],
                    [dnt_users].[email],
                    [dnt_users].[extcredits1],
                    [dnt_users].[extcredits2],
                    [dnt_users].[extcredits3],
                    [dnt_users].[extcredits4],
                    [dnt_users].[extcredits5],
                    [dnt_users].[extcredits6],
                    [dnt_users].[extcredits7],
                    [dnt_users].[extcredits8],
                    [dnt_users].[extgroupids],
                    [dnt_users].[gender],
                    [dnt_users].[groupexpiry],
                    [dnt_users].[groupid],
                    [dnt_users].[joindate],
                    [dnt_users].[lastactivity],
                    [dnt_users].[lastip],
                    [dnt_users].[lastpost],
                    [dnt_users].[lastpostid],
                    [dnt_users].[lastposttitle],
                    [dnt_users].[lastvisit],
                    [dnt_users].[newpm],
                    [dnt_users].[newpmcount],
                    [dnt_users].[newsletter],
                    [dnt_users].[nickname],
                    [dnt_users].[oltime],
                    [dnt_users].[onlinestate],
                    [dnt_users].[pageviews],
                    [dnt_users].[password],
                    [dnt_users].[pmsound],
                    [dnt_users].[posts],
                    [dnt_users].[ppp],
                    [dnt_users].[regip],
                    [dnt_users].[secques],
                    [dnt_users].[showemail],
                    [dnt_users].[sigstatus],
                    [dnt_users].[spaceid],
                    [dnt_users].[templateid],
                    [dnt_users].[tpp],
                    [dnt_users].[uid],
                    [dnt_users].[username],
                    [dnt_userfields].[authflag],
                    [dnt_userfields].[authstr],
                    [dnt_userfields].[authtime],
                    [dnt_userfields].[avatar],
                    [dnt_userfields].[avatarheight],
                    [dnt_userfields].[avatarwidth],
                    [dnt_userfields].[bio],
                    [dnt_userfields].[customstatus],
                    [dnt_userfields].[icq],
                    [dnt_userfields].[idcard],
                    [dnt_userfields].[ignorepm],
                    [dnt_userfields].[location],
                    [dnt_userfields].[medals],
                    [dnt_userfields].[mobile],
                    [dnt_userfields].[msn],
                    [dnt_userfields].[phone],
                    [dnt_userfields].[qq],
                    [dnt_userfields].[realname],
                    [dnt_userfields].[sightml],
                    [dnt_userfields].[signature],
                    [dnt_userfields].[skype],
                    [dnt_userfields].[website],
                    [dnt_userfields].[yahoo]
                    FROM [dnt_posts1] 
                    LEFT JOIN [dnt_users] ON [dnt_users].[uid] = [dnt_posts1].[posterid] 
                    LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_posts1].[posterid]
                    WHERE [dnt_posts1].invisible=0 
                    AND [dnt_posts1].pid IN (SELECT pid FROM dnt_postdebatefields WHERE opinion=@opinion AND tid=@tid)) AS DEBATEPOST
                    WHERE ROWID BETWEEN @startRow AND @endRow
GO
/****** Object:  StoredProcedure [dbo].[dnt_getsinglepost1]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getsinglepost1]
                    @tid int,
                    @pid int
                    AS
                    SELECT [aid], [tid], [pid], [postdatetime], [readperm], [filename], [description], [filetype], [filesize], [attachment], [downloads], [attachprice], [width], [height], [uid]  FROM [dnt_attachments] WHERE [tid]=@tid

                    SELECT TOP 1 
	                                [dnt_posts1].[pid], 
	                                [dnt_posts1].[fid], 
	                                [dnt_posts1].[title], 
	                                [dnt_posts1].[layer],
	                                [dnt_posts1].[message], 
	                                [dnt_posts1].[ip], 
	                                [dnt_posts1].[lastedit], 
	                                [dnt_posts1].[postdatetime], 
	                                [dnt_posts1].[attachment], 
	                                [dnt_posts1].[poster], 
	                                [dnt_posts1].[invisible], 
	                                [dnt_posts1].[usesig], 
	                                [dnt_posts1].[htmlon], 
	                                [dnt_posts1].[smileyoff], 
	                                [dnt_posts1].[parseurloff], 
	                                [dnt_posts1].[bbcodeoff], 
	                                [dnt_posts1].[rate], 
	                                [dnt_posts1].[ratetimes], 
	                                [dnt_posts1].[posterid], 
	                                [dnt_users].[nickname],  
	                                [dnt_users].[username], 
	                                [dnt_users].[groupid],
                                    [dnt_users].[spaceid],
                                    [dnt_users].[gender],
									[dnt_users].[bday], 
	                                [dnt_users].[email], 
	                                [dnt_users].[showemail], 
	                                [dnt_users].[digestposts], 
	                                [dnt_users].[credits], 
	                                [dnt_users].[extcredits1], 
	                                [dnt_users].[extcredits2], 
	                                [dnt_users].[extcredits3], 
	                                [dnt_users].[extcredits4], 
	                                [dnt_users].[extcredits5], 
	                                [dnt_users].[extcredits6], 
	                                [dnt_users].[extcredits7], 
	                                [dnt_users].[extcredits8], 
	                                [dnt_users].[posts], 
	                                [dnt_users].[joindate], 
	                                [dnt_users].[onlinestate], 
	                                [dnt_users].[lastactivity],
					[dnt_users].[oltime],
					[dnt_users].[lastvisit],
	                                [dnt_users].[invisible], 
	                                [dnt_userfields].[avatar], 
	                                [dnt_userfields].[avatarwidth], 
	                                [dnt_userfields].[avatarheight], 
	                                [dnt_userfields].[medals], 
	                                [dnt_userfields].[sightml] AS signature, 
	                                [dnt_userfields].[location], 
	                                [dnt_userfields].[customstatus], 
	                                [dnt_userfields].[website], 
	                                [dnt_userfields].[icq], 
	                                [dnt_userfields].[qq], 
	                                [dnt_userfields].[msn], 
	                                [dnt_userfields].[yahoo], 
	                                [dnt_userfields].[skype] 
                    FROM [dnt_posts1] LEFT JOIN [dnt_users] ON [dnt_users].[uid]=[dnt_posts1].[posterid] LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid]=[dnt_users].[uid] WHERE [dnt_posts1].[pid]=@pid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getshortuserinfo]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getshortuserinfo]
@uid int
AS
SELECT TOP 1 * FROM [dnt_users] WHERE [uid]=@uid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getreplypid1]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getreplypid1]
                    @uid int,
                    @tid int

                    AS
                    SELECT TOP 1 [pid] FROM [dnt_posts1] WHERE [tid] =@tid AND [posterid]=@uid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getrelatedtopics]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getrelatedtopics]
@count int,
@tid int
AS

SELECT TOP(@count) 
[dnt_topictagcaches].[linktid],
[dnt_topictagcaches].[linktitle],
[dnt_topictagcaches].[tid]
FROM [dnt_topictagcaches] WHERE [tid]=@tid ORDER BY [linktid] DESC
GO
/****** Object:  StoredProcedure [dbo].[dnt_getpostlistbycondition1]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getpostlistbycondition1]
					@tid int,
					@pagesize int,
					@pageindex int,
					@posterid int
					AS
					DECLARE @startRow int,
							@endRow int

					SET @startRow = (@pageindex-1)*@pagesize
					SET @endRow = @startRow + @pagesize - 1

					SELECT 
					POSTS.[pid], 
					POSTS.[fid], 
					POSTS.[title], 
					POSTS.[layer],
					POSTS.[message], 
					POSTS.[ip], 
					POSTS.[lastedit], 
					POSTS.[postdatetime], 
					POSTS.[attachment], 
					POSTS.[poster], 
					POSTS.[posterid], 
					POSTS.[invisible], 
					POSTS.[usesig], 
					POSTS.[htmlon], 
					POSTS.[smileyoff], 
					POSTS.[parseurloff], 
					POSTS.[bbcodeoff], 
					POSTS.[rate], 
					POSTS.[ratetimes], 
					POSTS.[nickname],  
					POSTS.[username], 
					POSTS.[groupid], 
					POSTS.[spaceid],
					POSTS.[gender],
					POSTS.[bday],
					POSTS.[email], 
					POSTS.[showemail], 
					POSTS.[digestposts], 
					POSTS.[credits], 
					POSTS.[extcredits1], 
					POSTS.[extcredits2], 
					POSTS.[extcredits3], 
					POSTS.[extcredits4], 
					POSTS.[extcredits5], 
					POSTS.[extcredits6], 
					POSTS.[extcredits7], 
					POSTS.[extcredits8], 
					POSTS.[posts], 
					POSTS.[joindate], 
					POSTS.[onlinestate],
					POSTS.[lastactivity],  
					POSTS.[invisible] AS usersinvisible, 
					POSTS.[avatar], 
					POSTS.[avatarwidth],
					POSTS.[avatarheight],
					POSTS.[medals],
					POSTS.[signature], 
					POSTS.[location], 
					POSTS.[customstatus], 
					POSTS.[website], 
					POSTS.[icq], 
					POSTS.[qq], 
					POSTS.[msn], 
					POSTS.[yahoo],
					POSTS.[oltime],
					POSTS.[lastvisit],
					POSTS.[skype] 
					FROM(SELECT ROW_NUMBER() OVER(ORDER BY [pid]) AS ROWID,
					[dnt_posts1].[pid], 
					[dnt_posts1].[fid], 
					[dnt_posts1].[title], 
					[dnt_posts1].[layer],
					[dnt_posts1].[message], 
					[dnt_posts1].[ip], 
					[dnt_posts1].[lastedit], 
					[dnt_posts1].[postdatetime], 
					[dnt_posts1].[attachment], 
					[dnt_posts1].[poster], 
					[dnt_posts1].[posterid], 
					[dnt_posts1].[invisible], 
					[dnt_posts1].[usesig], 
					[dnt_posts1].[htmlon], 
					[dnt_posts1].[smileyoff], 
					[dnt_posts1].[parseurloff], 
					[dnt_posts1].[bbcodeoff], 
					[dnt_posts1].[rate], 
					[dnt_posts1].[ratetimes], 
					[dnt_users].[nickname],  
					[dnt_users].[username], 
					[dnt_users].[groupid], 
					[dnt_users].[spaceid],
					[dnt_users].[gender],
					[dnt_users].[bday],
					[dnt_users].[email], 
					[dnt_users].[showemail], 
					[dnt_users].[digestposts], 
					[dnt_users].[credits], 
					[dnt_users].[extcredits1], 
					[dnt_users].[extcredits2], 
					[dnt_users].[extcredits3], 
					[dnt_users].[extcredits4], 
					[dnt_users].[extcredits5], 
					[dnt_users].[extcredits6], 
					[dnt_users].[extcredits7], 
					[dnt_users].[extcredits8], 
					[dnt_users].[posts], 
					[dnt_users].[joindate], 
					[dnt_users].[onlinestate],
					[dnt_users].[lastactivity],
					[dnt_users].[oltime],
					[dnt_users].[lastvisit],
					[dnt_users].[invisible] AS usersinvisible, 
					[dnt_userfields].[avatar], 
					[dnt_userfields].[avatarwidth],
					[dnt_userfields].[avatarheight],
					[dnt_userfields].[medals],
					[dnt_userfields].[sightml] AS signature, 
					[dnt_userfields].[location], 
					[dnt_userfields].[customstatus], 
					[dnt_userfields].[website], 
					[dnt_userfields].[icq], 
					[dnt_userfields].[qq], 
					[dnt_userfields].[msn], 
					[dnt_userfields].[yahoo], 
					[dnt_userfields].[skype]
					FROM [dnt_posts1] 
					LEFT JOIN [dnt_users] ON [dnt_users].[uid]=[dnt_posts1].[posterid] 
					LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid]=[dnt_users].[uid]
					WHERE [dnt_posts1].[tid]=@tid AND [dnt_posts1].[invisible]=0 AND [posterid]=@posterid) AS POSTS
					WHERE ROWID BETWEEN @startROW AND @endROW
GO
/****** Object:  StoredProcedure [dbo].[dnt_getpostlist1]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getpostlist1]
@tid int,
@pagesize int,
@pageindex int
AS
DECLARE @startRow int,
		@endRow int
SET @startRow = (@pageIndex - 1) * @pageSize +1
SET @endRow = @startRow + @pageSize -1 

SELECT 
[POSTS].[pid],
[POSTS].[fid], 
[POSTS].[title], 
[POSTS].[layer],
[POSTS].[message], 
[POSTS].[ip], 
[POSTS].[lastedit], 
[POSTS].[postdatetime], 
[POSTS].[attachment], 
[POSTS].[poster], 
[POSTS].[posterid], 
[POSTS].[invisible], 
[POSTS].[usesig], 
[POSTS].[htmlon], 
[POSTS].[smileyoff], 
[POSTS].[parseurloff], 
[POSTS].[bbcodeoff], 
[POSTS].[rate], 
[POSTS].[ratetimes],	 
[POSTS].[nickname],  
[POSTS].[username], 
[POSTS].[groupid], 
[POSTS].[spaceid],
[POSTS].[gender],
[POSTS].[bday],
[POSTS].[email], 
[POSTS].[showemail], 
[POSTS].[digestposts], 
[POSTS].[credits], 
[POSTS].[extcredits1], 
[POSTS].[extcredits2], 
[POSTS].[extcredits3], 
[POSTS].[extcredits4], 
[POSTS].[extcredits5], 
[POSTS].[extcredits6], 
[POSTS].[extcredits7], 
[POSTS].[extcredits8], 
[POSTS].[posts], 
[POSTS].[joindate], 
[POSTS].[onlinestate],
[POSTS].[lastactivity],  
[POSTS].[userinvisible], 
[POSTS].[avatar], 
[POSTS].[avatarwidth], 
[POSTS].[avatarheight], 
[POSTS].[medals],
[POSTS].[signature], 
[POSTS].[location], 
[POSTS].[customstatus], 
[POSTS].[website], 
[POSTS].[icq], 
[POSTS].[qq], 
[POSTS].[msn], 
[POSTS].[yahoo],
[POSTS].[oltime],
[POSTS].[lastvisit],
[POSTS].[skype] 
FROM (SELECT ROW_NUMBER() OVER(ORDER BY pid)AS ROWID,
[dnt_posts1].[pid],
[dnt_posts1].[fid], 
[dnt_posts1].[title], 
[dnt_posts1].[layer],
[dnt_posts1].[message], 
[dnt_posts1].[ip], 
[dnt_posts1].[lastedit], 
[dnt_posts1].[postdatetime], 
[dnt_posts1].[attachment], 
[dnt_posts1].[poster], 
[dnt_posts1].[posterid], 
[dnt_posts1].[invisible], 
[dnt_posts1].[usesig], 
[dnt_posts1].[htmlon], 
[dnt_posts1].[smileyoff], 
[dnt_posts1].[parseurloff], 
[dnt_posts1].[bbcodeoff], 
[dnt_posts1].[rate], 
[dnt_posts1].[ratetimes],	 
[dnt_users].[nickname],  
[dnt_users].[username], 
[dnt_users].[groupid], 
[dnt_users].[spaceid],
[dnt_users].[gender],
[dnt_users].[bday],
[dnt_users].[email], 
[dnt_users].[showemail], 
[dnt_users].[digestposts], 
[dnt_users].[credits], 
[dnt_users].[extcredits1], 
[dnt_users].[extcredits2], 
[dnt_users].[extcredits3], 
[dnt_users].[extcredits4], 
[dnt_users].[extcredits5], 
[dnt_users].[extcredits6], 
[dnt_users].[extcredits7], 
[dnt_users].[extcredits8], 
[dnt_users].[posts], 
[dnt_users].[joindate], 
[dnt_users].[onlinestate],
[dnt_users].[lastactivity],
[dnt_users].[oltime],
[dnt_users].[lastvisit],
[dnt_users].[invisible] AS [userinvisible], 
[dnt_userfields].[avatar], 
[dnt_userfields].[avatarwidth], 
[dnt_userfields].[avatarheight], 
[dnt_userfields].[medals],
[dnt_userfields].[sightml] AS [signature], 
[dnt_userfields].[location], 
[dnt_userfields].[customstatus], 
[dnt_userfields].[website], 
[dnt_userfields].[icq], 
[dnt_userfields].[qq], 
[dnt_userfields].[msn], 
[dnt_userfields].[yahoo], 
[dnt_userfields].[skype]
FROM [dnt_posts1] LEFT JOIN [dnt_users] ON [dnt_users].[uid]=[dnt_posts1].[posterid] LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid]=[dnt_users].[uid] 
WHERE [tid] = @tid AND [dnt_posts1].[invisible] <=0) AS POSTS 
WHERE ROWID BETWEEN @startRow AND @endRow
GO
/****** Object:  StoredProcedure [dbo].[dnt_getlastexecutescheduledeventdatetime]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getlastexecutescheduledeventdatetime]
(
	@key VARCHAR(100),
	@servername VARCHAR(100),
	@lastexecuted DATETIME OUTPUT
)
AS
SELECT @lastexecuted = MAX([lastexecuted]) FROM [dnt_scheduledevents] WHERE [key] = @key AND [servername] = @servername

IF(@lastexecuted IS NULL)
BEGIN
	SET @lastexecuted = DATEADD(YEAR,-1,GETDATE())
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_getinvitecodelistbyuid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getinvitecodelistbyuid]
@creatorid int,
@pageindex int
AS
DECLARE @startRow int,
		@endRow int
SET @startRow = (@pageIndex - 1) * 10 +1
SET @endRow = @startRow + 10 -1

SELECT 
[INVITATION].[inviteid],
[INVITATION].[invitecode],
[INVITATION].[invitetype],
[INVITATION].[createdtime],
[INVITATION].[creator],
[INVITATION].[creatorid],
[INVITATION].[expiretime],
[INVITATION].[maxcount],
[INVITATION].[successcount]
FROM (SELECT ROW_NUMBER() OVER(ORDER BY [inviteid] DESC)AS ROWID,
[inviteid],
[invitecode],
[invitetype],
[createdtime],
[creator],
[creatorid],
[expiretime],
[maxcount],
[successcount]
FROM [dnt_invitation]
WHERE [creatorid]=@creatorid and [invitetype]=3 AND [isdeleted]=0) AS INVITATION
WHERE ROWID BETWEEN @startRow AND @endRow
GO
/****** Object:  StoredProcedure [dbo].[dnt_getinvitecode]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getinvitecode]
@searchtype nchar(10),
@searchkey nchar(20)
AS
BEGIN
IF @searchtype='uid'
   SELECT TOP 1 [inviteid],[invitecode],[invitetype],[createdtime],[creator],[creatorid],[expiretime],[maxcount],[successcount] 
FROM [dnt_invitation] WHERE [creatorid]=@searchkey AND [invitetype]=2 AND [isdeleted]=0 ORDER BY [inviteid] DESC
ELSE IF @searchtype='id'
   SELECT [inviteid],[invitecode],[invitetype],[createdtime],[creator],[creatorid],[expiretime],[maxcount],[successcount] FROM 

[dnt_invitation] WHERE [inviteid]=@searchkey AND [isdeleted]=0
ELSE IF @searchtype='code'
   SELECT [inviteid],[invitecode],[invitetype],[createdtime],[creator],[creatorid],[expiretime],[maxcount],[successcount] FROM 

[dnt_invitation] WHERE [invitecode]=@searchkey AND [isdeleted]=0
ELSE
   SELECT (1)
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_getindexforumlist]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getindexforumlist]
AS
SELECT CASE WHEN DATEDIFF(n, [lastpost], GETDATE())<600 THEN 'new' ELSE 'old' END AS [havenew],
[dnt_forums].[allowbbcode],
[dnt_forums].[allowblog],
[dnt_forums].[alloweditrules],
[dnt_forums].[allowhtml],
[dnt_forums].[allowimgcode],
[dnt_forums].[allowpostspecial],
[dnt_forums].[allowrss],
[dnt_forums].[allowsmilies],
[dnt_forums].[allowspecialonly],
[dnt_forums].[allowtag],
[dnt_forums].[allowthumbnail],	
[dnt_forums].[autoclose],	
[dnt_forums].[colcount],
[dnt_forums].[curtopics],
[dnt_forums].[disablewatermark],
[dnt_forums].[displayorder],
[dnt_forums].[fid],
[dnt_forums].[inheritedmod],
[dnt_forums].[istrade],
[dnt_forums].[jammer],
[dnt_forums].[lastpost],
[dnt_forums].[lastposter],
[dnt_forums].[lastposterid],
[dnt_forums].[lasttid],
[dnt_forums].[lasttitle],
[dnt_forums].[layer],
[dnt_forums].[modnewposts],
[dnt_forums].[name],
[dnt_forums].[parentid],
[dnt_forums].[parentidlist],
[dnt_forums].[pathlist],
[dnt_forums].[posts],
[dnt_forums].[recyclebin],
[dnt_forums].[status],
[dnt_forums].[subforumcount],
[dnt_forums].[templateid],
[dnt_forums].[todayposts],
[dnt_forums].[topics],
[dnt_forumfields].[applytopictype],
[dnt_forumfields].[attachextensions],
[dnt_forumfields].[description],
[dnt_forumfields].[fid],
[dnt_forumfields].[getattachperm],
[dnt_forumfields].[icon],
[dnt_forumfields].[moderators],
[dnt_forumfields].[password],
[dnt_forumfields].[permuserlist],
[dnt_forumfields].[postattachperm],
[dnt_forumfields].[postbytopictype],
[dnt_forumfields].[postcredits],
[dnt_forumfields].[postperm],
[dnt_forumfields].[redirect],
[dnt_forumfields].[replycredits],
[dnt_forumfields].[replyperm],
[dnt_forumfields].[rewritename],
[dnt_forumfields].[rules],
[dnt_forumfields].[seodescription],
[dnt_forumfields].[seokeywords],
[dnt_forumfields].[topictypeprefix],
[dnt_forumfields].[topictypes],
[dnt_forumfields].[viewbytopictype],
[dnt_forumfields].[viewperm]
FROM [dnt_forums] 
LEFT JOIN [dnt_forumfields] ON [dnt_forums].[fid]=[dnt_forumfields].[fid] 
WHERE [dnt_forums].[status] > 0 AND [layer] <= 1 
AND [dnt_forums].[parentid] NOT IN (SELECT [fid] FROM [dnt_forums] WHERE [status] < 1 AND [layer] = 0) ORDER BY [displayorder]
GO
/****** Object:  StoredProcedure [dbo].[dnt_deluserallinf]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_deluserallinf]
@uid INT,
@delPosts BIT,
@delPms BIT
AS
DECLARE @existuid INT
SELECT @existuid = COUNT([uid]) FROM [dnt_users] WHERE [uid]=@uid
IF @existuid <>0
BEGIN
	DELETE FROM [dnt_users] WHERE [uid]=@uid                 
	DELETE FROM [dnt_userfields] WHERE [uid]=@uid                 
	DELETE FROM [dnt_onlinetime] WHERE [uid]=@uid                
	DELETE FROM [dnt_polls] WHERE [uid]=@uid                 
	DELETE FROM [dnt_favorites] WHERE [uid]=@uid
	DECLARE @tableid INT,
			@tablename NVARCHAR(20)
	IF @delPosts = 1
		BEGIN
			DELETE FROM [dnt_topics] WHERE [posterid]=@uid
			DECLARE tables_cursor CURSOR FOR SELECT [id] FROM [dnt_tablelist]
			OPEN tables_cursor
			FETCH NEXT FROM tables_cursor INTO @tableid
			WHILE @@FETCH_STATUS = 0
			BEGIN
				SET @tablename = 'dnt_posts' + LTRIM(STR(@tableid))
				EXEC ('DELETE FROM ' + @tablename + ' WHERE [posterid]='+@uid)
				FETCH NEXT FROM tables_cursor INTO @tableid
			END
			CLOSE tables_cursor
			DEALLOCATE tables_cursor
			SET @tableid = 0
			SET @tablename = ''
		END
	ELSE
		BEGIN
			UPDATE [dnt_topics] SET [poster]='ûѱɾ' Where [posterid]=@uid
			UPDATE [dnt_topics] SET [lastposter]='ûѱɾ' Where [lastpostid]=@uid
			DECLARE tables_cursor CURSOR FOR SELECT [id] FROM [dnt_tablelist]
			OPEN tables_cursor
			FETCH NEXT FROM tables_cursor INTO @tableid
			WHILE @@FETCH_STATUS = 0
			BEGIN
				SET @tablename = 'dnt_posts' + LTRIM(STR(@tableid))
				EXEC ('UPDATE ['+@tablename+'] SET [poster]=''ûѱɾ'' WHERE [posterid]='+@uid)
				FETCH NEXT FROM tables_cursor INTO @tableid
			END
			CLOSE tables_cursor
			DEALLOCATE tables_cursor
			SET @tableid = 0
			SET @tablename = ''
		END
	IF @delPms = 1
		BEGIN
			DELETE FROM [dnt_pms] WHERE [msgfromid]=@uid
		END
	ELSE
		BEGIN
			UPDATE [dnt_pms] SET [msgfrom]='ûѱɾ' WHERE [msgfromid]=@uid
			UPDATE [dnt_pms] SET [msgto]='ûѱɾ' WHERE [msgtoid]=@uid
		END
	DELETE FROM [dnt_moderators] WHERE [uid]=@uid
	UPDATE [dnt_statistics] SET [totalusers]=[totalusers]-1
	DECLARE @lastuserid INT,@lastusername VARCHAR(50)
	SELECT TOP 1 @lastuserid=[uid],@lastusername=[username] FROM [dnt_users] ORDER BY [uid] DESC
	IF @lastuserid IS NOT NULL
		UPDATE [dnt_Statistics] SET [lastuserid]=@lastuserid, [lastusername]=@lastusername
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_deletetopictags]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_deletetopictags]
	@tid int
 AS
BEGIN       
	UPDATE [dnt_tags] SET [count]=[count]-1,[fcount]=[fcount]-1 
	WHERE EXISTS (SELECT [tagid] FROM [dnt_topictags] WHERE [tid] = @tid AND [tagid] = [dnt_tags].[tagid])

    DELETE FROM [dnt_topictags] WHERE [tid] = @tid	
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_deletetopicbytidlist1]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_deletetopicbytidlist1]
    @tidlist AS VARCHAR(2000),
    @chanageposts AS BIT
AS

    DECLARE @postcount int
    DECLARE @topiccount int
    DECLARE @todaycount int
    DECLARE @sqlstr nvarchar(4000)
    DECLARE @fid varchar(2000)
    DECLARE @posterid varchar(200)
    DECLARE @tempFid int
    DECLARE @tempPosterid int
    DECLARE @tempLayer int
    DECLARE @temppostdatetime datetime

    DECLARE @tempfidlist AS VARCHAR(1000)	

    SET @fid = ''
    SET @posterid = ''
    SET @postcount=0
    SET @topiccount=0
    SET @todaycount=0

    SET @tempfidlist = '';


    IF @tidlist<>''
        BEGIN
            EXEC('DECLARE cu_dnt_posts CURSOR FOR SELECT [fid],[posterid],[layer],[postdatetime] FROM [dnt_posts1] WHERE [dnt_posts1].[tid] IN ('+@tidlist+')')
			
            OPEN cu_dnt_posts
            FETCH NEXT FROM cu_dnt_posts into @tempFid,@tempPosterid,@tempLayer,@temppostdatetime
            WHILE @@FETCH_STATUS = 0
                BEGIN
                    SET @postcount = @postcount + 1
                    IF @tempLayer = 0
	                    BEGIN
		                    SET @topiccount = @topiccount + 1
							
	                    END

                    IF DATEDIFF(d,@temppostdatetime,GETDATE()) = 0
	                    BEGIN
		                    SET @todaycount = @todaycount + 1
	                    END


                    IF CHARINDEX(',' + LTRIM(STR(@tempFid)) + ',',@fid + ',') = 0
	                    BEGIN
		                    --SET @fid = @fid + ',' + LTRIM(STR(@tempFid))	
		                    SELECT @tempfidlist = ISNULL([parentidlist],'') FROM [dnt_forums] WHERE [fid] = @tempFid
		                    IF RTRIM(@tempfidlist)<>''
			                    BEGIN
				                    SET @fid = RTRIM(@fid) + ',' +  RTRIM(@tempfidlist) + ',' + CAST(@tempFid AS VARCHAR(10))
			                    END
		                    ELSE
			                    BEGIN
				                    SET @fid =RTRIM(@fid) + ',' +  CAST(@tempFid AS VARCHAR(10))
			                    END

					
	                    END
                    IF @chanageposts = 1
	                    BEGIN
		                    UPDATE [dnt_users] SET [posts] = [posts] - 1 WHERE [uid] = @tempPosterid
	                    END
				
                    FETCH NEXT FROM cu_dnt_posts into @tempFid,@tempPosterid,@tempLayer,@temppostdatetime
                END

            CLOSE cu_dnt_posts
            DEALLOCATE cu_dnt_posts

	
            IF LEN(@fid)>0
                BEGIN	

			
                    SET @fid = SUBSTRING(@fid,2,LEN(@fid)-1)
		
                    IF @chanageposts = 1
	                    BEGIN
		
		                    UPDATE [dnt_statistics] SET [totaltopic]=[totaltopic] - @topiccount, [totalpost]=[totalpost] - @postcount

		                    EXEC('UPDATE [dnt_forums] 
		                    SET [posts]=[posts] - ' + @postcount + ',  
		                    [topics]=[topics] - ' + @topiccount + ', 
		                    [todayposts] = [todayposts] - ' + @todaycount + ' 
		                    WHERE [fid] IN ('+@fid+')')
	                    END
		
                    EXEC('DELETE FROM [dnt_favorites] WHERE [tid] IN ('+@tidlist+') AND [typeid]=0')
					
                    EXEC('DELETE FROM [dnt_polls] WHERE [tid] IN ('+@tidlist+')')

                    EXEC('DELETE FROM [dnt_posts1] WHERE [tid] IN ('+@tidlist+')')

                    EXEC('DELETE FROM [dnt_mytopics] WHERE [tid] IN ('+@tidlist+')')
                END
            EXEC('DELETE FROM [dnt_topics] WHERE [closed] IN ('+@tidlist+') OR [tid] IN ('+@tidlist+')')
			
            EXEC('UPDATE [dnt_tags] SET [count]=[count]-1, [fcount]=[fcount]-1 WHERE [tagid] IN (SELECT [tagid] FROM [dnt_topictags] WHERE [tid] IN ('+@tidlist+'))') 
			
            EXEC('DELETE FROM [dnt_topictags] WHERE [tid] IN ('+@tidlist+')')
			
            EXEC('DELETE FROM [dnt_topictagcaches] WHERE [tid] IN ('+@tidlist+') OR [linktid] IN ('+@tidlist+')')
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_deletepost1bypid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  PROCEDURE [dbo].[dnt_deletepost1bypid]
                        @pid int,
						@chanageposts AS BIT
                    AS

                        DECLARE @fid int
                        DECLARE @tid int
                        DECLARE @posterid int
                        DECLARE @lastforumposterid int
                        DECLARE @layer int
                        DECLARE @postdatetime smalldatetime
                        DECLARE @poster varchar(50)
                        DECLARE @postcount int
                        DECLARE @title nchar(60)
                        DECLARE @lasttid int
                        DECLARE @postid int
                        DECLARE @todaycount int
                    	
                    	
                        SELECT @fid = [fid],@tid = [tid],@posterid = [posterid],@layer = [layer], @postdatetime = [postdatetime] FROM [dnt_posts1] WHERE pid = @pid

                        DECLARE @fidlist AS VARCHAR(1000)
                    	
                        SET @fidlist = '';
                    	
                        SELECT @fidlist = ISNULL([parentidlist],'') FROM [dnt_forums] WHERE [fid] = @fid
                        IF RTRIM(@fidlist)<>''
                            BEGIN
                                SET @fidlist = RTRIM(@fidlist) + ',' + CAST(@fid AS VARCHAR(10))
                            END
                        ELSE
                            BEGIN
                                SET @fidlist = CAST(@fid AS VARCHAR(10))
                            END


                        IF @layer<>0

                            BEGIN
                    			
								IF @chanageposts = 1
									BEGIN
										UPDATE [dnt_statistics] SET [totalpost]=[totalpost] - 1

										UPDATE [dnt_forums] SET 
											[posts]=[posts] - 1, 
											[todayposts]=CASE 
																WHEN DATEPART(yyyy, @postdatetime)=DATEPART(yyyy,GETDATE()) AND DATEPART(mm, @postdatetime)=DATEPART(mm,GETDATE()) AND DATEPART(dd, @postdatetime)=DATEPART(dd,GETDATE()) THEN [todayposts] - 1
																ELSE [todayposts]
														END						
										WHERE (CHARINDEX(',' + RTRIM([fid]) + ',', ',' +
															(SELECT @fidlist AS [fid]) + ',') > 0)
                    			
										UPDATE [dnt_users] SET [posts] = [posts] - 1 WHERE [uid] = @posterid

										UPDATE [dnt_topics] SET [replies]=[replies] - 1 WHERE [tid]=@tid
									END
                    			
                                DELETE FROM [dnt_posts1] WHERE [pid]=@pid
                    			
                            END
                        ELSE
                            BEGIN
                    		
                                SELECT @postcount = COUNT([pid]) FROM [dnt_posts1] WHERE [tid] = @tid
                                SELECT @todaycount = COUNT([pid]) FROM [dnt_posts1] WHERE [tid] = @tid AND DATEDIFF(d, [postdatetime], GETDATE()) = 0
                    			
								IF @chanageposts = 1
									BEGIN
										UPDATE [dnt_statistics] SET [totaltopic]=[totaltopic] - 1, [totalpost]=[totalpost] - @postcount
		                    			
										UPDATE [dnt_forums] SET [posts]=[posts] - @postcount, [topics]=[topics] - 1,[todayposts]=[todayposts] - @todaycount WHERE (CHARINDEX(',' + RTRIM([fid]) + ',', ',' +(SELECT @fidlist AS [fid]) + ',') > 0)
		                    			
										UPDATE [dnt_users] SET [posts] = [posts] - @postcount WHERE [uid] = @posterid
                    			
									END

                                DELETE FROM [dnt_posts1] WHERE [tid] = @tid
                    			
                                DELETE FROM [dnt_topics] WHERE [tid] = @tid
                    			
                            END	
                    		

                        IF @layer<>0
                            BEGIN
                                SELECT TOP 1 @pid = [pid], @posterid = [posterid], @postdatetime = [postdatetime], @title = [title], @poster = [poster] FROM [dnt_posts1] WHERE [tid]=@tid ORDER BY [pid] DESC
                                UPDATE [dnt_topics] SET [lastposter]=@poster,[lastpost]=@postdatetime,[lastpostid]=@pid,[lastposterid]=@posterid WHERE [tid]=@tid
                            END



                        SELECT @lasttid = [lasttid] FROM [dnt_forums] WHERE [fid] = @fid

                    	
                        IF @lasttid = @tid
                            BEGIN

                    			
                    			

                                SELECT TOP 1 @pid = [pid], @tid = [tid],@lastforumposterid = [posterid], @title = [title], @postdatetime = [postdatetime], @poster = [poster] FROM [dnt_posts1] WHERE [fid] = @fid ORDER BY [pid] DESC
                    			
                            
                            
                                UPDATE [dnt_forums] SET 
                    			
	                                [lastpost]=@postdatetime,
	                                [lastposter]=ISNULL(@poster,''),
	                                [lastposterid]=ISNULL(@lastforumposterid,'0')

                                WHERE (CHARINDEX(',' + RTRIM([fid]) + ',', ',' +
					                                (SELECT @fidlist AS [fid]) + ',') > 0)


                    			
                                SELECT TOP 1 @pid = [pid], @tid = [tid],@posterid = [posterid], @postdatetime = [postdatetime], @title = [title], @poster = [poster] FROM [dnt_posts1] WHERE [posterid]=@posterid ORDER BY [pid] DESC
                    			
                                UPDATE [dnt_users] SET
                    			
	                                [lastpost] = @postdatetime,
	                                [lastpostid] = @pid,
	                                [lastposttitle] = ISNULL(@title,'')
                    				
                                WHERE [uid] = @posterid
                    			
                            END
GO
/****** Object:  StoredProcedure [dbo].[dnt_deleteonlineusers]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_deleteonlineusers] 
@olidlist varchar(5000) = ''
AS

DELETE FROM [dnt_online] WHERE CHARINDEX(','+RTRIM([olid])+',', ','+@olidlist+',') > 0
GO
/****** Object:  StoredProcedure [dbo].[dnt_deletenousedforumattachment]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_deletenousedforumattachment]
AS
DELETE FROM [dnt_attachments] 
WHERE [tid]= 0 AND [pid]=0 AND DATEDIFF(n, postdatetime, GETDATE()) > 30
GO
/****** Object:  StoredProcedure [dbo].[dnt_deleteinvitecode]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_deleteinvitecode]
@id int
AS
BEGIN
UPDATE [dnt_invitation] SET [isdeleted]=1 WHERE [inviteid]=@id
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_deleteforumsbyfid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_deleteforumsbyfid]
@fid INT,
@postname NVARCHAR(50)
AS
DECLARE @parentid INT,
		@displayorder INT		
SELECT TOP 1 @parentid=[parentid],@displayorder=[displayorder] FROM [dnt_forums] WHERE [fid]=@fid
UPDATE [dnt_forums] SET [displayorder]=[displayorder]-1 WHERE [displayorder]>@displayorder
UPDATE [dnt_forums] SET [subforumcount]=[subforumcount]-1 WHERE  [fid]=@parentid
DELETE FROM [dnt_forumfields] WHERE [fid]=@fid
DELETE FROM [dnt_polls] WHERE [tid] IN (SELECT [tid] FROM [dnt_topics] WHERE [fid]=@fid)
EXEC ('DELETE FROM [dnt_attachments] WHERE [tid] IN(SELECT [tid] FROM [dnt_topics] WHERE [fid]=' + @fid + ') OR [pid] IN(SELECT [pid] FROM [' + @postname + '] WHERE [fid]=' + @fid + ')')
EXEC ('DELETE FROM [' + @postname + '] WHERE [fid]=' + @fid)
DELETE FROM [dnt_topics] WHERE [fid]=@fid
DELETE FROM [dnt_forums] WHERE  [fid]=@fid
DELETE FROM [dnt_moderators] WHERE  [fid]=@fid
GO
/****** Object:  StoredProcedure [dbo].[dnt_addusergroup]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_addusergroup]
@Radminid INT,
@Grouptitle NVARCHAR(50),
@Creditshigher INT,
@Creditslower INT,
@Stars INT,
@Color CHAR(7),
@Groupavatar NVARCHAR(60), 
@Readaccess INT,
@Allowvisit INT,
@Allowpost INT,
@Allowreply INT,
@Allowpostpoll INT,
@Allowdirectpost INT,
@Allowgetattach INT,
@Allowpostattach INT,
@Allowvote INT,
@Allowmultigroups INT, 
@Allowsearch INT,
@Allowavatar INT,
@Allowcstatus INT,
@Allowuseblog INT,
@Allowinvisible INT,
@Allowtransfer INT,
@Allowsetreadperm INT, 
@Allowsetattachperm INT,
@Allowhidecode INT,
@Allowhtml INT,
@Allowcusbbcode INT,
@Allownickname INT,
@Allowsigbbcode INT,
@Allowsigimgcode INT,
@Allowviewpro INT,
@Allowviewstats INT,
@Allowtrade INT,
@Allowdiggs INT,
@Allowdebate INT,
@Allowbonus INT,
@Minbonusprice INT,
@Maxbonusprice INT,
@Disableperiodctrl INT, 
@Reasonpm INT,
@Maxprice SMALLINT,
@Maxpmnum SMALLINT,
@Maxsigsize SMALLINT,
@Maxattachsize INT,
@Maxsizeperday INT,
@Attachextensions CHAR(100),
@Maxspaceattachsize INT,
@Maxspacephotosize INT, 
@Raterange CHAR(100)
AS
INSERT INTO [dnt_usergroups]  ([radminid],[grouptitle],[creditshigher],[creditslower],
[stars] ,[color], [groupavatar],[readaccess], [allowvisit],[allowpost],[allowreply],
[allowpostpoll], [allowdirectpost],[allowgetattach],[allowpostattach],[allowvote],[allowmultigroups],
[allowsearch],[allowavatar],[allowcstatus],[allowuseblog],[allowinvisible],[allowtransfer],
[allowsetreadperm],[allowsetattachperm],[allowhidecode],[allowhtml],[allowcusbbcode],[allownickname],
[allowsigbbcode],[allowsigimgcode],[allowviewpro],[allowviewstats],[allowtrade],[allowdiggs],[disableperiodctrl],[reasonpm],
[maxprice],[maxpmnum],[maxsigsize],[maxattachsize],[maxsizeperday],[attachextensions],[raterange],[maxspaceattachsize],
[maxspacephotosize],[allowdebate],[allowbonus],[minbonusprice],[maxbonusprice]) 
VALUES(
@Radminid,@Grouptitle,@Creditshigher,@Creditslower,@Stars,@Color,@Groupavatar,@Readaccess,@Allowvisit,@Allowpost,@Allowreply,
@Allowpostpoll,@Allowdirectpost,@Allowgetattach,@Allowpostattach,@Allowvote,@Allowmultigroups,@Allowsearch,@Allowavatar,@Allowcstatus,
@Allowuseblog,@Allowinvisible,@Allowtransfer,@Allowsetreadperm,@Allowsetattachperm,@Allowhidecode,@Allowhtml,@Allowcusbbcode,@Allownickname,
@Allowsigbbcode,@Allowsigimgcode,@Allowviewpro,@Allowviewstats,@Allowtrade,@Allowdiggs,@Disableperiodctrl,@Reasonpm,@Maxprice,@Maxpmnum,@Maxsigsize,@Maxattachsize, 
@Maxsizeperday,@Attachextensions,@Raterange,@Maxspaceattachsize,@Maxspacephotosize,@Allowdebate,@Allowbonus,@Minbonusprice,@Maxbonusprice)
GO
/****** Object:  StoredProcedure [dbo].[dnt_addparentforumtopics]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_addparentforumtopics]
@topics int,
@fpidlist nvarchar(100)
AS
   UPDATE [dnt_forums] SET [topics] = [topics] + @topics WHERE [fid] IN (SELECT [item]FROM [dnt_split](@fpidlist, ',') )
GO
/****** Object:  StoredProcedure [dbo].[dnt_getpostcountbycondition1]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getpostcountbycondition1]
					@tid int,
					@posterid int
					AS
					SELECT COUNT(pid) FROM [dnt_posts1] WHERE [tid] = @tid AND [posterid] = @posterid  AND [layer]>=0
GO
/****** Object:  StoredProcedure [dbo].[dnt_getpostcount]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getpostcount]
                    @tid int
                    AS
                    SELECT COUNT(pid) FROM [dnt_posts1] WHERE [tid]=@tid AND [invisible]=0 AND layer>0
GO
/****** Object:  StoredProcedure [dbo].[dnt_getpost1tree]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getpost1tree]
                    @tid int
                    AS
                    SELECT [pid], [layer], [title], [poster], [posterid],[postdatetime],[message] FROM [dnt_posts1] WHERE [tid]=@tid AND [invisible]=0 ORDER BY [parentid];
GO
/****** Object:  StoredProcedure [dbo].[dnt_getpost1count]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getpost1count]
@tid int
AS
SELECT COUNT(pid) FROM [dnt_posts1] WHERE [tid] = @tid AND [invisible]=0 AND layer>0
GO
/****** Object:  StoredProcedure [dbo].[dnt_getpolllist]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getpolllist]
@tid int
AS
SELECT 
[pollid],
[tid],
[displayorder],
[multiple],
[visible],
[maxchoices],
[expiration],
[uid],
[voternames] 
FROM [dnt_polls] 
WHERE [tid]=@tid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getpmlist]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getpmlist]
@userid int,
@folder int,
@pagesize int,
@pageindex int,
@inttype int
AS
DECLARE @startRow int,
		@endRow int
SET @startRow = (@pageindex - 1) * @pagesize + 1
SET @endRow = @startRow + @pagesize - 1

IF (@folder <> 0)
BEGIN
	IF (@inttype <> 1)
	BEGIN
		SELECT 
		[PMS].[pmid],
		[PMS].[msgfrom],
		[PMS].[msgfromid],
		[PMS].[msgto],
		[PMS].[msgtoid],
		[PMS].[folder],
		[PMS].[new],
		[PMS].[subject],
		[PMS].[postdatetime],
		[PMS].[message]		
		FROM(SELECT ROW_NUMBER() OVER(ORDER BY [pmid] DESC) AS ROWID,
		[pmid],
		[msgfrom],
		[msgfromid],
		[msgto],
		[msgtoid],
		[folder],
		[new],
		[subject],
		[postdatetime],
		[message]
		FROM [dnt_pms]
		WHERE [msgfromid] = @userid AND [folder] = @folder) AS PMS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	
	ELSE
	BEGIN
		SELECT 
		[PMS].[pmid],
		[PMS].[msgfrom],
		[PMS].[msgfromid],
		[PMS].[msgto],
		[PMS].[msgtoid],
		[PMS].[folder],
		[PMS].[new],
		[PMS].[subject],
		[PMS].[postdatetime],
		[PMS].[message]		
		FROM(SELECT ROW_NUMBER() OVER(ORDER BY [pmid] DESC) AS ROWID,
		[pmid],
		[msgfrom],
		[msgfromid],
		[msgto],
		[msgtoid],
		[folder],
		[new],
		[subject],
		[postdatetime],
		[message]
		FROM [dnt_pms]
		WHERE [msgfromid] = @userid AND [folder] = @folder AND [new] = 1) AS PMS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
END

ELSE
BEGIN
	IF (@inttype <> 1)
	BEGIN
		SELECT 
		[PMS].[pmid],
		[PMS].[msgfrom],
		[PMS].[msgfromid],
		[PMS].[msgto],
		[PMS].[msgtoid],
		[PMS].[folder],
		[PMS].[new],
		[PMS].[subject],
		[PMS].[postdatetime],
		[PMS].[message] 
		FROM(SELECT ROW_NUMBER() OVER(ORDER BY [pmid] DESC) AS ROWID,
		[pmid],
		[msgfrom],
		[msgfromid],
		[msgto],
		[msgtoid],
		[folder],
		[new],
		[subject],
		[postdatetime],
		[message]
		FROM [dnt_pms]
		WHERE [msgtoid] = @userid AND [folder] = @folder) AS PMS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
	
	ELSE
	BEGIN
		SELECT 
		[PMS].[pmid],
		[PMS].[msgfrom],
		[PMS].[msgfromid],
		[PMS].[msgto],
		[PMS].[msgtoid],
		[PMS].[folder],
		[PMS].[new],
		[PMS].[subject],
		[PMS].[postdatetime],
		[PMS].[message] 
		FROM(SELECT ROW_NUMBER() OVER(ORDER BY [pmid] DESC) AS ROWID,
		[pmid],
		[msgfrom],
		[msgfromid],
		[msgto],
		[msgtoid],
		[folder],
		[new],
		[subject],
		[postdatetime],
		[message]
		FROM [dnt_pms]
		WHERE [msgtoid] = @userid AND [folder] = @folder AND [new] = 1) AS PMS
		WHERE ROWID BETWEEN @startRow AND @endRow
	END
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_getpmcount]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getpmcount]
@userid int,
@folder int=0,
@state int=-1
AS

IF @folder=-1
	BEGIN
	  SELECT COUNT(pmid) AS [pmcount] FROM [dnt_pms] WHERE ([msgtoid] = @userid AND [folder]=0) OR ([msgfromid] = @userid AND [folder] = 1) OR ([msgfromid] = @userid AND [folder] = 2)
	END
ELSE
    BEGIN
		IF @folder=0
			BEGIN
				IF @state=-1
					BEGIN
						SELECT COUNT(pmid) AS [pmcount] FROM [dnt_pms] WHERE [msgtoid] = @userid AND [folder] = @folder
					END
				ELSE IF @state=2
					BEGIN
						SELECT COUNT(pmid) AS [pmcount] FROM [dnt_pms] WHERE [msgtoid] = @userid AND [folder] = @folder AND [new]=1 AND GETDATE()-[postdatetime]<3
					END
				ELSE
					BEGIN
						SELECT COUNT(pmid) AS [pmcount] FROM [dnt_pms] WHERE [msgtoid] = @userid AND [folder] = @folder AND [new] = @state
					END
			END
		ELSE
			BEGIN
				IF @state=-1
					BEGIN
						SELECT COUNT(pmid) AS [pmcount] FROM [dnt_pms] WHERE [msgfromid] = @userid AND [folder] = @folder
					END
				ELSE IF @state=2
					BEGIN
						SELECT COUNT(pmid) AS [pmcount] FROM [dnt_pms] WHERE [msgfromid] = @userid AND [folder] = @folder AND [new]=1 AND GETDATE()-[postdatetime]<3
					END
				ELSE
					BEGIN
						SELECT COUNT(pmid) AS [pmcount] FROM [dnt_pms] WHERE [msgfromid] = @userid AND [folder] = @folder AND [new] = @state
					END
			END
	END
GO
/****** Object:  StoredProcedure [dbo].[dnt_getparentidbyfid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_getparentidbyfid]
@fid INT
AS
SELECT [parentid] From [dnt_forums] WHERE [inheritedmod]=1 AND [fid]=@fid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getforumstable]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_getforumstable]
AS
SELECT
[f].[fid],[f].[parentid],[f].[layer],[f].[pathlist],[f].[parentidlist],[f].[subforumcount],[f].[name],[f].[status],[f].[colcount],[f].[displayorder],[f].[templateid],[f].[topics],[f].[curtopics],[f].[posts],[f].[todayposts],[f].[lasttid],[f].[lasttitle],[f].[lastpost],[f].[lastposterid],[f].[lastposter],[f].[allowsmilies],[f].[allowrss],[f].[allowhtml],[f].[allowbbcode],[f].[allowimgcode],[f].[allowblog],[f].[istrade],[f].[allowpostspecial],[f].[allowspecialonly],[f].[alloweditrules],[f].[allowthumbnail],[f].[allowtag],[f].[recyclebin],[f].[modnewposts],[f].[jammer],[f].[disablewatermark],[f].[inheritedmod],[f].[autoclose],[ff].[password],[ff].[icon],[ff].[postcredits],[ff].[replycredits],[ff].[redirect],[ff].[attachextensions],[ff].[rules],[ff].[topictypes],[ff].[viewperm],[ff].[postperm],[ff].[replyperm],[ff].[getattachperm],[ff].[postattachperm],[ff].[moderators],[ff].[description],[ff].[applytopictype],[ff].[postbytopictype],[ff].[viewbytopictype],[ff].[topictypeprefix],[ff].[permuserlist],[ff].[seokeywords],[ff].[seodescription],[ff].[rewritename] 
FROM [dnt_forums] AS [f] 
LEFT JOIN [dnt_forumfields] AS [ff] 
ON [f].[fid]=[ff].[fid] 
ORDER BY [f].[displayorder]
GO
/****** Object:  StoredProcedure [dbo].[dnt_getforumnewtopics]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getforumnewtopics]
@fid int
AS
DECLARE @strSQL VARCHAR(5000)
DECLARE @strMaxPostTableId VARCHAR(3)
SELECT @strMaxPostTableId=max([id]) FROM [dnt_tablelist]
					
SET @strSQL = 'SELECT TOP 20 [dnt_topics].[tid],[dnt_topics].[title],[dnt_topics].[poster],[dnt_topics].[postdatetime],[dnt_posts'+@strMaxPostTableId+'].[message] FROM [dnt_topics] LEFT JOIN [dnt_posts'+@strMaxPostTableId+'] ON [dnt_topics].[tid]=[dnt_posts'+@strMaxPostTableId+'].[tid]  WHERE [dnt_posts'+@strMaxPostTableId+'].[layer]=0 AND  [dnt_topics].[fid]='+LTRIM(STR(@fid))+' ORDER BY [lastpost] DESC'
EXEC(@strSQL)
GO
/****** Object:  StoredProcedure [dbo].[dnt_getfirstpost1id]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getfirstpost1id]
                    @tid int
                    AS
                    SELECT TOP 1 [pid] FROM [dnt_posts1] WHERE [tid]=@tid ORDER BY [pid]
GO
/****** Object:  StoredProcedure [dbo].[dnt_getfirstimageattachbytid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getfirstimageattachbytid]
@tid INT
AS
SELECT TOP 1 
[aid],
[uid],
[tid],
[pid],
[postdatetime],
[readperm],
[filename],
[description],
[filetype],
[filesize],
[attachment],
[downloads],
[attachprice],
[width],
[height] 
FROM [dnt_attachments] 
WHERE [tid]=@tid AND LEFT([filetype], 5)='image' ORDER BY [aid]
GO
/****** Object:  StoredProcedure [dbo].[dnt_getfavoriteslist]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getfavoriteslist]
@uid int,
@pagesize int,
@pageindex int
AS

--SELECT [f].[uid],[f].[tid],[topics].[title],[topics].[poster],[topics].[postdatetime],[topics].[replies],[topics].[views],[topics].[posterid] FROM [dnt_favorites] [f] LEFT JOIN [dnt_topics] [topics]  ON   [f].[tid]=[topics].[tid] WHERE  [f].[typeid]=0 AND [f].[uid]=@uid
IF @pageindex = 1
	BEGIN
		SELECT TOP(@pagesize) [uid],[tid],[title],[poster],[postdatetime],[replies],[views],[posterid]  
		FROM (SELECT [f].[uid],[f].[tid],[topics].[title],[topics].[poster],[topics].[postdatetime],[topics].[replies],[topics].[views],[topics].[posterid] FROM [dnt_favorites] [f] LEFT JOIN [dnt_topics] [topics]  ON   [f].[tid]=[topics].[tid] WHERE  [f].[typeid]=0 AND [f].[uid]=@uid) favorites ORDER BY [tid] DESC
	END
ELSE
	BEGIN
		SELECT TOP(@pagesize) [uid],[tid],[title],[poster],[postdatetime],[replies],[views],[posterid] 
	    FROM (SELECT [f].[uid],[f].[tid],[topics].[title],[topics].[poster],[topics].[postdatetime],[topics].[replies],[topics].[views],[topics].[posterid] FROM [dnt_favorites] [f] LEFT JOIN [dnt_topics] [topics]  ON   [f].[tid]=[topics].[tid] WHERE  [f].[typeid]=0 AND [f].[uid]=@uid) f1 WHERE [tid] < (SELECT MIN([tid]) FROM (SELECT TOP((@pageindex-1)*@pagesize) [tid] 
	    FROM (SELECT [f].[uid],[f].[tid],[topics].[title],[topics].[poster],[topics].[postdatetime],[topics].[replies],[topics].[views],[topics].[posterid] FROM [dnt_favorites] [f] LEFT JOIN [dnt_topics] [topics]  ON   [f].[tid]=[topics].[tid] WHERE  [f].[typeid]=0 AND [f].[uid]=@uid) f2 ORDER BY [tid] DESC) AS tblTmp)  ORDER BY [tid] DESC
	END
GO
/****** Object:  StoredProcedure [dbo].[dnt_getfavoritescount]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getfavoritescount]
@uid int,
@typeid smallint
AS
     SELECT COUNT(uid)  FROM [dnt_favorites] WHERE [uid]=@uid AND [typeid]=@typeid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getexpiredonlineuserlist]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getexpiredonlineuserlist]
@expires datetime
AS

SELECT [olid], [userid] FROM [dnt_online] WHERE [lastupdatetime]<@expires
GO
/****** Object:  StoredProcedure [dbo].[dnt_getorderbyordercode]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getorderbyordercode]
@ordercode char(32)
AS
BEGIN
	SELECT [orderid],[ordercode],[uid],[buyer],[paytype],[tradeno],[price],[orderstatus],[createdtime],[confirmedtime]
,[credit],[amount] FROM [dnt_orders] WHERE [ordercode]=@ordercode
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_getonlineuserlistbyfid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getonlineuserlistbyfid]
@fid int
AS
SELECT [olid]
      ,[userid]
      ,[ip]
      ,[username]
      ,[nickname]
      ,[password]
      ,[groupid]
      ,[olimg]
      ,[adminid]
      ,[invisible]
      ,[action]
      ,[lastactivity]
      ,[lastposttime]
      ,[lastpostpmtime]
      ,[lastsearchtime]
      ,[lastupdatetime]
      ,[forumid]
      ,[forumname]
      ,[titleid]
      ,[title]
      ,[verifycode]
      ,[newpms]
      ,[newnotices] FROM [dnt_online] WHERE [forumid]=@fid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getonlineuserlist]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getonlineuserlist]
AS
SELECT [olid]
      ,[userid]
      ,[ip]
      ,[username]
      ,[nickname]
      ,[password]
      ,[groupid]
      ,[olimg]
      ,[adminid]
      ,[invisible]
      ,[action]
      ,[lastactivity]
      ,[lastposttime]
      ,[lastpostpmtime]
      ,[lastsearchtime]
      ,[lastupdatetime]
      ,[forumid]
      ,[forumname]
      ,[titleid]
      ,[title]
      ,[verifycode]
      ,[newpms]
      ,[newnotices] FROM [dnt_online]
GO
/****** Object:  StoredProcedure [dbo].[dnt_getonlineuserbyip]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getonlineuserbyip]
@userid int,
@ip varchar(15)
AS

SELECT TOP 1 [olid]
      ,[userid]
      ,[ip]
      ,[username]
      ,[nickname]
      ,[password]
      ,[groupid]
      ,[olimg]
      ,[adminid]
      ,[invisible]
      ,[action]
      ,[lastactivity]
      ,[lastposttime]
      ,[lastpostpmtime]
      ,[lastsearchtime]
      ,[lastupdatetime]
      ,[forumid]
      ,[forumname]
      ,[titleid]
      ,[title]
      ,[verifycode]
      ,[newpms]
      ,[newnotices] FROM [dnt_online] WHERE [userid]=@userid AND [ip]=@ip
GO
/****** Object:  StoredProcedure [dbo].[dnt_getonlineuser]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getonlineuser]
@userid int,
@password char(32)
AS
SELECT TOP 1 [olid]
      ,[userid]
      ,[ip]
      ,[username]
      ,[nickname]
      ,[password]
      ,[groupid]
      ,[olimg]
      ,[adminid]
      ,[invisible]
      ,[action]
      ,[lastactivity]
      ,[lastposttime]
      ,[lastpostpmtime]
      ,[lastsearchtime]
      ,[lastupdatetime]
      ,[forumid]
      ,[forumname]
      ,[titleid]
      ,[title]
      ,[verifycode]
      ,[newpms]
      ,[newnotices] FROM [dnt_online] WHERE [userid]=@userid AND [password]=@password
GO
/****** Object:  StoredProcedure [dbo].[dnt_getonlineuercount]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getonlineuercount]
AS
SELECT COUNT(olid) FROM [dnt_online]
GO
/****** Object:  StoredProcedure [dbo].[dnt_getonlineregistercount]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_getonlineregistercount]
AS
SELECT COUNT(olid) FROM [dnt_online] WHERE [userid]>0
GO
/****** Object:  StoredProcedure [dbo].[dnt_getonlinegroupicontable]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_getonlinegroupicontable]
AS
SELECT [groupid], [displayorder], [title], [img] FROM [dnt_onlinelist] WHERE [img] <> '' ORDER BY [displayorder]
GO
/****** Object:  StoredProcedure [dbo].[dnt_getnousedforumattachment]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getnousedforumattachment]
AS
SELECT 
[aid],
[uid],
[tid],
[pid],
[postdatetime],
[readperm],
[filename],
[description],
[filetype],
[filesize],
[attachment],
[downloads],
[attachprice],
[width],
[height]
FROM [dnt_attachments] 
WHERE [tid]= 0 AND [pid]=0 AND DATEDIFF(n, postdatetime, GETDATE()) > 30
GO
/****** Object:  StoredProcedure [dbo].[dnt_getnousedattachmentlistbytid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getnousedattachmentlistbytid]
@uid INT
AS
SELECT 
[aid], 
[attachment] 
FROM [dnt_attachments] 
WHERE [uid]= @uid AND [tid]=0 AND [pid]=0
GO
/****** Object:  StoredProcedure [dbo].[dnt_getnoticecountbyuid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getnoticecountbyuid]
@uid int,
@type int
AS
IF @type = -1
   SELECT COUNT(nid) FROM [dnt_notices] WHERE [uid] = @uid
ELSE
    SELECT COUNT(nid) FROM [dnt_notices] WHERE [uid] = @uid AND [type]=@type
GO
/****** Object:  StoredProcedure [dbo].[dnt_getnoticecount]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getnoticecount]
@userid int,
@type int = -1,
@state int=-1
AS

	IF @type = -1
		BEGIN
			IF @state = -1
				BEGIN
					SELECT COUNT(nid) AS [pmcount] FROM [dnt_notices] WHERE [uid]=@userid
				END
			ELSE
				BEGIN
					SELECT COUNT(nid) AS [pmcount] FROM [dnt_notices] WHERE [uid]=@userid AND [new]=@state
				END
		END
	ELSE
		BEGIN
			IF @state = -1
				BEGIN
					SELECT COUNT(nid) AS [pmcount] FROM [dnt_notices] WHERE [uid]=@userid AND [type]=@type
				END
			ELSE
				BEGIN
					SELECT COUNT(nid) AS [pmcount] FROM [dnt_notices] WHERE [uid]=@userid AND [new]=@state AND [type]=@type
				END
		END
GO
/****** Object:  StoredProcedure [dbo].[dnt_getnoticebyuid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getnoticebyuid]
@uid int,
@type int

AS

IF @type = 0
     SELECT nid, uid, type, new, posterid, poster, note, postdatetime FROM [dnt_notices] WHERE [uid] = @uid  ORDER BY [postdatetime] DESC
ELSE
    SELECT nid, uid, type, new, posterid, poster, note, postdatetime  FROM [dnt_notices] WHERE [uid] = @uid AND [type] = @type ORDER BY [postdatetime] DESC
GO
/****** Object:  StoredProcedure [dbo].[dnt_getnewtopics1]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getnewtopics1]
					@fidlist VARCHAR(500)
					AS
					IF @fidlist <> ''
					BEGIN
					SELECT TOP(20) 
						[dnt_posts1].[tid], 
						[dnt_posts1].[title], 
						[dnt_posts1].[poster], 
						[dnt_posts1].[postdatetime], 
						[dnt_posts1].[message],
						[dnt_forums].[name] 
						FROM [dnt_posts1]  
						LEFT JOIN [dnt_forums] ON [dnt_posts1].[fid]=[dnt_forums].[fid]
						LEFT JOIN [dnt_topics] ON [dnt_posts1].[tid]=[dnt_topics].[tid]
						WHERE CHARINDEX(','+RTRIM([dnt_forums].[fid])+',', ','+@fidlist+',') > 0 
						AND [dnt_posts1].[layer]=0 AND [dnt_topics].[displayorder] >= 0
						ORDER BY [dnt_posts1].[tid] DESC
					END 
					ELSE
					BEGIN
					SELECT TOP(20) 
						[dnt_posts1].[tid], 
						[dnt_posts1].[title], 
						[dnt_posts1].[poster], 
						[dnt_posts1].[postdatetime], 
						[dnt_posts1].[message],
						[dnt_forums].[name] 
						FROM [dnt_posts1]
						LEFT JOIN [dnt_forums] ON [dnt_posts1].[fid]=[dnt_forums].[fid]
						LEFT JOIN [dnt_topics] ON [dnt_posts1].[tid]=[dnt_topics].[tid]
						WHERE [dnt_posts1].[layer]=0 AND [dnt_topics].[displayorder] >= 0
						ORDER BY [dnt_posts1].[tid] DESC
					END
GO
/****** Object:  StoredProcedure [dbo].[dnt_getnewnoticecountbyuid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getnewnoticecountbyuid]
@uid int
AS

SELECT COUNT(nid) FROM [dnt_notices] WHERE [uid] =  @uid  AND [new] = 1
GO
/****** Object:  StoredProcedure [dbo].[dnt_getmytopics]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getmytopics]
@uid int,
@pageindex int,
@pagesize int
AS
DECLARE @startRow int,
	@endRow int
SET @startRow = ( @pageindex - 1 ) * @pagesize + 1 
SET @endRow = @startRow + @pagesize - 1

SELECT 
[MYTOPIC].[tid], 
[MYTOPIC].[fid], 
[MYTOPIC].[iconid], 
[MYTOPIC].[typeid], 
[MYTOPIC].[readperm], 
[MYTOPIC].[price], 
[MYTOPIC].[poster], 
[MYTOPIC].[posterid], 
[MYTOPIC].[title], 
[MYTOPIC].[postdatetime], 
[MYTOPIC].[lastpost], 
[MYTOPIC].[lastpostid], 
[MYTOPIC].[lastposter], 
[MYTOPIC].[lastposterid], 
[MYTOPIC].[views], 
[MYTOPIC].[replies], 
[MYTOPIC].[displayorder], 
[MYTOPIC].[highlight], 
[MYTOPIC].[digest], 
[MYTOPIC].[rate], 
[MYTOPIC].[hide], 
[MYTOPIC].[special], 
[MYTOPIC].[attachment], 
[MYTOPIC].[moderated], 
[MYTOPIC].[closed], 
[MYTOPIC].[magic]
FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_topics].[lastpost] DESC) AS ROWID,
[dnt_topics].[tid], 
[dnt_topics].[fid], 
[dnt_topics].[iconid], 
[dnt_topics].[typeid], 
[dnt_topics].[readperm], 
[dnt_topics].[price], 
[dnt_topics].[poster], 
[dnt_topics].[posterid], 
[dnt_topics].[title], 
[dnt_topics].[postdatetime], 
[dnt_topics].[lastpost], 
[dnt_topics].[lastpostid], 
[dnt_topics].[lastposter], 
[dnt_topics].[lastposterid], 
[dnt_topics].[views], 
[dnt_topics].[replies], 
[dnt_topics].[displayorder], 
[dnt_topics].[highlight], 
[dnt_topics].[digest], 
[dnt_topics].[rate], 
[dnt_topics].[hide], 
[dnt_topics].[special], 
[dnt_topics].[attachment], 
[dnt_topics].[moderated], 
[dnt_topics].[closed], 
[dnt_topics].[magic]
FROM [dnt_topics] 
INNER JOIN [dnt_mytopics] ON ([dnt_topics].[tid] = [dnt_mytopics].[tid] AND [dnt_mytopics].[uid] = @uid)) AS MYTOPIC
WHERE ROWID BETWEEN @startRow AND @endRow
GO
/****** Object:  StoredProcedure [dbo].[dnt_getmyposts]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getmyposts]
@uid int,
@pageindex int,
@pagesize int
 AS
DECLARE @startRow int,
	@endRow int
SET @startRow = ( @pageindex - 1 ) * @pagesize + 1
SET @endRow = @startRow + @pagesize - 1

SELECT 
[MYPOST].[tid], 
[MYPOST].[fid], 
[MYPOST].[iconid], 
[MYPOST].[typeid], 
[MYPOST].[readperm], 
[MYPOST].[price], 
[MYPOST].[poster], 
[MYPOST].[posterid], 
[MYPOST].[title], 
[MYPOST].[postdatetime], 
[MYPOST].[lastpost], 
[MYPOST].[lastpostid], 
[MYPOST].[lastposter], 
[MYPOST].[lastposterid], 
[MYPOST].[views], 
[MYPOST].[replies], 
[MYPOST].[displayorder], 
[MYPOST].[highlight], 
[MYPOST].[digest], 
[MYPOST].[rate], 
[MYPOST].[hide], 
[MYPOST].[special], 
[MYPOST].[attachment], 
[MYPOST].[moderated], 
[MYPOST].[closed], 
[MYPOST].[magic] 
FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_myposts].[tid] DESC) AS ROWID,
[dnt_topics].[tid], 
[dnt_topics].[fid], 
[dnt_topics].[iconid], 
[dnt_topics].[typeid], 
[dnt_topics].[readperm], 
[dnt_topics].[price], 
[dnt_topics].[poster], 
[dnt_topics].[posterid], 
[dnt_topics].[title], 
[dnt_topics].[postdatetime], 
[dnt_topics].[lastpost], 
[dnt_topics].[lastpostid], 
[dnt_topics].[lastposter], 
[dnt_topics].[lastposterid], 
[dnt_topics].[views], 
[dnt_topics].[replies], 
[dnt_topics].[displayorder], 
[dnt_topics].[highlight], 
[dnt_topics].[digest], 
[dnt_topics].[rate], 
[dnt_topics].[hide], 
[dnt_topics].[special], 
[dnt_topics].[attachment], 
[dnt_topics].[moderated], 
[dnt_topics].[closed], 
[dnt_topics].[magic]
FROM [dnt_topics] 
INNER JOIN [dnt_myposts] ON ([dnt_topics].[tid] = [dnt_myposts].[tid] AND [dnt_myposts].[uid] = @uid)) AS MYPOST
WHERE ROWID BETWEEN @startRow AND @endRow
GO
/****** Object:  StoredProcedure [dbo].[dnt_getmyattachmentsbytype]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getmyattachmentsbytype]
@uid int,
@pageindex int,
@pagesize int,
@extlist as nvarchar(100)
AS
DECLARE @startRow int,
	@endRow int
SET @startRow=(@pageindex - 1) * @pagesize + 1
SET @endRow = @startRow + @pagesize - 1

SELECT 
[ATTACHMENTS].[aid],
[ATTACHMENTS].[uid],
[ATTACHMENTS].[attachment],
[ATTACHMENTS].[description],
[ATTACHMENTS].[downloads],
[ATTACHMENTS].[extname],
[ATTACHMENTS].[filename],
[ATTACHMENTS].[pid],
[ATTACHMENTS].[postdatetime],
[ATTACHMENTS].[tid]
FROM (SELECT ROW_NUMBER() OVER(ORDER BY [aid] DESC) AS ROWID,
[dnt_myattachments].[aid],
[dnt_myattachments].[uid],
[dnt_myattachments].[attachment],
[dnt_myattachments].[description],
[dnt_myattachments].[downloads],
[dnt_myattachments].[extname],
[dnt_myattachments].[filename],
[dnt_myattachments].[pid],
[dnt_myattachments].[postdatetime],
[dnt_myattachments].[tid]
FROM [dnt_myattachments]
WHERE [uid] = @uid AND CHARINDEX([dnt_myattachments].[extname], @extlist) > 0) AS ATTACHMENTS
WHERE ROWID BETWEEN @startRow AND @endRow
GO
/****** Object:  StoredProcedure [dbo].[dnt_getmyattachments]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getmyattachments]
@uid int,
@pageindex int,
@pagesize int
 AS
DECLARE @startRow int,
		@endRow int
SET @startRow=(@pageindex-1) * @pagesize + 1
SET @endRow = @startRow + @pagesize - 1
SELECT 
[ATTACHMENTS].[aid],
[ATTACHMENTS].[uid],
[ATTACHMENTS].[attachment],
[ATTACHMENTS].[description],
[ATTACHMENTS].[downloads],
[ATTACHMENTS].[extname],
[ATTACHMENTS].[filename],
[ATTACHMENTS].[pid],
[ATTACHMENTS].[postdatetime],
[ATTACHMENTS].[tid]
FROM (SELECT ROW_NUMBER() OVER(ORDER BY [aid] DESC) AS ROWID,
[dnt_myattachments].[aid],
[dnt_myattachments].[uid],
[dnt_myattachments].[attachment],
[dnt_myattachments].[description],
[dnt_myattachments].[downloads],
[dnt_myattachments].[extname],
[dnt_myattachments].[filename],
[dnt_myattachments].[pid],
[dnt_myattachments].[postdatetime],
[dnt_myattachments].[tid]
FROM [dnt_myattachments]
WHERE [dnt_myattachments].[uid] = @uid ) AS ATTACHMENTS
WHERE ROWID BETWEEN @startRow AND @endRow
GO
/****** Object:  StoredProcedure [dbo].[dnt_getmaxandmintid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_getmaxandmintid]
@fid INT
AS
SELECT 
MAX([tid]) AS [maxtid],
MIN([tid]) AS [mintid] 
FROM [dnt_topics] 
WHERE 
[fid] IN (SELECT [fid] 
		  FROM [dnt_forums] 
		  WHERE [fid]=@fid 
		  OR (CHARINDEX(',' + RTRIM(@fid) + ',', ',' + RTRIM(parentidlist) + ',') > 0))
GO
/****** Object:  StoredProcedure [dbo].[dnt_getmainforum]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_getmainforum]
AS
SELECT
[fid],[parentid],[layer],[pathlist],[parentidlist],[subforumcount],[name],[status],[colcount],[displayorder],[templateid],[topics],[curtopics],[posts],[todayposts],[lasttid],[lasttitle],[lastpost],[lastposterid],[lastposter],[allowsmilies],[allowrss],[allowhtml],[allowbbcode],[allowimgcode],[allowblog],[istrade],[allowpostspecial],[allowspecialonly],[alloweditrules],[allowthumbnail],[allowtag],[recyclebin],[modnewposts],[jammer],[disablewatermark],[inheritedmod],[autoclose] 
FROM [dnt_forums] 
WHERE [layer]=0 
Order By [displayorder] ASC
GO
/****** Object:  StoredProcedure [dbo].[dnt_getlastposttid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_getlastposttid]
@visibleforums VARCHAR(4000),
@fid INT
AS
IF @visibleforums=''
SELECT TOP 1 [tid] FROM [dnt_topics] AS t LEFT JOIN [dnt_forums] AS f  ON [t].[fid] = [f].[fid] 
WHERE [t].[closed]<>1 AND  [t].[displayorder] >=0  AND ([t].[fid] = @fid 
OR CHARINDEX(',' + CONVERT(NVARCHAR(10), @fid) + ',' , ',' + RTRIM([f].[parentidlist]) + ',') > 0 )  
ORDER BY [t].[lastpost] DESC
ELSE
EXEC('SELECT TOP 1 [tid] FROM [dnt_topics] AS t LEFT JOIN [dnt_forums] AS f  ON [t].[fid] = [f].[fid] 
WHERE [t].[closed]<>1 AND  [t].[displayorder] >=0  AND ([t].[fid] = ' + @fid +
'OR CHARINDEX('','' + CONVERT(NVARCHAR(10), ' + @fid + ') + '','' , '','' + RTRIM([f].[parentidlist]) + '','') > 0 )  
AND [t].[fid] IN ('+@visibleforums+')  ORDER BY [t].[lastpost] DESC')
GO
/****** Object:  StoredProcedure [dbo].[dnt_getlastpostlist1]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getlastpostlist1]
	                    @tid int,
	                    @pageindex int,
	                    @postnum int,
	                    @posttablename varchar(20)
                    AS
                    DECLARE @startRow int,
		                    @endRow int
                    SET @startRow = (@pageIndex - 1) * @postnum +1
                    SET @endRow = @startRow + @postnum -1

                    SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY [pid]) AS ROWID,
		                    [dnt_posts1].[pid],
		                    [dnt_posts1].[fid], 
		                    [dnt_posts1].[layer],
		                    [dnt_posts1].[posterid],
		                    [dnt_posts1].[title], 
		                    [dnt_posts1].[message], 
		                    [dnt_posts1].[postdatetime], 
		                    [dnt_posts1].[attachment], 
		                    [dnt_posts1].[poster], 
		                    [dnt_posts1].[invisible], 
		                    [dnt_posts1].[usesig], 
		                    [dnt_posts1].[htmlon], 
		                    [dnt_posts1].[smileyoff], 
		                    [dnt_posts1].[parseurloff], 
		                    [dnt_posts1].[bbcodeoff], 
		                    [dnt_posts1].[rate], 
		                    [dnt_posts1].[ratetimes], 
		                    [dnt_users].[username], 
		                    [dnt_users].[email], 
		                    [dnt_users].[showemail], 
		                    [dnt_userfields].[avatar], 
		                    [dnt_userfields].[avatarwidth], 
		                    [dnt_userfields].[avatarheight], 
		                    [dnt_userfields].[sightml] AS [signature], 
		                    [dnt_userfields].[location], 
		                    [dnt_userfields].[customstatus] 
		                    FROM [dnt_posts1] 
		                    LEFT JOIN [dnt_users] ON [dnt_users].[uid]=[dnt_posts1].[posterid]
		                    LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid]=[dnt_users].[uid]
		                    WHERE [dnt_posts1].[tid] = @tid AND [dnt_posts1].[invisible] <=0 AND [dnt_posts1].layer <> 0) AS POST
		                    WHERE ROWID BETWEEN @startRow AND @endRow
GO
/****** Object:  StoredProcedure [dbo].[dnt_createtopic]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createtopic]
@fid smallint,
@iconid smallint,
@title nchar(80),
@typeid smallint,
@readperm int,
@price smallint,
@poster char(20),
@posterid int,
@postdatetime smalldatetime,
@lastpost smalldatetime,
@lastpostid int,
@lastposter char(20),
@views int,
@replies int,
@displayorder int,
@highlight varchar(500),
@digest int,
@rate int,
@hide int,
@attachment int,
@moderated int,
@closed int,
@magic int,
@special tinyint,
@attention int
AS

DECLARE @topicid int

DELETE FROM [dnt_topics] WHERE [tid]>(SELECT ISNULL(max(tid),0)-100 FROM [dnt_topics]) AND [lastpostid]=0

INSERT INTO [dnt_topics]([fid], [iconid], [title], [typeid], [readperm], [price], [poster], [posterid], [postdatetime], [lastpost], [lastpostid], [lastposter], [views], [replies], [displayorder], [highlight], [digest], [rate], [hide], [attachment], [moderated], [closed], [magic], [special],[attention]) VALUES(@fid, @iconid, @title, @typeid, @readperm, @price, @poster, @posterid, @postdatetime, @lastpost, @lastpostid, @lastposter, @views, @replies, @displayorder, @highlight, @digest, @rate, @hide, @attachment, @moderated, @closed, @magic, @special,@attention)

SET @topicid=SCOPE_IDENTITY()

IF @@ERROR=0 AND @displayorder=0
	BEGIN
		UPDATE [dnt_statistics] SET [totaltopic]=[totaltopic] + 1


		UPDATE [dnt_forums] SET [topics] = [topics] + 1,[curtopics] = [curtopics] + 1 WHERE [fid] = @fid
		
		IF @posterid <> -1
		BEGIN
			INSERT INTO [dnt_mytopics]([tid],[uid],[dateline]) VALUES(@topicid,  @posterid,  @postdatetime)
		END
		
	END
	
SELECT @topicid as topicid
GO
/****** Object:  StoredProcedure [dbo].[dnt_createtags]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createtags]
@tags nvarchar(55),
@userid int,
@postdatetime datetime
AS
BEGIN	
	INSERT INTO [dnt_tags]([tagname], [userid], [postdatetime], [orderid], [color], [count], [fcount], [pcount], [scount], [vcount]) 
		SELECT [item], @userid, @postdatetime, 0, '', 0, 0, 0, 0, 0 FROM [dnt_split](@tags, ' ') AS [newtags] 
		WHERE NOT EXISTS (SELECT [tagname] FROM [dnt_tags] WHERE [newtags].[item] = [tagname])
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_createsearchcache]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createsearchcache]
	@keywords varchar(255),
	@searchstring varchar(255),
	@ip varchar(15),
	@uid int,
	@groupid int,
	@postdatetime varchar(19),
	@expiration varchar(19),
	@topics int,
	@tids text
AS
INSERT INTO dnt_searchcaches 
	([keywords],[searchstring],[ip],[uid],[groupid],[postdatetime],[expiration],[topics],[tids])
VALUES
	(@keywords,@searchstring,@ip,@uid,@groupid,@postdatetime,@expiration,@topics,@tids)
SELECT SCOPE_IDENTITY()  AS 'searchid'
GO
/****** Object:  StoredProcedure [dbo].[dnt_createpost1]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createpost1]
                    @fid int,
                    @tid int,
                    @parentid int,
                    @layer int,
                    @poster varchar(20),
                    @posterid int,
                    @title nvarchar(60),
                    @topictitle nvarchar(60),
                    @postdatetime char(20),
                    @message ntext,
                    @ip varchar(15),
                    @lastedit varchar(50),
                    @invisible int,
                    @usesig int,
                    @htmlon int,
                    @smileyoff int,
                    @bbcodeoff int,
                    @parseurloff int,
                    @attachment int,
                    @rate int,
                    @ratetimes int

                    AS


                    DEClARE @postid int

                    DELETE FROM [dnt_postid] WHERE DATEDIFF(n, postdatetime, GETDATE()) >5

                    INSERT INTO [dnt_postid] ([postdatetime]) VALUES(GETDATE())

                    SELECT @postid=SCOPE_IDENTITY()

                    INSERT INTO [dnt_posts1]([pid], [fid], [tid], [parentid], [layer], [poster], [posterid], [title], [postdatetime], [message], [ip], [lastedit], [invisible], [usesig], [htmlon], [smileyoff], [bbcodeoff], [parseurloff], [attachment], [rate], [ratetimes]) VALUES(@postid, @fid, @tid, @parentid, @layer, @poster, @posterid, @title, @postdatetime, @message, @ip, @lastedit, @invisible, @usesig, @htmlon, @smileyoff, @bbcodeoff, @parseurloff, @attachment, @rate, @ratetimes)

                    IF @parentid=0
                        BEGIN
                    		
                            UPDATE [dnt_posts1] SET [parentid]=@postid WHERE [pid]=@postid
                        END

                    IF @@ERROR=0
                        BEGIN
                            IF  @invisible = 0
                            BEGIN
                    		
                                UPDATE [dnt_statistics] SET [totalpost]=[totalpost] + 1
                    		
                    		
                    		
                                DECLARE @fidlist AS VARCHAR(1000)
                                DECLARE @strsql AS VARCHAR(4000)
                    			
                                SET @fidlist = '';
                    			
                                SELECT @fidlist = ISNULL([parentidlist],'') FROM [dnt_forums] WHERE [fid] = @fid
                                IF RTRIM(@fidlist)<>''
	                                BEGIN
		                                SET @fidlist = RTRIM(@fidlist) + ',' + CAST(@fid AS VARCHAR(10))
	                                END
                                ELSE
	                                BEGIN
		                                SET @fidlist = CAST(@fid AS VARCHAR(10))
	                                END
                            
                    			
                                UPDATE [dnt_forums] SET 
						                                [posts]=[posts] + 1, 
						                                [todayposts]=CASE 
										                                WHEN DATEDIFF(day, [lastpost], GETDATE())=0 THEN [todayposts] + 1 
									                                 ELSE 1 
									                                 END,
						                                [lasttid]=@tid,	
                                            [lasttitle]=@topictitle,
						                                [lastpost]=@postdatetime,
						                                [lastposter]=@poster,
						                                [lastposterid]=@posterid 
                    							
				                                		WHERE fid IN (SELECT [item] FROM [dnt_split](@fidlist, ','))
                    			
                    			
                                UPDATE [dnt_users] SET
	                                [lastpost] = @postdatetime,
	                                [lastpostid] = @postid,
	                                [lastposttitle] = @title,
	                                [posts] = [posts] + 1,
	                                [lastactivity] = GETDATE()
                                WHERE [uid] = @posterid
                            
                            
                                IF @layer<=0
	                                BEGIN
		                                UPDATE [dnt_topics] SET [replies]=0,[lastposter]=@poster,[lastpost]=@postdatetime,[lastposterid]=@posterid WHERE [tid]=@tid
	                                END
                                ELSE
	                                BEGIN
		                                UPDATE [dnt_topics] SET [replies]=[replies] + 1,[lastposter]=@poster,[lastpost]=@postdatetime,[lastposterid]=@posterid WHERE [tid]=@tid
	                                END
                            END

                            UPDATE [dnt_topics] SET [lastpostid]=@postid WHERE [tid]=@tid
                            
                        IF @posterid <> -1
                            BEGIN
                                INSERT [dnt_myposts]([uid], [tid], [pid], [dateline]) VALUES(@posterid, @tid, @postid, @postdatetime)
                            END

                        END
                    	
                    SELECT @postid AS postid
GO
/****** Object:  StoredProcedure [dbo].[dnt_createpm]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createpm]
@pmid int,
@msgfrom nvarchar(20),
@msgto nvarchar(20),
@msgfromid int,
@msgtoid int,
@folder smallint=0,
@new int=0,
@subject nvarchar(60),
@postdatetime datetime,
@message ntext,
@savetosentbox smallint=1
AS

IF @folder<>0
	BEGIN
		SET @msgfrom=@msgto
	END
ELSE
	BEGIN
		UPDATE [dnt_users] SET [newpmcount]=ABS(ISNULL([newpmcount],0)*1)+1,[newpm] = 1 WHERE [uid]=@msgtoid
	END

	

INSERT INTO [dnt_pms] 
	([msgfrom],[msgfromid],[msgto],[msgtoid],[folder],[new],[subject],[postdatetime],[message])
VALUES
	(@msgfrom,@msgfromid,@msgto,@msgtoid,@folder,@new,@subject,@postdatetime,@message)
	
SELECT SCOPE_IDENTITY() AS 'pmid'

IF @savetosentbox=1 AND @folder=0
	BEGIN
		INSERT INTO [dnt_pms]
			([msgfrom],[msgfromid],[msgto],[msgtoid],[folder],[new],[subject],[postdatetime],[message])
		VALUES
			(@msgfrom,@msgfromid,@msgto,@msgtoid,1,@new,@subject,@postdatetime,@message)
	END
GO
/****** Object:  StoredProcedure [dbo].[dnt_createorder]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createorder]
@ordercode char(32),
@uid int,
@buyer char(20),
@paytype tinyint,
@price decimal(18,2),
@orderstatus tinyint,
@credit tinyint,
@amount int
AS
BEGIN
INSERT INTO [dnt_orders]([ordercode],[uid],[buyer],[paytype],[price],[orderstatus],
[credit],[amount]) VALUES(@ordercode,@uid,@buyer,@paytype,@price,@orderstatus,@credit,@amount)
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_createonlineuser]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createonlineuser] 
@onlinestate int,
@userid int,
@ip varchar(15),
@username nvarchar(40),
@nickname nvarchar(40),
@password char(32),
@groupid smallint,
@olimg varchar(80),
@adminid smallint,
@invisible smallint,
@action smallint,
@lastactivity smallint,
@lastposttime datetime,
@lastpostpmtime datetime,
@lastsearchtime datetime,
@lastupdatetime datetime,
@forumid int,
@forumname nvarchar(50),
@titleid int,
@title nvarchar(80),
@verifycode varchar(10),
@newpms smallint,
@newnotices smallint

AS

IF @onlinestate = 0
BEGIN
	UPDATE [dnt_users] SET [onlinestate]=1 WHERE [uid]=@userid
END


INSERT INTO [dnt_online] ([userid],[ip],[username],[nickname],[password],[groupid],[olimg],[adminid],[invisible],[action],[lastactivity],[lastposttime],[lastpostpmtime],[lastsearchtime],[lastupdatetime],[forumid],[forumname],[titleid],[title],[verifycode],[newpms],[newnotices])VALUES(@userid,@ip,@username,@nickname,@password,@groupid,@olimg,@adminid,@invisible,@action,@lastactivity,@lastposttime,@lastpostpmtime,@lastsearchtime,@lastupdatetime,@forumid,@forumname,@titleid,@title,@verifycode,@newpms,@newnotices);SELECT SCOPE_IDENTITY()
GO
/****** Object:  StoredProcedure [dbo].[dnt_createnotice]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createnotice]
@uid int,
@type int,
@new  int,
@posterid int,
@poster nchar(20),
@note ntext,
@postdatetime datetime

AS

INSERT INTO [dnt_notices] ([uid], [type], [new], [posterid], [poster], [note], [postdatetime]) VALUES (@uid, @type, @new, @posterid, @poster, @note, @postdatetime);

SELECT SCOPE_IDENTITY()  AS 'nid'
GO
/****** Object:  StoredProcedure [dbo].[dnt_createinvitecode]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createinvitecode]
                    @code char(8),
                    @creatorid int,
                    @creator nchar(20),
                    @createtime smalldatetime,
                    @expiretime smalldatetime,
                    @maxcount int,
                    @invitetype int

                    AS
                    
                    INSERT INTO [dnt_invitation]([invitecode],[creatorid],[creator],[createdtime],[expiretime],[maxcount],[invitetype])
                     VALUES(@code,@creatorid,@creator,@createtime,@expiretime,@maxcount,@invitetype);SELECT SCOPE_IDENTITY()
GO
/****** Object:  StoredProcedure [dbo].[dnt_createfavorite]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createfavorite]
@uid int,
@tid int,
@type tinyint

AS
	
	INSERT INTO [dnt_favorites] ([uid],[tid],[typeid]) VALUES(@uid,@tid,@type)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[dnt_createdebatepostexpand]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createdebatepostexpand]
	@tid int,
	@pid int,
	@opinion int,
	@diggs int
AS
BEGIN
	INSERT INTO [dnt_postdebatefields] VALUES(@tid, @pid, @opinion, @diggs)
	IF @opinion = 1
		UPDATE [dnt_debates] SET [positivediggs] = [positivediggs] + 1 WHERE [tid] = @tid
	ELSE IF @opinion = 2
		UPDATE [dnt_debates] SET [negativediggs] = [negativediggs] + 1 WHERE [tid] = @tid
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_createattachment]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createattachment]
@uid int,
@tid int,
@pid int,
@postdatetime datetime,
@readperm int,
@filename nchar(200),
@description nchar(200),
@filetype nchar(100),
@filesize int,
@attachment nchar(200),
@downloads int,
@extname nvarchar(50),
@attachprice int,
@width int,
@height int
AS
DECLARE @aid int

INSERT INTO [dnt_attachments]([uid],[tid], [pid], [postdatetime], [readperm], [filename], [description], [filetype], [filesize],  [attachment], [downloads],[attachprice],[width],[height]) VALUES(@uid, @tid, @pid, @postdatetime, @readperm, @filename, @description, @filetype, @filesize,  @attachment, @downloads, @attachprice,@width,@height)
SELECT SCOPE_IDENTITY()  AS 'aid'

set @aid=(SELECT SCOPE_IDENTITY()  AS 'aid')
UPDATE [dnt_posts1] SET [attachment]=1 WHERE [pid]=@pid
INSERT INTO [dnt_myattachments]([aid],[uid],[attachment],[description],[postdatetime],[downloads],[filename],[pid],[tid],[extname]) VALUES(@aid,@uid,@attachment,@description,@postdatetime,@downloads,@filename,@pid,@tid,@extname)
GO
/****** Object:  StoredProcedure [dbo].[dnt_createadmingroup]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createadmingroup]
	@admingid smallint,
	@alloweditpost tinyint,
	@alloweditpoll tinyint,
	@allowstickthread tinyint,
	@allowmodpost tinyint,
	@allowdelpost tinyint,
	@allowmassprune tinyint,
	@allowrefund tinyint,
	@allowcensorword tinyint,
	@allowviewip tinyint,
	@allowbanip tinyint,
	@allowedituser tinyint,
	@allowmoduser tinyint,
	@allowbanuser tinyint,
	@allowpostannounce tinyint,
	@allowviewlog tinyint,
	@disablepostctrl tinyint,
	@allowviewrealname tinyint
AS
INSERT INTO dnt_admingroups 
	([admingid],[alloweditpost],[alloweditpoll],[allowstickthread],[allowmodpost],[allowdelpost],[allowmassprune],[allowrefund],[allowcensorword],[allowviewip],[allowbanip],[allowedituser],[allowmoduser],[allowbanuser],[allowpostannounce],[allowviewlog],[disablepostctrl],[allowviewrealname])
VALUES
	(@admingid,@alloweditpost,@alloweditpoll,@allowstickthread,@allowmodpost,@allowdelpost,@allowmassprune,@allowrefund,@allowcensorword,@allowviewip,@allowbanip,@allowedituser,@allowmoduser,@allowbanuser,@allowpostannounce,@allowviewlog,@disablepostctrl,@allowviewrealname)
GO
/****** Object:  StoredProcedure [dbo].[dnt_clearexpireinvitecode]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_clearexpireinvitecode]
AS
BEGIN
DELETE [dnt_invitation] WHERE [invitetype]=3 AND [createdtime]<>[expiretime] AND ([expiretime]-GETDATE())<=0;
DELETE [dnt_invitation] WHERE [isdeleted]=1 AND [createdtime]<(GETDATE()-1)
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_clearexpirecreditorders]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_clearexpirecreditorders]
AS
BEGIN
   DELETE [dnt_orders] WHERE [orderstatus] < 1 AND [createdtime] < (GETDATE()-15)
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_checkpasswordbyusername]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_checkpasswordbyusername]
@username nchar(20),
@password char(32)
AS
SELECT TOP 1 [uid], [groupid], [adminid] FROM [dnt_users] WHERE [username]=@username AND [password]=@password
GO
/****** Object:  StoredProcedure [dbo].[dnt_checkpasswordbyuid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_checkpasswordbyuid]
@uid int,
@password char(32)
AS
SELECT TOP 1 [uid], [groupid], [adminid] FROM [dnt_users] WHERE [uid]=@uid AND [password]=@password
GO
/****** Object:  StoredProcedure [dbo].[dnt_checkpasswordandsecques]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_checkpasswordandsecques]
@username nchar(20),
@password char(32),
@secques char(8)
AS
SELECT TOP 1 [uid] FROM [dnt_users] WHERE [username]=@username AND [password]=@password AND [secques]=@secques
GO
/****** Object:  StoredProcedure [dbo].[dnt_checkemailandsecques]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_checkemailandsecques]
@username nchar(20),
@email char(32),
@secques char(8)
AS
SELECT TOP 1 [uid] FROM [dnt_users] WHERE [username]=@username AND [email]=@email AND [secques]=@secques
GO
/****** Object:  StoredProcedure [dbo].[dnt_getattachpaymentlogbyaid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getattachpaymentlogbyaid]
@aid int
AS
SELECT 
[id],
[uid],
[username],
[aid],
[authorid],
[postdatetime],
[amount],
[netamount]
FROM [dnt_attachpaymentlog]
WHERE [aid] = @aid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getattachmentlistbytidlist]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getattachmentlistbytidlist]
@tidlist VARCHAR(500)
AS
SELECT 
[aid],
[filename] 
FROM [dnt_attachments] WITH (NOLOCK)
WHERE [tid] IN (SELECT [item]FROM [dnt_split](@tidlist, ','))
GO
/****** Object:  StoredProcedure [dbo].[dnt_getattachmentlistbytid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getattachmentlistbytid]
@tid INT
AS
SELECT 
[aid],
[filename] 
FROM [dnt_attachments] 
WHERE [tid]	= @tid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getattachmentlistbypidlist]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getattachmentlistbypidlist]
@pidlist varchar(500)
AS
SELECT 
[aid],
[uid],
[tid],
[pid],
[postdatetime],
[readperm],
[filename],
[description],
[filetype],
[filesize],
[attachment],
[downloads],
[attachprice],
[width],
[height] 
FROM [dnt_attachments] WITH (NOLOCK)
WHERE [dnt_attachments].[pid] IN (SELECT [item]FROM [dnt_split](@pidlist, ',') )
GO
/****** Object:  StoredProcedure [dbo].[dnt_getattachmentlistbypid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getattachmentlistbypid]
@pid INT
AS
SELECT 
[aid],
[uid],
[tid],
[pid],
[postdatetime],
[readperm],
[filename],
[description],
[filetype],
[filesize],
[attachment],
[downloads],
[attachprice],
[width],
[height] 
FROM [dnt_attachments] 
WHERE [pid]=@pid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getattachmentlistbyaid]    Script Date: 06/10/2013 22:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getattachmentlistbyaid]
@aidlist varchar(500)
AS
SELECT [aid], [tid], [pid], [filename] FROM [dnt_attachments] WITH (NOLOCK) WHERE [aid] IN (SELECT [item] FROM [dnt_split](@aidlist, ',') )
GO
/****** Object:  StoredProcedure [dbo].[dnt_getattachmentcountbytid]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getattachmentcountbytid]
@tid INT
AS
SELECT COUNT([aid]) AS [acount] FROM [dnt_attachments] WHERE [tid]=@tid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getattachmentcountbypid]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getattachmentcountbypid]
@pid INT
AS
SELECT COUNT([aid]) AS [acount] FROM [dnt_attachments] WHERE [pid]=@pid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getattachenmtinfobyaid]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getattachenmtinfobyaid]
@aid INT
AS
SELECT TOP 1
[aid],
[uid],
[tid],
[pid],
[postdatetime],
[readperm],
[filename],
[description],
[filetype],
[filesize],
[attachment],
[downloads],
[attachprice],
[width],
[height] 
FROM [dnt_attachments] with (nolock)
WHERE [aid]=@aid
GO
/****** Object:  StoredProcedure [dbo].[dnt_getalltoptopiclist]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getalltoptopiclist]
AS
SELECT 
[tid],
[displayorder],
[fid] 
FROM [dnt_topics] 
WHERE [displayorder] > 0 ORDER BY [fid]
GO
/****** Object:  StoredProcedure [dbo].[dnt_getalltopiccount]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_getalltopiccount]
@fid int
AS

SELECT COUNT(tid) FROM [dnt_topics] WHERE ([fid]=@fid   OR   [fid]  IN (  SELECT fid  FROM [dnt_forums]  WHERE  CHARINDEX(',' + RTRIM(@fid) + ',', ',' + parentidlist + ',') > 0))  AND [displayorder]>=0
GO
/****** Object:  StoredProcedure [dbo].[dnt_deleteattachmentbytid]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_deleteattachmentbytid]
@tid INT
AS
DELETE FROM [dnt_attachments] WHERE [tid] = @tid
GO
/****** Object:  StoredProcedure [dbo].[dnt_deleteattachmentbypid]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_deleteattachmentbypid]
@pid INT
AS
DELETE FROM [dnt_attachments] 
WHERE [pid]=@pid
GO
/****** Object:  StoredProcedure [dbo].[dnt_deleteattachmentbyaid]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_deleteattachmentbyaid]
@aid INT
AS
DELETE FROM [dnt_attachments] 
WHERE [aid]=@aid
GO
/****** Object:  StoredProcedure [dbo].[dnt_createuser]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createuser]
@username nchar(20),
@nickname nchar(20),
@password char(32),
@secques char(8),
@gender int,
@adminid int,
@groupid smallint,
@groupexpiry int,
@extgroupids char(60),
@regip char(15),
@joindate char(19),
@lastip char(15),
@lastvisit char(19),
@lastactivity char(19),
@lastpost char(19),
@lastpostid int,
@lastposttitle nchar(60),
@posts int,
@digestposts smallint,
@oltime int,
@pageviews int,
@credits int,
@extcredits1 float,
@extcredits2 float,
@extcredits3 float,
@extcredits4 float,
@extcredits5 float,
@extcredits6 float,
@extcredits7 float,
@extcredits8 float,
@avatarshowid int,
@email char(50),
@bday char(19),
@sigstatus int,
@salt nchar(6),
@tpp int,
@ppp int,
@templateid smallint,
@pmsound int,
@showemail int,
@newsletter int,
@invisible int,
@newpm int,
@accessmasks int,
@website varchar(80),
@icq varchar(12),
@qq varchar(12),
@yahoo varchar(40),
@msn varchar(40),
@skype varchar(40),
@location nvarchar(30),
@customstatus varchar(30),
@avatar varchar(255),
@avatarwidth int,
@avatarheight int,
@medals varchar(300),
@bio nvarchar(500),
@signature nvarchar(500),
@sightml nvarchar(1000),
@authstr varchar(20),
@realname nvarchar(10),
@idcard varchar(20),
@mobile varchar(20),
@phone varchar(20)
AS
DECLARE @uid int

INSERT INTO [dnt_users]([username],[nickname], [password], [secques], [gender], [adminid], [groupid], [groupexpiry], [extgroupids], [regip], [joindate], [lastip], [lastvisit], [lastactivity], [lastpost], [lastpostid], [lastposttitle], [posts], [digestposts], [oltime], [pageviews], [credits], [extcredits1], [extcredits2], [extcredits3], [extcredits4], [extcredits5], [extcredits6], [extcredits7], [extcredits8], [avatarshowid], [email], [bday], [sigstatus], [salt], [tpp], [ppp], [templateid], [pmsound], [showemail], [newsletter], [invisible], [newpm], [accessmasks]) VALUES(@username,@nickname, @password, @secques, @gender, @adminid, @groupid, @groupexpiry, @extgroupids, @regip, @joindate, @lastip, @lastvisit, @lastactivity, @lastpost, @lastpostid, @lastposttitle, @posts, @digestposts, @oltime, @pageviews, @credits, @extcredits1, @extcredits2, @extcredits3, @extcredits4, @extcredits5, @extcredits6, @extcredits7, @extcredits8, @avatarshowid, @email, @bday, @sigstatus, @salt, @tpp, @ppp, @templateid, @pmsound, @showemail, @newsletter, @invisible, @newpm, @accessmasks)
SELECT SCOPE_IDENTITY()  AS 'userid'
SET @uid = SCOPE_IDENTITY()

IF @@ERROR=0
	BEGIN
		UPDATE [dnt_statistics] SET [totalusers]=[totalusers] + 1,[lastusername]=@username,[lastuserid]=@uid
	END

INSERT INTO dnt_userfields 
	([uid],[website],[icq],[qq],[yahoo],[msn],[skype],[location],[customstatus],[avatar],[avatarwidth],[avatarheight],[medals],[bio],[signature],[sightml],[authstr],[realname],[idcard],[mobile],[phone])
VALUES
	(@uid,@website,@icq,@qq,@yahoo,@msn,@skype,@location,@customstatus,@avatar,@avatarwidth,@avatarheight,@medals,@bio,@signature,@sightml,@authstr,@realname,@idcard,@mobile,@phone)
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateusergroup]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_updateusergroup]
@Radminid INT,
@Grouptitle NVARCHAR(50),
@Creditshigher INT,
@Creditslower INT, 
@Stars INT,
@Color CHAR(7),
@Groupavatar NVARCHAR(60),
@Readaccess INT,
@Allowvisit INT,
@Allowpost INT,
@Allowreply INT,
@Allowpostpoll INT,
@Allowdirectpost INT,
@Allowgetattach INT,
@Allowpostattach INT,
@Allowvote INT,
@Allowmultigroups INT,
@Allowsearch INT,
@Allowavatar INT,
@Allowcstatus INT,
@Allowuseblog INT,
@Allowinvisible INT,
@Allowtransfer INT,
@Allowsetreadperm INT,
@Allowsetattachperm INT,
@Allowhidecode INT,
@Allowhtml INT,
@Allowcusbbcode INT,
@Allownickname INT,
@Allowsigbbcode INT,
@Allowsigimgcode INT,
@Allowviewpro INT,
@Allowviewstats INT,
@Allowtrade INT,
@Allowdiggs INT,
@Disableperiodctrl INT,
@Allowdebate INT,
@Allowbonus INT,
@Minbonusprice INT,
@Maxbonusprice INT,
@Reasonpm INT,
@Maxprice SMALLINT,
@Maxpmnum SMALLINT,
@Maxsigsize SMALLINT,
@Maxattachsize INT,
@Maxsizeperday INT,
@Attachextensions CHAR(100),
@Maxspaceattachsize INT,
@Maxspacephotosize INT,
@Groupid INT
AS
UPDATE [dnt_usergroups]  
SET [radminid]=@Radminid,[grouptitle]=@Grouptitle,[creditshigher]=@Creditshigher,[creditslower]=@Creditslower,
[stars]=@Stars,[color]=@Color,[groupavatar]=@Groupavatar,[readaccess]=@Readaccess, 
[allowvisit]=@Allowvisit,[allowpost]=@Allowpost,[allowreply]=@Allowreply,[allowpostpoll]=@Allowpostpoll, 
[allowdirectpost]=@Allowdirectpost,[allowgetattach]=@Allowgetattach,[allowpostattach]=@Allowpostattach,
[allowvote]=@Allowvote,[allowmultigroups]=@Allowmultigroups,[allowsearch]=@Allowsearch,[allowavatar]=@Allowavatar,
[allowcstatus]=@Allowcstatus,[allowuseblog]=@Allowuseblog,[allowinvisible]=@Allowinvisible,
[allowtransfer]=@Allowtransfer,[allowsetreadperm]=@Allowsetreadperm,[allowsetattachperm]=@Allowsetattachperm,
[allowhidecode]=@Allowhidecode,[allowhtml]=@Allowhtml,[allowcusbbcode]=@Allowcusbbcode,
[allownickname]=@Allownickname,[allowsigbbcode]=@Allowsigbbcode,[allowsigimgcode]=@Allowsigimgcode,
[allowviewpro]=@Allowviewpro,[allowviewstats]=@Allowviewstats,[allowtrade]=@Allowtrade,[allowdiggs]=@Allowdiggs,
[disableperiodctrl]=@Disableperiodctrl,[allowdebate]=@Allowdebate,[allowbonus]=@Allowbonus,
[minbonusprice]=@Minbonusprice,[maxbonusprice]=@Maxbonusprice,[reasonpm]=@Reasonpm,[maxprice]=@Maxprice,
[maxpmnum]=@Maxpmnum,[maxsigsize]=@Maxsigsize,[maxattachsize]=@Maxattachsize,[maxsizeperday]=@Maxsizeperday,
[attachextensions]=@Attachextensions,[maxspaceattachsize]=@Maxspaceattachsize,
[maxspacephotosize]=@Maxspacephotosize  
WHERE [groupid]=@Groupid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateuserforumsetting]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateuserforumsetting]
	@uid int,
	@tpp int,
	@ppp int,
	@invisible int,
	@customstatus varchar(30)
AS
UPDATE [dnt_users] SET [tpp]=@tpp, [ppp]=@ppp, [invisible]=@invisible WHERE [uid]=@uid
UPDATE [dnt_userfields] SET [customstatus]=@customstatus WHERE [uid]=@uid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateusercredits]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateusercredits]
    @uid INT
    AS
    UPDATE [dnt_users] SET [credits] = extcredits1+posts+digestposts*5 WHERE [uid] = @uid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateuserauthstr]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateuserauthstr]
	@uid int,
	@authstr char(20),
	@authflag int =1
AS
UPDATE [dnt_userfields] SET [authstr]=@authstr, [authtime] = GETDATE(), [authflag]=@authflag WHERE [uid]=@uid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateuser]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateuser]
@username nchar(20),
@nickname nchar(20),
@password char(32),
@secques char(8),
@spaceid int,
@gender int,
@adminid int,
@groupid smallint,
@groupexpiry int,
@extgroupids char(60),
@regip char(15),
@joindate char(19),
@lastip char(15),
@lastvisit char(19),
@lastactivity char(19),
@lastpost char(19),
@lastpostid int,
@lastposttitle nchar(60),
@posts int,
@digestposts smallint,
@oltime int,
@pageviews int,
@credits int,
@extcredits1 float,
@extcredits2 float,
@extcredits3 float,
@extcredits4 float,
@extcredits5 float,
@extcredits6 float,
@extcredits7 float,
@extcredits8 float,
@avatarshowid int,
@email char(50),
@bday char(19),
@sigstatus int,
@tpp int,
@ppp int,
@templateid smallint,
@pmsound int,
@showemail int,
@newsletter int,
@invisible int,
@newpm int,
@newpmcount int,
@accessmasks int,
@onlinestate int,
@website varchar(80),
@icq varchar(12),
@qq varchar(12),
@yahoo varchar(40),
@msn varchar(40),
@skype varchar(40),
@location nvarchar(30),
@customstatus varchar(30),
@avatar varchar(255),
@avatarwidth int,
@avatarheight int,
@medals varchar(300),
@bio nvarchar(500),
@signature nvarchar(500),
@sightml nvarchar(1000),
@authstr varchar(20),
@authtime smalldatetime,
@authflag tinyint,
@realname nvarchar(10),
@idcard varchar(20),
@mobile varchar(20),
@phone varchar(20),
@ignorepm nvarchar(1000),
@uid int
AS

UPDATE [dnt_users] SET [username]=@username,[nickname]=@nickname, [password]=@password, [secques]=@secques, [spaceid]=@spaceid, [gender]=@gender, [adminid]=@adminid, [groupid]=@groupid, [groupexpiry]=@groupexpiry, 
[extgroupids]=@extgroupids, [regip]= @regip, [joindate]= @joindate, [lastip]=@lastip, [lastvisit]=@lastvisit, [lastactivity]=@lastactivity, [lastpost]=@lastpost, 
[lastpostid]=@lastpostid, [lastposttitle]=@lastposttitle, [posts]=@posts, [digestposts]=@digestposts, [oltime]=@oltime, [pageviews]=@pageviews, [credits]=@credits, 
[extcredits1]=@extcredits1, [extcredits2]=@extcredits2, [extcredits3]=@extcredits3, [extcredits4]=@extcredits4, [extcredits5]=@extcredits5, [extcredits6]=@extcredits6, 
[extcredits7]=@extcredits7, [extcredits8]=@extcredits8, [avatarshowid]=@avatarshowid, [email]=@email, [bday]=@bday, [sigstatus]=@sigstatus, [tpp]=@tpp, [ppp]=@ppp, 
[templateid]=@templateid, [pmsound]=@pmsound, [showemail]=@showemail, [newsletter]=@newsletter, [invisible]=@invisible, [newpm]=@newpm, [newpmcount]=@newpmcount, [accessmasks]=@accessmasks, [onlinestate]=@onlinestate 
WHERE [uid]=@uid

UPDATE [dnt_userfields] SET [website]=@website,[icq]=@icq,[qq]=@qq,[yahoo]=@yahoo,[msn]=@msn,[skype]=@skype,[location]=@location,[customstatus]=@customstatus,
[avatar]=@avatar,[avatarwidth]=@avatarwidth,[avatarheight]=@avatarheight,[medals]=@medals,[bio]=@bio,[signature]=@signature,[sightml]=@sightml,[authstr]=@authstr,
[authtime]=@authtime,[authflag]=@authflag,[realname]=@realname,[idcard]=@idcard,[mobile]=@mobile,[phone]=@phone,[ignorepm]=@ignorepm 
WHERE [uid]=@uid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updatetopicviewcount]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updatetopicviewcount]
@tid int,
@viewcount int
AS
UPDATE [dnt_topics]  SET [views]= [views] + @viewcount WHERE [tid]=@tid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updatetopicposter]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updatetopicposter]
@poster NVARCHAR(20),
@posterid INT
AS
UPDATE [dnt_topics] 
SET [poster]=@poster 
WHERE [posterid]=@posterid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updatetopiclastposterid]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_updatetopiclastposterid]
@tid INT
AS
UPDATE [dnt_topics] 
SET [lastposterid]=(SELECT ISNULL(MIN(lastpostid), -1)-1 FROM [dnt_topics] WHERE [tid] = @tid)
GO
/****** Object:  StoredProcedure [dbo].[dnt_updatetopic]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updatetopic]
	@tid int,
	@fid smallint,
	@iconid smallint,
	@title nchar(60),
	@typeid smallint,
	@readperm int,
	@price smallint,
	@poster char(20),
	@posterid int,
	@postdatetime smalldatetime,
	@lastpostid int,
	@lastpost smalldatetime,
	@lastposter char(20),
	@replies int,
	@displayorder int,
	@highlight varchar(500),
	@digest int,
	@rate int,
	@hide int,
	@special int,
	@attachment int,
	@moderated int,
	@closed int,
	@magic int
AS
UPDATE [dnt_topics] SET
	[fid]=@fid,
	[iconid]=@iconid,
	[title]=@title,
	[typeid]=@typeid,
	[readperm]=@readperm,
	[price]=@price,
	[poster]=@poster,
	[posterid]=@posterid,
	[postdatetime]=@postdatetime,
	[lastpostid]=@lastpostid,
	[lastpost]=@lastpost,
	[lastposter]=@lastposter,
	[replies]=@replies,
	[displayorder]=@displayorder,
	[highlight]=@highlight,
	[digest]=@digest,
	[rate]=@rate,
	[hide]=@hide,
	[special]=@special,
	[attachment]=@attachment,
	[moderated]=@moderated,
	[closed]=@closed,
	[magic]=@magic WHERE [tid]=@tid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updatepostposter]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updatepostposter]
@poster NVARCHAR(20),
@posterid INT
AS
DECLARE @count INT,
		@begin INT,
		@tableid INT
SET @begin = 1
DECLARE @tempposttable TABLE 
						(
							[ROWID] INT IDENTITY(1,1),
							[tableid] INT
						)
INSERT INTO @tempposttable 
SELECT id FROM dnt_tablelist
SELECT @count=COUNT(1) FROM @tempposttable
WHILE @begin <= @count
BEGIN
	SELECT  @tableid = [tableid] FROM @tempposttable WHERE [ROWID] = @begin
	EXEC('UPDATE [dnt_posts' + @tableid + '] SET [poster]=''' + @poster + ''' WHERE [posterid]=' + @posterid )
	SET @begin = @begin + 1
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_updatepost1]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updatepost1]
                        @pid int,
                        @title nvarchar(160),
                        @message ntext,
                        @lastedit nvarchar(50),
                        @invisible int,
                        @usesig int,
                        @htmlon int,
                        @smileyoff int,
                        @bbcodeoff int,
                        @parseurloff int
                    AS
                    UPDATE dnt_posts1 SET 
                        [title]=@title,
                        [message]=@message,
                        [lastedit]=@lastedit,
                        [invisible]=@invisible,
                        [usesig]=@usesig,
                        [htmlon]=@htmlon,
                        [smileyoff]=@smileyoff,
                        [bbcodeoff]=@bbcodeoff,

                        [parseurloff]=@parseurloff WHERE [pid]=@pid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateorderinfo]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateorderinfo]
@orderid int,
@tradeno char(32),
@orderstatus tinyint,
@confirmedtime smalldatetime
AS
BEGIN
    UPDATE [dnt_orders] SET [tradeno]=@tradeno,[orderstatus]=@orderstatus,[confirmedtime]=@confirmedtime WHERE [orderid]=@orderid
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateonlinelist]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_updateonlinelist]
@title NVARCHAR(50),
@groupid INT
AS
UPDATE [dnt_onlinelist] SET [title]=@title WHERE [groupid]=@groupid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateonlineaction]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateonlineaction] 
@action smallint,
@lastupdatetime datetime,
@forumid int,
@forumname nvarchar(100),
@titleid int,
@title nvarchar(160),
@olid int
AS

IF (@action =5 OR @action =6)
BEGIN
   UPDATE [dnt_online] SET [lastactivity]=[action],[action]=@action,[lastupdatetime]=@lastupdatetime,[lastposttime]= @lastupdatetime,[forumid]=@forumid,[forumname]=@forumname,[titleid]=@titleid,[title]=@title WHERE [olid]=@olid
END
ELSE
BEGIN
   UPDATE [dnt_online] SET [lastactivity]=[action],[action]=@action,[lastupdatetime]=@lastupdatetime,[forumid]=@forumid,[forumname]=@forumname,[titleid]=@titleid,[title]=@title WHERE [olid]=@olid
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_updatemytopic]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_updatemytopic]
AS
DELETE FROM [dnt_mytopics]
INSERT INTO [dnt_mytopics]([uid], [tid], [dateline]) 
SELECT [posterid],[tid],[postdatetime] 
FROM [dnt_topics] 
WHERE [posterid]<>-1
GO
/****** Object:  StoredProcedure [dbo].[dnt_updatemypost]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_updatemypost]
@tablename VARCHAR(50)
AS
DELETE FROM [dnt_myposts]
EXEC ('
		INSERT INTO [dnt_myposts]([uid], [tid], [pid], [dateline])
		SELECT [posterid],[tid],[pid],[postdatetime] FROM [' + @tablename + '] WHERE [posterid]<>-1
	')
GO
/****** Object:  StoredProcedure [dbo].[dnt_updatemoderatorname]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_updatemoderatorname]
@oldname NVARCHAR(20),
@newname VARCHAR(20)
AS
IF @newname <> ''
	UPDATE dnt_forumfields 
	SET MODERATORS=REPLACE(LTRIM(RTRIM(REPLACE(' '+REPLACE(CONVERT(NVARCHAR(500),MODERATORS),',',' ')+' ',' '+@oldname+' ',' '+@newname+' '))),' ',',')
	WHERE CHARINDEX(','+@oldname+',',','+CONVERT(NVARCHAR(500),MODERATORS)+',') > 0
ELSE
	UPDATE dnt_forumfields 
	SET MODERATORS = REPLACE(LTRIM(RTRIM(REPLACE(REPLACE(','+CONVERT(NVARCHAR(500),MODERATORS)+',',','+@oldname+',',','),',',' '))),' ',',')
	WHERE CHARINDEX(','+@oldname+',',','+CONVERT(NVARCHAR(500),MODERATORS)+',') > 0
GO
/****** Object:  StoredProcedure [dbo].[dnt_updatelastpostoftopic]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_updatelastpostoftopic]
@tid INT,
@postcount INT,
@lastpostid INT,
@lastpost VARCHAR(20),
@lastposterid INT,
@lastposter VARCHAR(20)
AS
UPDATE [dnt_topics] 
SET [lastpost]=@lastpost, [lastposterid]=@lastposterid, [lastposter]=@lastposter, [replies]=@postcount, [lastpostid]=@lastpostid 
WHERE [tid] = @tid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateinvitecodesuccesscount]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateinvitecodesuccesscount]
@id int
AS
BEGIN
UPDATE [dnt_invitation] SET [successcount]=[successcount]+1 WHERE [inviteid]=@id
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateforumsmoderators]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_updateforumsmoderators]
@displayorder INT,
@moderators VARCHAR(500),
@fid INT,
@inherited INT
AS
DECLARE @usernamelist VARCHAR(255),
		@username VARCHAR(255),
		@uid INT,
		@len INT,
		@b BIT,
		@begin INT,
		@end INT
SELECT @len=0,@begin=1,@end=1,@b=1,@usernamelist=''
WHILE @b=1
	BEGIN
		IF @end=1
			SET @begin=@end
		ELSE
			SET @begin=@end+1
		SET @end = CHARINDEX(',',@moderators,@begin)
		IF @end=0
			SET @end=LEN(@moderators)+1
		SET @len=@end-@begin
		IF @len>0
			BEGIN
				SET @username=SUBSTRING(@moderators,@begin,@len)
				IF @username<>''
					BEGIN
						SELECT @uid=[uid] FROM [dnt_users] WHERE [groupid]<>7 AND [groupid]<>8 AND [username]=@username
						IF @uid IS NOT NULL
							BEGIN
								INSERT INTO [dnt_moderators] ([uid],[fid],[displayorder],[inherited]) VALUES (@uid,@fid,@displayorder,@inherited)
								SET @usernamelist=@usernamelist+@username+','
								SET @displayorder=@displayorder+1
								SET @uid=NULL
							END
					END
			END
		ELSE
			SET @b=0
	END
IF RIGHT(@usernamelist,1)=','
	SET @usernamelist=LEFT(@usernamelist,LEN(@usernamelist)-1)
UPDATE [dnt_forumfields] SET [moderators]=@usernamelist WHERE [fid] =@fid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateforumsinfo]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_updateforumsinfo]
@parentid SmallInt,
@layer Int,
@pathlist NChar(3000),
@parentidlist NChar(300),
@subforumcount Int,
@name NChar(50),
@status Int,
@colcount SmallInt,
@displayorder Int,
@templateid SmallInt,
@topics Int,
@curtopics Int,
@posts Int,
@todayposts Int,
@lasttid Int,
@lasttitle NChar(60),
@lastpost DateTime,
@lastposterid Int,
@lastposter NChar(20),
@allowsmilies Int,
@allowrss Int,
@allowhtml Int,
@allowbbcode Int,
@allowimgcode Int,
@allowblog Int,
@istrade Int,
@allowpostspecial Int,
@allowspecialonly Int,
@alloweditrules Int,
@allowthumbnail Int,
@allowtag Int,
@recyclebin Int,
@modnewposts Int,
@jammer Int,
@disablewatermark Int,
@inheritedmod Int,
@autoclose SmallInt,
@password NVarChar(16),
@icon VarChar(255),
@postcredits VarChar(255),
@replycredits VarChar(255),
@redirect VarChar(255),
@attachextensions VarChar(255),
@rules NText,
@topictypes Text,
@viewperm Text,
@postperm Text,
@replyperm Text,
@getattachperm Text,
@postattachperm Text,
@moderators Text,
@description NText,
@applytopictype TinyInt,
@postbytopictype TinyInt,
@viewbytopictype TinyInt,
@topictypeprefix TinyInt,
@permuserlist NText,
@seokeywords NVarChar(500),
@seodescription NVarChar(500),
@rewritename NVarChar(20),
@fid Int

AS
UPDATE [dnt_forums] 
SET [parentid]=@parentid, [layer]=@layer, [pathlist]=@pathlist, 
[parentidlist]=@parentidlist, [subforumcount]=@subforumcount, [name]=@name, [status]=@status,
[colcount]=@colcount, [displayorder]=@displayorder,[templateid]=@templateid,[topics]=@topics,
[curtopics]=@curtopics,[posts]=@posts,[todayposts]=@todayposts,[lasttid]=@lasttid,[lasttitle]=@lasttitle,
[lastpost]=@lastpost,[lastposterid]=@lastposterid,[lastposter]=@lastposter,
[allowsmilies]=@allowsmilies ,[allowrss]=@allowrss, [allowhtml]=@allowhtml, [allowbbcode]=@allowbbcode, [allowimgcode]=@allowimgcode, 
[allowblog]=@allowblog,[istrade]=@istrade,[allowpostspecial]=@allowpostspecial,[allowspecialonly]=@allowspecialonly,
[alloweditrules]=@alloweditrules ,[allowthumbnail]=@allowthumbnail ,[allowtag]=@allowtag,
[recyclebin]=@recyclebin, [modnewposts]=@modnewposts,[jammer]=@jammer,[disablewatermark]=@disablewatermark,[inheritedmod]=@inheritedmod,
[autoclose]=@autoclose 
WHERE [fid]=@fid

UPDATE [dnt_forumfields] 
SET [password]=@password,[icon]=@icon,[postcredits]=@postcredits,
 [replycredits]=@replycredits,[redirect]=@redirect,[attachextensions]=@attachextensions,[rules]=@rules,[topictypes]=@topictypes,
 [viewperm]=@viewperm,[postperm]=@postperm,[replyperm]=@replyperm,[getattachperm]=@getattachperm,[postattachperm]=@postattachperm,
 [moderators]=@moderators,[description]=@description,[applytopictype]=@applytopictype,[postbytopictype]=@postbytopictype,
 [viewbytopictype]=@viewbytopictype,[topictypeprefix]=@topictypeprefix,[permuserlist]=@permuserlist,[seokeywords]=@seokeywords,
 [seodescription]=@seodescription,[rewritename]=@rewritename 
 WHERE [fid]=@fid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateforum]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_updateforum]
@lastfid INT,
@topiccount INT,
@postcount INT,
@lasttid INT,
@lasttitle NCHAR(80),
@lastpost VARCHAR(20),
@lastposterid INT,
@lastposter NCHAR(20),
@todaypostcount INT 
AS
UPDATE [dnt_forums] 
SET [topics] = @topiccount, [posts]=@postcount, [todayposts] = @todaypostcount, [lasttid] = @lasttid, [lasttitle] = @lasttitle, [lastpost]=@lastpost, [lastposterid] = @lastposterid, [lastposter]=@lastposter 
WHERE [dnt_forums].[fid] = @lastfid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateattachmenttidtoanothertopic]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateattachmenttidtoanothertopic]
@tid INT,
@oldtid INT
AS
UPDATE [dnt_attachments] SET [tid]=@tid WHERE [tid]=@oldtid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateattachmentinfo]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateattachmentinfo]
@readperm INT,
@description NCHAR(100),
@aid INT
AS
UPDATE [dnt_attachments] 
SET [readperm] = @readperm, [description] = @description 
WHERE [aid] = @aid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateattachmentdownloads]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateattachmentdownloads]
@aid INT
AS
UPDATE [dnt_attachments] SET [downloads]=[downloads]+1 WHERE [aid]=@aid;

UPDATE  [dnt_myattachments]
SET    [downloads] = (SELECT [downloads] FROM [dnt_attachments] WHERE [dnt_attachments].aid = @aid)
WHERE  [aid]=@aid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateattachment]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateattachment]
@readperm INT,
@description NCHAR(100),
@attachprice INT,
@aid INT
AS
UPDATE [dnt_attachments] 
SET [readperm] = @readperm, [description] = @description, [attachprice] = @attachprice 
WHERE [aid] = @aid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateallfieldattachmentinfo]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateallfieldattachmentinfo]
@postdatetime DATETIME,
@readperm INT,
@filename NCHAR(100),
@filetype NCHAR(50),
@description NCHAR(100),
@filesize INT,
@attachment NCHAR(100),
@downloads INT,
@tid INT,
@pid INT,
@aid INT,
@attachprice INT,
@width INT,
@height INT
AS
UPDATE [dnt_attachments] 
SET 
[postdatetime] = @postdatetime, 
[readperm] = @readperm, 
[filename] = @filename, 
[description] = @description, 
[filetype] = @filetype, 
[filesize] = @filesize, 
[attachment] = @attachment, 
[downloads] = @downloads, 
[tid]=@tid, 
[pid]=@pid, 
[attachprice]=@attachprice, 
[width]=@width, 
[height]=@height 
WHERE [aid]=@aid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateadmingroup]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateadmingroup]
	@admingid smallint,
	@alloweditpost tinyint,
	@alloweditpoll tinyint,
	@allowstickthread tinyint,
	@allowmodpost tinyint,
	@allowdelpost tinyint,
	@allowmassprune tinyint,
	@allowrefund tinyint,
	@allowcensorword tinyint,
	@allowviewip tinyint,
	@allowbanip tinyint,
	@allowedituser tinyint,
	@allowmoduser tinyint,
	@allowbanuser tinyint,
	@allowpostannounce tinyint,
	@allowviewlog tinyint,
	@disablepostctrl tinyint,
	@allowviewrealname tinyint
AS
UPDATE [dnt_admingroups] SET 
	[alloweditpost]=@alloweditpost,
	[alloweditpoll]=@alloweditpoll,
	[allowstickthread]=@allowstickthread,
	[allowmodpost]=@allowmodpost,
	[allowdelpost]=@allowdelpost,
	[allowmassprune]=@allowmassprune,
	[allowrefund]=@allowrefund,
	[allowcensorword]=@allowcensorword,
	[allowviewip]=@allowviewip,
	[allowbanip]=@allowbanip,
	[allowedituser]=@allowedituser,
	[allowmoduser]=@allowmoduser,
	[allowbanuser]=@allowbanuser,
	[allowpostannounce]=@allowpostannounce,
	[allowviewlog]=@allowviewlog,
	[disablepostctrl]=@disablepostctrl,
	[allowviewrealname]=@allowviewrealname
WHERE [admingid]=@admingid
GO
/****** Object:  StoredProcedure [dbo].[dnt_resetlastpostinfo]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_resetlastpostinfo]
AS
--ʱ#tempTable1#tempTable2
CREATE TABLE #tempTable1 (
							fid INT,
							lasttid INT,
							lasttitle NVARCHAR(60),
							lastpost DATETIME,
							parentid INT,
							lastposterid INT,
							lastposter NVARCHAR(30)
						 )

CREATE table #tempTable2 (
							fid INT,
							lasttid INT,
							lasttitle NVARCHAR(60),
							lastpost DATETIME,
							parentid INT,
							lastposterid INT,
							lastposter NVARCHAR(30)
						)
DECLARE @maxlayer INT  -- layerı
SELECT @maxlayer = MAX(layer) FROM dnt_forums;
--ȳʼdnt_forumsȵϢ
UPDATE dnt_forums SET lasttid = 0, lasttitle = 'δ',lastpost = '1900-1-1',lastposterid=0,lastposter=''
--İ˵Ϣ
UPDATE dnt_forums 
SET lasttid = rightTable.tid, lasttitle = rightTable.title, lastpost = rightTable.lastpost, lastposterid=rightTable.lastposterid, lastposter=rightTable.lastposter
FROM dnt_forums AS leftTable
INNER JOIN (SELECT fid,tid,title,lastpost,lastposter,lastposterid FROM dnt_topics WHERE tid IN( SELECT MAX(tid) FROM dnt_topics GROUP BY fid)) AS rightTable
ON leftTable.fid = rightTable.fid
WHERE leftTable.fid = rightTable.fid

WHILE @maxlayer > 0
BEGIN
	--ʱ#tempTable1Ϊ˱֤ڶѭʱǿյ
	DELETE FROM #tempTable1;
	--dnt_forumsеparentidֶη飬ѯÿظʱļ¼
	--ȻLEFT JOINdnt_forumsparentidȲlastpostΪвѯ
	--ѽ뵽ʱ#tempTable1УԱʱ#tempTable2
	INSERT INTO #tempTable1 
				SELECT fid,lasttid,lasttitle,a.lastpost,a.parentid,a.lastposterid,a.lastposter 
				FROM (
						SELECT parentid,MAX(lastpost) lastpost FROM dnt_forums a WHERE layer = @maxlayer GROUP BY parentid
					 ) b 
				LEFT JOIN dnt_forums a
				ON a.parentid=b.parentid and a.lastpost=b.lastpost						

	--ʱ#tempTable2Ϊ˱֤ڶѭʱǿյ
	DELETE FROM #tempTable2;
	--#tempTable1еparentid飬ѯеMAX(fid)
	--Ȼfid IN ӲѯвMAX(fid)Ϊѯ뵽#tempTable2
	INSERT INTO #tempTable2 
				SELECT * FROM #tempTable1
				WHERE fid IN (SELECT MAX(fid) FROM #tempTable1 GROUP BY parentid,lastpost)
	--ʱ#tempTable2еݣdnt_forums˵Ϣ
	UPDATE dnt_forums 
	SET lastpost = CASE WHEN #tempTable2.lastpost>dnt_forums.lastpost THEN #tempTable2.lastpost
				   ELSE dnt_forums.lastpost END,
		lasttitle = CASE WHEN #tempTable2.lastpost>dnt_forums.lastpost THEN #tempTable2.lasttitle
					ELSE dnt_forums.lasttitle END,
		lasttid = CASE WHEN #tempTable2.lastpost>dnt_forums.lastpost THEN #tempTable2.lasttid
					ELSE dnt_forums.lasttid END,
		lastposterid = CASE WHEN #tempTable2.lastpost>dnt_forums.lastpost THEN #tempTable2.lastposterid
					ELSE dnt_forums.lastposterid END,
		lastposter = CASE WHEN #tempTable2.lastpost>dnt_forums.lastpost THEN #tempTable2.lastposter
					ELSE dnt_forums.lastposter END			
	FROM dnt_forums 
	INNER JOIN #tempTable2 
	ON dnt_forums.fid=#tempTable2.parentid 
	WHERE dnt_forums.fid=#tempTable2.parentid;
	SET @maxlayer = @maxlayer - 1;
END
DROP TABLE #tempTable2;
DROP TABLE #tempTable1;
GO
/****** Object:  StoredProcedure [dbo].[dnt_resetforumstopics]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_resetforumstopics]
AS
--а,Ӱ
UPDATE dnt_forums 
		SET curtopics=ISNULL(rightTable.sumtopics,0),topics = ISNULL(rightTable.sumtopics,0)
		FROM dnt_forums 
		INNER JOIN (SELECT fid,COUNT(tid) sumtopics FROM dnt_topics GROUP BY fid) AS rightTable
		ON dnt_forums.fid=rightTable.fid
		WHERE dnt_forums.fid=rightTable.fid

DECLARE @maxlayer INT
SELECT @maxlayer = MAX(layer) FROM dnt_forums


--£ײµ
WHILE @maxlayer > 0
BEGIN
	--ӰеۼӲµ
	UPDATE dnt_forums 
	SET topics=topics+ISNULL(rightTable.sumtopics,0) 
	FROM dnt_forums AS leftTable 
	INNER JOIN (SELECT parentid,SUM(topics) sumtopics FROM dnt_forums WHERE layer=@maxlayer GROUP BY parentid) AS rightTable
	ON leftTable.fid=rightTable.parentid
	WHERE leftTable.fid=rightTable.parentid
	SET @maxlayer = @maxlayer - 1
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_resetforumsposts]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_resetforumsposts]
AS
--forumsеԱͳ
UPDATE dnt_forums SET posts=0
DECLARE @i INT,
		@maxlayer INT,
		@maxtableid INT,
		@tablename NVARCHAR(50)
SET @i = 1
--ȡֱ
SELECT @maxtableid = MAX(id) FROM dnt_tablelist
--δֱ
WHILE @i <= @maxtableid
BEGIN
	SET @tablename = 'dnt_posts' + CONVERT(NVARCHAR(2),@i)
	--ֱһ
	IF NOT EXISTS(SELECT * FROM SYSOBJECTS WHERE id = OBJECT_ID(@tablename) AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
		CONTINUE
	--ȡÿڵǰֱеۼӲforumsа
	EXEC('
		UPDATE dnt_forums 
		SET posts=posts+rightTable.fidcount 
		FROM dnt_forums 
		INNER JOIN (SELECT fid,COUNT(fid) fidcount FROM '+ @tablename +' GROUP BY fid) AS rightTable
		ON dnt_forums.fid=rightTable.fid
		WHERE dnt_forums.fid=rightTable.fid
		')
	SET @i = @i + 1
END

--²ӰеۼӲµ
--ȡð
SELECT @maxlayer = MAX(layer) FROM dnt_forums
--£ײµ
WHILE @maxlayer > 0
BEGIN
	--ӰеۼӲµ
	UPDATE dnt_forums 
	SET posts=posts+rightTable.sumposts 
	FROM dnt_forums AS leftTable 
	INNER JOIN (SELECT parentid,SUM(posts) sumposts FROM dnt_forums WHERE layer=@maxlayer GROUP BY parentid) AS rightTable
	ON leftTable.fid=rightTable.parentid
	WHERE leftTable.fid=rightTable.parentid
	SET @maxlayer = @maxlayer - 1
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_resetclearmove]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_resetclearmove]
AS
DELETE FROM [dnt_topics] WHERE [closed] > 1
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopiclist]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gettopiclist]
@fid int,
@pagesize int,
@startnum int,
@pageindex int
AS
DECLARE @startRow int,
		@endRow int
SET @startRow = (@pageindex - 1) * @pagesize + 1 - @startnum
SET @endRow = @startRow + @pagesize -1

SELECT 
[TOPICS].[rate], 
[TOPICS].[tid],
[TOPICS].[iconid],
[TOPICS].[typeid],
[TOPICS].[title],
[TOPICS].[price],
[TOPICS].[hide],
[TOPICS].[readperm],
[TOPICS].[poster],
[TOPICS].[posterid],
[TOPICS].[replies],
[TOPICS].[views],
[TOPICS].[postdatetime],
[TOPICS].[lastpost],
[TOPICS].[lastposter],
[TOPICS].[lastpostid],
[TOPICS].[lastposterid],
[TOPICS].[highlight],
[TOPICS].[digest],
[TOPICS].[displayorder],
[TOPICS].[attachment],
[TOPICS].[closed],
[TOPICS].[magic],
[TOPICS].[special] 
FROM(SELECT ROW_NUMBER() OVER(ORDER BY [lastpostid] DESC)AS ROWID,
[dnt_topics].[rate], 
[dnt_topics].[tid],
[dnt_topics].[iconid],
[dnt_topics].[typeid],
[dnt_topics].[title],
[dnt_topics].[price],
[dnt_topics].[hide],
[dnt_topics].[readperm],
[dnt_topics].[poster],
[dnt_topics].[posterid],
[dnt_topics].[replies],
[dnt_topics].[views],
[dnt_topics].[postdatetime],
[dnt_topics].[lastpost],
[dnt_topics].[lastposter],
[dnt_topics].[lastpostid],
[dnt_topics].[lastposterid],
[dnt_topics].[highlight],
[dnt_topics].[digest],
[dnt_topics].[displayorder],
[dnt_topics].[attachment],
[dnt_topics].[closed],
[dnt_topics].[magic],
[dnt_topics].[special] 
FROM [dnt_topics]
WHERE [fid]=@fid AND [displayorder]=0) AS TOPICS
WHERE ROWID BETWEEN @startRow AND @endRow
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopicinfo]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gettopicinfo]
@tid int,
@fid int,
@mode int
AS
IF @mode = 1
	BEGIN
       SELECT TOP 1 [tid]
      ,[fid]
      ,[iconid]
      ,[readperm]
      ,[price]
      ,[poster]
      ,[posterid]
      ,[title]
      ,[postdatetime]
      ,[lastpost]
      ,[lastpostid]
      ,[lastposter]
      ,[lastposterid]
      ,[views]
      ,[replies]
      ,[displayorder]
      ,[highlight]
      ,[digest]
      ,[hide]
      ,[attachment]
      ,[moderated]
      ,[closed]
      ,[magic]
      ,[identify]
      ,[special]
      ,[typeid]
      ,[rate]
      ,[attention] FROM [dnt_topics] WITH (NOLOCK) WHERE [fid]=@fid AND [tid]<@tid AND [displayorder]>=0 ORDER BY [tid] DESC
	END
ELSE IF @mode = 2
	BEGIN
       SELECT TOP 1 [tid]
      ,[fid]
      ,[iconid]
      ,[readperm]
      ,[price]
      ,[poster]
      ,[posterid]
      ,[title]
      ,[postdatetime]
      ,[lastpost]
      ,[lastpostid]
      ,[lastposter]
      ,[lastposterid]
      ,[views]
      ,[replies]
      ,[displayorder]
      ,[highlight]
      ,[digest]
      ,[hide]
      ,[attachment]
      ,[moderated]
      ,[closed]
      ,[magic]
      ,[identify]
      ,[special]
      ,[typeid]
      ,[rate]
      ,[attention] FROM [dnt_topics] WITH (NOLOCK) WHERE [fid]=@fid AND [tid]>@tid AND [displayorder]>=0 ORDER BY [tid] ASC
	END
ELSE
	BEGIN
       SELECT TOP 1 [tid]
      ,[fid]
      ,[iconid]
      ,[readperm]
      ,[price]
      ,[poster]
      ,[posterid]
      ,[title]
      ,[postdatetime]
      ,[lastpost]
      ,[lastpostid]
      ,[lastposter]
      ,[lastposterid]
      ,[views]
      ,[replies]
      ,[displayorder]
      ,[highlight]
      ,[digest]
      ,[hide]
      ,[attachment]
      ,[moderated]
      ,[closed]
      ,[magic]
      ,[identify]
      ,[special]
      ,[typeid]
      ,[rate]
      ,[attention] FROM [dnt_topics] WITH (NOLOCK) WHERE [tid]=@tid
	END
GO
/****** Object:  StoredProcedure [dbo].[dnt_insertforumsinfo]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_insertforumsinfo]
@parentid SmallInt,
@layer Int,
@pathlist NChar(3000),
@parentidlist NChar(300),
@subforumcount Int,
@name NChar(50),
@status Int,
@colcount SmallInt,
@displayorder Int,
@templateid SmallInt,
@allowsmilies Int,
@allowrss Int,
@allowhtml Int,
@allowbbcode Int,
@allowimgcode Int,
@allowblog Int,
@istrade Int,
@alloweditrules Int,
@allowthumbnail Int,
@allowtag Int,
@recyclebin Int,
@modnewposts Int,
@jammer Int,
@disablewatermark Int,
@inheritedmod Int,
@autoclose SmallInt,
@allowpostspecial Int,
@allowspecialonly Int,
@description NText,
@password VarChar(16),
@icon VarChar(255),
@postcredits VarChar(255),
@replycredits VarChar(255),
@redirect VarChar(255),
@attachextensions VarChar(255),
@moderators Text,
@rules NText,
@topictypes Text,
@viewperm Text,
@postperm Text,
@replyperm Text,
@getattachperm Text,
@postattachperm Text,
@seokeywords NVarChar(500),
@seodescription NVarChar(500),
@rewritename NVarChar(20)
AS
DECLARE @fid INT

INSERT INTO [dnt_forums] ([parentid],[layer],[pathlist],[parentidlist],[subforumcount],[name],
[status],[colcount],[displayorder],[templateid],[allowsmilies],[allowrss],[allowhtml],[allowbbcode],[allowimgcode],[allowblog],
[istrade],[alloweditrules],[recyclebin],[modnewposts],[jammer],[disablewatermark],[inheritedmod],[autoclose],[allowthumbnail],
[allowtag],[allowpostspecial],[allowspecialonly]) 
VALUES (@parentid,@layer,@pathlist,@parentidlist,@subforumcount,@name,@status, @colcount, @displayorder,
@templateid,@allowsmilies,@allowrss,@allowhtml,@allowbbcode,@allowimgcode,@allowblog,@istrade,@alloweditrules,@recyclebin,
@modnewposts,@jammer,@disablewatermark,@inheritedmod,@autoclose,@allowthumbnail,@allowtag,@allowpostspecial,@allowspecialonly)
--SET @fid=@@IDENTITY
SELECT @fid = ISNULL(MAX(fid), 0) FROM [dnt_forums]

INSERT INTO [dnt_forumfields] ([fid],[description],[password],[icon],[postcredits],[replycredits],[redirect],
[attachextensions],[moderators],[rules],[topictypes],[viewperm],[postperm],[replyperm],[getattachperm],[postattachperm],[seokeywords],[seodescription],[rewritename]) 
VALUES (@fid,@description,@password,@icon,@postcredits,@replycredits,@redirect,@attachextensions,@moderators,@rules,@topictypes,@viewperm,
@postperm,@replyperm,@getattachperm,@postattachperm,@seokeywords,@seodescription,@rewritename)
GO
/****** Object:  StoredProcedure [dbo].[dnt_passpost]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_passpost]
@currentPostTableId INT,
@postcount INT,
@pidList NVARCHAR(500)
AS
DECLARE @count INT,
		@begin INT,
		@postdatetime DATETIME,
		@poster NVARCHAR(50),
		@posterid INT,
		@fid INT,
		@title NVARCHAR(20),
		@tid INT
		 
SET @begin=1
EXEC('UPDATE  [dnt_posts'+@currentPostTableId+']   SET [invisible]=0 WHERE [pid] IN ('+@pidList+')')
UPDATE  [dnt_statistics] SET [totalpost]= [totalpost] + @postcount

DECLARE @tempposttable TABLE 
						(
							[ROWID] INT IDENTITY(1,1),
							[postdatetime] DATETIME,
							[poster] NVARCHAR(50),
							[posterid] INT,
							[fid] INT,
							[title] NVARCHAR(20),
							[tid] INT
						)
INSERT INTO @tempposttable 
EXEC('SELECT [postdatetime],[poster],[posterid],[fid],[title],[tid] FROM [dnt_posts'+@currentPostTableId+'] WHERE [pid] IN ('+@pidList+')')
SELECT @count=COUNT(1) FROM @tempposttable
WHILE @begin <= @count
BEGIN
	SELECT @postdatetime = [postdatetime],
			@poster = [poster],
			@posterid = [posterid],
			@fid = [fid],
			@title = [title],
			@tid = [tid]
	FROM @tempposttable
	UPDATE [dnt_forums] 
	SET [posts]=[posts] + 1, 
	[todayposts]=CASE WHEN datediff(day,'2008-10-22',getdate())=0 
	THEN [todayposts] + 1	
	ELSE [todayposts] END,
	[lastpost]=@postdatetime,
	[lastposter]=@poster,
	[lastposterid]=@posterid 
	WHERE [fid]=@fid
	
	UPDATE [dnt_users] 
	SET [lastpost] = @postdatetime, 
	[lastpostid] = @posterid, 
	[lastposttitle] = @title, 
	[posts] = [posts] + 1  
	WHERE [uid] = @posterid
	
	UPDATE [dnt_topics] 
	SET [replies]=[replies]+1,
	[lastposter]=@poster,
	[lastposterid]=@posterid,
	[lastpost]=@postdatetime 
	WHERE [tid]=@tid
	
	SET @begin = @begin + 1
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateuserprofile]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateuserprofile]
	@uid int,
	@nickname nchar(20),
	@gender int,
	@email char(50),
	@bday char(10),
	@showemail int,
	@website nvarchar(80),
	@icq varchar(12),
	@qq varchar(12),
	@yahoo varchar(40),
	@msn varchar(40),
	@skype varchar(40),
	@location nvarchar(30),
	@bio nvarchar(500),
	@signature nvarchar(500),
	@sigstatus int,
	@sightml nvarchar(1000),
	@realname nvarchar(10),
	@idcard varchar(20),
	@mobile varchar(20),
	@phone varchar(20)
AS
UPDATE [dnt_users] SET [nickname]=@nickname, [gender]=@gender , [email]=@email , [bday]=@bday, [sigstatus]=@sigstatus, [showemail]=@showemail WHERE [uid]=@uid
UPDATE [dnt_userfields] SET [website]=@website , [icq]=@icq , [qq]=@qq , [yahoo]=@yahoo , [msn]=@msn , [skype]=@skype , [location]=@location , [bio]=@bio, [signature]=@signature, [sightml]=@sightml, [realname]=@realname,[idcard]=@idcard,[mobile]=@mobile,[phone]=@phone  WHERE [uid]=@uid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateuserpreference]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateuserpreference]
	@uid int,
	@avatar varchar(255),
	@avatarwidth int,
	@avatarheight int,
	@templateid int
AS
UPDATE [dnt_userfields] SET [avatar]=@avatar, [avatarwidth]=@avatarwidth, [avatarheight]=@avatarheight WHERE [uid]=@uid
UPDATE [dnt_users] SET [templateid]=@templateid WHERE [uid]=@uid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateuserpostcount]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_updateuserpostcount]
@postcount INT,
@userid INT
AS
UPDATE [dnt_users] SET [posts]=@postcount WHERE [dnt_users].[uid] = @userid
GO
/****** Object:  StoredProcedure [dbo].[dnt_updateuserpassword]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_updateuserpassword]
	@uid int,
	@password char(44)
AS
UPDATE [dnt_users] SET [password]=@password WHERE [uid]=@uid
GO
/****** Object:  Table [dbo].[mry_businesscoupon]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_businesscoupon](
	[couponid] [int] IDENTITY(1,1) NOT NULL,
	[buid] [int] NULL,
	[startdate] [datetime] NULL,
	[enddate] [datetime] NULL,
	[title] [nvarchar](255) NULL,
	[picurl] [nvarchar](50) NULL,
	[enabled] [bit] NULL,
 CONSTRAINT [PK_MRY_BUSINESSCOUPON] PRIMARY KEY CLUSTERED 
(
	[couponid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Żȯ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businesscoupon', @level2type=N'COLUMN',@level2name=N'couponid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼ұ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businesscoupon', @level2type=N'COLUMN',@level2name=N'buid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ʼ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businesscoupon', @level2type=N'COLUMN',@level2name=N'startdate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businesscoupon', @level2type=N'COLUMN',@level2name=N'enddate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Żݾ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businesscoupon', @level2type=N'COLUMN',@level2name=N'title'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ŻȯͼƬַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businesscoupon', @level2type=N'COLUMN',@level2name=N'picurl'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ч״̬' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businesscoupon', @level2type=N'COLUMN',@level2name=N'enabled'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼ҵŻȯ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businesscoupon'
GO
/****** Object:  Table [dbo].[mry_businessalbum]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_businessalbum](
	[albumid] [int] IDENTITY(1,1) NOT NULL,
	[buid] [int] NULL,
	[albumname] [nvarchar](20) NULL,
	[picurl] [nvarchar](50) NULL,
	[photocount] [int] NULL,
	[cid] [int] NULL,
	[grade] [smallint] NULL,
 CONSTRAINT [PK_MRY_BUSINESSALBUM] PRIMARY KEY CLUSTERED 
(
	[albumid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessalbum', @level2type=N'COLUMN',@level2name=N'albumid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼ұ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessalbum', @level2type=N'COLUMN',@level2name=N'buid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessalbum', @level2type=N'COLUMN',@level2name=N'albumname'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͼַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessalbum', @level2type=N'COLUMN',@level2name=N'picurl'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƭ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessalbum', @level2type=N'COLUMN',@level2name=N'photocount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessalbum', @level2type=N'COLUMN',@level2name=N'cid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessalbum', @level2type=N'COLUMN',@level2name=N'grade'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessalbum'
GO
/****** Object:  Table [dbo].[mry_businessactivity]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_businessactivity](
	[activityid] [int] IDENTITY(1,1) NOT NULL,
	[buid] [int] NOT NULL,
	[activityname] [nvarchar](100) NULL,
	[startdate] [datetime] NULL,
	[enddate] [datetime] NULL,
	[descrfile] [nvarchar](80) NULL,
	[picurl] [nvarchar](50) NULL,
 CONSTRAINT [PK_MRY_BUSINESSACTIVITY] PRIMARY KEY CLUSTERED 
(
	[activityid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessactivity', @level2type=N'COLUMN',@level2name=N'activityid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼ұ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessactivity', @level2type=N'COLUMN',@level2name=N'buid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessactivity', @level2type=N'COLUMN',@level2name=N'activityname'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ʼ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessactivity', @level2type=N'COLUMN',@level2name=N'startdate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessactivity', @level2type=N'COLUMN',@level2name=N'enddate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ļ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessactivity', @level2type=N'COLUMN',@level2name=N'descrfile'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͼƬַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessactivity', @level2type=N'COLUMN',@level2name=N'picurl'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼һ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessactivity'
GO
/****** Object:  StoredProcedure [dbo].[dnt_revisedebatetopicdiggs]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_revisedebatetopicdiggs]
	@tid int,
	@opinion int,
	@count int out
AS
BEGIN
	SELECT @count=COUNT(1) FROM [dnt_postdebatefields] WHERE [tid] = @tid AND [opinion] = @opinion
	
	IF @opinion=1
	BEGIN
		UPDATE [dnt_debates] SET [positivediggs]=(SELECT SUM(diggs + 1) FROM [dnt_postdebatefields] WHERE [tid] = @tid AND [opinion] = @opinion) WHERE [tid] = @tid
	END
	ELSE
	BEGIN
		UPDATE [dnt_debates] SET [negativediggs]=(SELECT SUM(diggs + 1) FROM [dnt_postdebatefields] WHERE [tid] = @tid AND [opinion] = @opinion) WHERE [tid] = @tid
	END
END
GO
/****** Object:  StoredProcedure [dbo].[dnt_resetuserdigestposts]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_resetuserdigestposts]
AS
UPDATE dnt_users
SET [digestposts] = leftTable.topiccount 
FROM dnt_users 
INNER JOIN (SELECT COUNT(tid) topiccount,posterid FROM dnt_topics WHERE [digest] > 0 GROUP BY posterid) AS leftTable
ON dnt_users.[uid] = leftTable.posterid
WHERE dnt_users.[uid] = leftTable.posterid AND dnt_users.posts <> 0
GO
/****** Object:  StoredProcedure [dbo].[dnt_resettodayposts]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_resettodayposts]
AS
UPDATE dnt_forums SET todayposts = 0;

DECLARE @tableid int;
SELECT @tableid = MAX(id) FROM dnt_tablelist;
EXEC('
UPDATE dnt_forums 
SET todayposts=rightTable.pidcount 
FROM dnt_forums 
INNER JOIN (SELECT fid,COUNT(pid) pidcount FROM dnt_posts'+ @tableid +' WHERE DATEDIFF(DAY,postdatetime,GETDATE())=0 GROUP BY fid ) AS rightTable
ON dnt_forums.fid=rightTable.fid
WHERE dnt_forums.fid=rightTable.fid
')
GO
/****** Object:  StoredProcedure [dbo].[dnt_resetstatistic]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[dnt_resetstatistic]
@totaltopic INT,
@totalpost INT,
@totalusers INT,
@lastusername VARCHAR(20),
@lastuserid INT
AS
UPDATE [dnt_statistics] 
SET 
[totaltopic]=@totaltopic,[totalpost]=@totalpost,[totalusers]=@totalusers,[lastusername]=@lastusername,[lastuserid]=@lastuserid
GO
/****** Object:  Table [dbo].[mry_businessreserve]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_businessreserve](
	[reserveid] [int] IDENTITY(1,1) NOT NULL,
	[buid] [int] NULL,
	[bbsuid] [int] NULL,
	[postname] [nvarchar](10) NULL,
	[reservedate] [datetime] NULL,
	[tel] [nvarchar](25) NULL,
	[memo] [nvarchar](255) NULL,
	[postdate] [datetime] NULL,
	[ip] [nvarchar](15) NULL,
	[readed] [bit] NULL,
 CONSTRAINT [PK_MRY_BUSINESSRESERVE] PRIMARY KEY CLUSTERED 
(
	[reserveid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ԤԼ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessreserve', @level2type=N'COLUMN',@level2name=N'reserveid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼ұ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessreserve', @level2type=N'COLUMN',@level2name=N'buid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessreserve', @level2type=N'COLUMN',@level2name=N'bbsuid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessreserve', @level2type=N'COLUMN',@level2name=N'postname'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ԤԼʱ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessreserve', @level2type=N'COLUMN',@level2name=N'reservedate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ϵ绰' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessreserve', @level2type=N'COLUMN',@level2name=N'tel'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ע' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessreserve', @level2type=N'COLUMN',@level2name=N'memo'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessreserve', @level2type=N'COLUMN',@level2name=N'postdate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IPַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessreserve', @level2type=N'COLUMN',@level2name=N'ip'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ѷ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessreserve', @level2type=N'COLUMN',@level2name=N'readed'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼ԤԼ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessreserve'
GO
/****** Object:  Table [dbo].[mry_businessquestions]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_businessquestions](
	[questionid] [int] IDENTITY(1,1) NOT NULL,
	[buid] [int] NULL,
	[bbsuid] [int] NULL,
	[postuname] [nvarchar](10) NULL,
	[tel] [nvarchar](25) NULL,
	[qq] [nvarchar](20) NULL,
	[msn] [nvarchar](50) NULL,
	[email] [nvarchar](100) NULL,
	[content] [nvarchar](255) NULL,
	[ip] [nvarchar](15) NULL,
	[postdate] [datetime] NULL,
	[ask] [nvarchar](255) NULL,
	[askdate] [datetime] NULL,
	[readed] [bit] NULL,
 CONSTRAINT [PK_MRY_BUSINESSQUESTIONS] PRIMARY KEY CLUSTERED 
(
	[questionid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ա' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions', @level2type=N'COLUMN',@level2name=N'questionid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼ұ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions', @level2type=N'COLUMN',@level2name=N'buid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions', @level2type=N'COLUMN',@level2name=N'bbsuid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions', @level2type=N'COLUMN',@level2name=N'postuname'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ϵ绰' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions', @level2type=N'COLUMN',@level2name=N'tel'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'QQ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions', @level2type=N'COLUMN',@level2name=N'qq'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'MSN' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions', @level2type=N'COLUMN',@level2name=N'msn'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions', @level2type=N'COLUMN',@level2name=N'email'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions', @level2type=N'COLUMN',@level2name=N'content'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IPַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions', @level2type=N'COLUMN',@level2name=N'ip'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions', @level2type=N'COLUMN',@level2name=N'postdate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼һظ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions', @level2type=N'COLUMN',@level2name=N'ask'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ظ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions', @level2type=N'COLUMN',@level2name=N'askdate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ѷ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions', @level2type=N'COLUMN',@level2name=N'readed'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼ѯ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessquestions'
GO
/****** Object:  Table [dbo].[mry_personalbum]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_personalbum](
	[albumid] [int] IDENTITY(1,1) NOT NULL,
	[puid] [int] NULL,
	[bbsuid] [int] NULL,
	[cid] [int] NULL,
	[albumname] [nvarchar](100) NULL,
	[bride] [nvarchar](10) NULL,
	[bridegroom] [nvarchar](10) NULL,
	[engagementdate] [datetime] NULL,
	[marrydate] [datetime] NULL,
	[photographcom] [nvarchar](50) NULL,
	[cameraman] [nvarchar](10) NULL,
	[picurl] [nvarchar](50) NULL,
	[descr] [nvarchar](255) NULL,
	[createdate] [datetime] NULL,
	[photocount] [int] NULL,
	[clicks] [int] NULL,
	[isopen] [bit] NULL,
 CONSTRAINT [PK_MRY_PERSONALBUM] PRIMARY KEY CLUSTERED 
(
	[albumid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'albumid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'puid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̳û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'bbsuid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'cid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'albumname'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'bride'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'bridegroom'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'engagementdate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'marrydate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ӱ¥' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'photographcom'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ӱʦ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'cameraman'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͼƬַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'picurl'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'˵' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'descr'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'createdate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƭ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'photocount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'clicks'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƿ񹫿' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum', @level2type=N'COLUMN',@level2name=N'isopen'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personalbum'
GO
/****** Object:  Table [dbo].[mry_newscomment]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_newscomment](
	[commentid] [int] IDENTITY(1,1) NOT NULL,
	[newsid] [int] NOT NULL,
	[bbsuid] [int] NULL,
	[postname] [nvarchar](10) NULL,
	[content] [nvarchar](255) NULL,
	[postdate] [datetime] NULL,
	[ip] [nvarchar](15) NULL,
	[layer] [int] NULL,
 CONSTRAINT [PK_MRY_NEWSCOMMENT] PRIMARY KEY CLUSTERED 
(
	[commentid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ա' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_newscomment', @level2type=N'COLUMN',@level2name=N'commentid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ѷ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_newscomment', @level2type=N'COLUMN',@level2name=N'newsid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_newscomment', @level2type=N'COLUMN',@level2name=N'bbsuid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_newscomment', @level2type=N'COLUMN',@level2name=N'postname'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_newscomment', @level2type=N'COLUMN',@level2name=N'content'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_newscomment', @level2type=N'COLUMN',@level2name=N'postdate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IPַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_newscomment', @level2type=N'COLUMN',@level2name=N'ip'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'¥' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_newscomment', @level2type=N'COLUMN',@level2name=N'layer'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ѶϢ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_newscomment'
GO
/****** Object:  Table [dbo].[mry_askposts]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_askposts](
	[postid] [int] IDENTITY(1,1) NOT NULL,
	[topcid] [int] NULL,
	[uid] [int] NULL,
	[asker] [nvarchar](20) NULL,
	[content] [nvarchar](80) NULL,
	[appendcontent] [nvarchar](80) NULL,
	[askdate] [datetime] NULL,
	[isaccept] [bit] NULL,
	[isanonymity] [bit] NULL,
	[issysget] [bit] NULL,
	[recommands] [int] NULL,
 CONSTRAINT [PK_MRY_ASKPOSTS] PRIMARY KEY CLUSTERED 
(
	[postid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ʴظ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_askposts', @level2type=N'COLUMN',@level2name=N'postid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ʴ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_askposts', @level2type=N'COLUMN',@level2name=N'topcid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_askposts', @level2type=N'COLUMN',@level2name=N'uid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ش' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_askposts', @level2type=N'COLUMN',@level2name=N'asker'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ظ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_askposts', @level2type=N'COLUMN',@level2name=N'content'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_askposts', @level2type=N'COLUMN',@level2name=N'appendcontent'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ظʱ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_askposts', @level2type=N'COLUMN',@level2name=N'askdate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƿ񱻲' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_askposts', @level2type=N'COLUMN',@level2name=N'isaccept'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƿش' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_askposts', @level2type=N'COLUMN',@level2name=N'isanonymity'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƿץȡ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_askposts', @level2type=N'COLUMN',@level2name=N'issysget'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƽ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_askposts', @level2type=N'COLUMN',@level2name=N'recommands'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ʴظ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_askposts'
GO
/****** Object:  StoredProcedure [dbo].[dnt_gettopiclistbytag]    Script Date: 06/10/2013 22:26:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_gettopiclistbytag]	
	@tagid int,
	@pageindex int,
	@pagesize int
AS
	DECLARE @startRow int,
			@endRow	int
SET @startRow = (@pageindex - 1) * @pagesize + 1
SET @endRow = @startRow + @pagesize -1

SELECT 
[TOPICTAGS].[tid], 
[TOPICTAGS].[title],
[TOPICTAGS].[poster],
[TOPICTAGS].[posterid],
[TOPICTAGS].[fid],
[TOPICTAGS].[postdatetime],
[TOPICTAGS].[replies],
[TOPICTAGS].[views],
[TOPICTAGS].[lastposter],
[TOPICTAGS].[lastposterid],
[TOPICTAGS].[lastpost] 
FROM(SELECT ROW_NUMBER() OVER(ORDER BY [lastpostid]) AS ROWID,
[t].[tid], 
[t].[title],
[t].[poster],
[t].[posterid],
[t].[fid],
[t].[postdatetime],
[t].[replies],
[t].[views],
[t].[lastposter],
[t].[lastposterid],
[t].[lastpost]
FROM [dnt_topictags] AS [tt], [dnt_topics] AS [t]
WHERE [t].[tid] = [tt].[tid] AND [t].[displayorder] >=0 AND [tt].[tagid] = @tagid) AS TOPICTAGS
WHERE ROWID BETWEEN @startRow AND @endRow
GO
/****** Object:  View [dbo].[v_MyPosts]    Script Date: 06/10/2013 22:26:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[v_MyPosts]
AS
SELECT T2.*,T1.uid as reposterid,t1.pid FROM Dnt_myposts AS T1 LEFT JOIN Dnt_topics AS T2 ON T1.tid = T2.tid
GO
/****** Object:  Table [dbo].[mry_picturephoto]    Script Date: 06/10/2013 22:26:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_picturephoto](
	[picid] [int] IDENTITY(1,1) NOT NULL,
	[albumid] [int] NULL,
	[picname] [nvarchar](50) NULL,
	[clicks] [int] NULL,
	[picurl] [nvarchar](50) NULL,
 CONSTRAINT [PK_MRY_PICTUREPHOTO] PRIMARY KEY CLUSTERED 
(
	[picid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƭ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_picturephoto', @level2type=N'COLUMN',@level2name=N'picid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_picturephoto', @level2type=N'COLUMN',@level2name=N'albumid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_picturephoto', @level2type=N'COLUMN',@level2name=N'picname'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_picturephoto', @level2type=N'COLUMN',@level2name=N'clicks'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͼƬַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_picturephoto', @level2type=N'COLUMN',@level2name=N'picurl'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͼƬ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_picturephoto'
GO
/****** Object:  View [dbo].[v_AdsNewsName]    Script Date: 06/10/2013 22:26:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[v_AdsNewsName]
AS
	SELECT t2.title,t1.* FROM mry_ads AS T1 LEFT JOIN mry_news AS T2 ON T1.newsid = T2.newsid
GO
/****** Object:  View [dbo].[v_Questions]    Script Date: 06/10/2013 22:26:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
cREATE VIEW [dbo].[v_Questions]
AS
SELECT    T2.companyname, T1.*
FROM         dbo.mry_businessquestions AS T1 LEFT OUTER JOIN
                      dbo.mry_businessuser AS T2 ON T1.buid = T2.buid
GO
/****** Object:  View [dbo].[v_BusinessCouponUName]    Script Date: 06/10/2013 22:26:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[v_BusinessCouponUName]
AS
SELECT     CASE WHEN datediff(d, enddate, getdate()) > 0 THEN 0 ELSE 1 END AS outofdate, t2.companyname, t2.logo, t1.couponid, t1.buid, t1.startdate, t1.enddate, t1.title, 
                      t1.picurl, t1.enabled
FROM         dbo.mry_businesscoupon AS t1 LEFT OUTER JOIN
                      dbo.mry_businessuser AS t2 ON t1.buid = t2.buid
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=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 = "t1"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 125
               Right = 177
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t2"
            Begin Extent = 
               Top = 6
               Left = 215
               Bottom = 125
               Right = 373
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 11
         Width = 284
         Width = 1500
         Width = 1500
         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
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_BusinessCouponUName'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_BusinessCouponUName'
GO
/****** Object:  View [dbo].[v_BusinessAlbumUname]    Script Date: 06/10/2013 22:26:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[v_BusinessAlbumUname]
AS
	SELECT t2.companyname,t1.* FROM mry_businessalbum AS T1 LEFT JOIN mry_businessuser AS T2 ON T1.buid = T2.buid
GO
/****** Object:  View [dbo].[v_BusinessActivityUname]    Script Date: 06/10/2013 22:26:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[v_BusinessActivityUname]
AS
SELECT     CASE WHEN datediff(d, enddate, getdate()) > 0 THEN 0 ELSE 1 END AS outofdate, t2.companyname, t2.logo, t1.activityid, t1.buid, t1.activityname, t1.startdate, 
                      t1.enddate, t1.descrfile, t1.picurl
FROM         dbo.mry_businessactivity AS t1 LEFT OUTER JOIN
                      dbo.mry_businessuser AS t2 ON t1.buid = t2.buid
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=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 = "t1"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 125
               Right = 188
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t2"
            Begin Extent = 
               Top = 6
               Left = 226
               Bottom = 125
               Right = 384
            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
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_BusinessActivityUname'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_BusinessActivityUname'
GO
/****** Object:  View [dbo].[v_BusinessActivity]    Script Date: 06/10/2013 22:26:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[v_BusinessActivity]
AS
SELECT     T2.companyname, T1.activityid, T1.buid, T1.activityname, T1.startdate, T1.enddate, T1.descrfile, T1.picurl, T2.viplevel
FROM         dbo.mry_businessactivity AS T1 LEFT OUTER JOIN
                      dbo.mry_businessuser AS T2 ON T1.buid = T2.buid
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=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 = "T1"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 125
               Right = 188
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "T2"
            Begin Extent = 
               Top = 6
               Left = 226
               Bottom = 191
               Right = 384
            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
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_BusinessActivity'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_BusinessActivity'
GO
/****** Object:  View [dbo].[v_AlbumUnames]    Script Date: 06/10/2013 22:26:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[v_AlbumUnames]
AS
	SELECT t2.nickname,t2.username, t1.* FROM mry_personalbum AS T1 LEFT JOIN dnt_users AS T2 
		ON T1.bbsuid = T2.uid
GO
/****** Object:  Table [dbo].[mry_personphoto]    Script Date: 06/10/2013 22:26:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_personphoto](
	[photoid] [int] IDENTITY(1,1) NOT NULL,
	[albumid] [int] NULL,
	[puid] [int] NULL,
	[photourl] [nvarchar](50) NULL,
	[browsecount] [int] NULL,
	[descr] [nvarchar](255) NULL,
	[grade] [int] NULL,
	[clicks] [int] NULL,
 CONSTRAINT [PK_MRY_PERSONPHOTO] PRIMARY KEY CLUSTERED 
(
	[photoid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƭ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personphoto', @level2type=N'COLUMN',@level2name=N'photoid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personphoto', @level2type=N'COLUMN',@level2name=N'albumid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'û' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personphoto', @level2type=N'COLUMN',@level2name=N'puid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƭַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personphoto', @level2type=N'COLUMN',@level2name=N'photourl'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personphoto', @level2type=N'COLUMN',@level2name=N'browsecount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƭ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personphoto', @level2type=N'COLUMN',@level2name=N'descr'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personphoto', @level2type=N'COLUMN',@level2name=N'grade'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personphoto', @level2type=N'COLUMN',@level2name=N'clicks'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƭ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_personphoto'
GO
/****** Object:  Table [dbo].[mry_businessphoto]    Script Date: 06/10/2013 22:26:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mry_businessphoto](
	[photoid] [int] IDENTITY(1,1) NOT NULL,
	[albumid] [int] NULL,
	[buid] [int] NULL,
	[browsecount] [int] NULL,
	[photourl] [nvarchar](50) NULL,
	[descr] [nvarchar](20) NULL,
 CONSTRAINT [PK_MRY_BUSINESSPHOTO] PRIMARY KEY CLUSTERED 
(
	[photoid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͼƬ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessphoto', @level2type=N'COLUMN',@level2name=N'photoid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessphoto', @level2type=N'COLUMN',@level2name=N'albumid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼ұ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessphoto', @level2type=N'COLUMN',@level2name=N'buid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessphoto', @level2type=N'COLUMN',@level2name=N'browsecount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ͼƬַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessphoto', @level2type=N'COLUMN',@level2name=N'photourl'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ƭ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessphoto', @level2type=N'COLUMN',@level2name=N'descr'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'̼ͼƬ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'mry_businessphoto'
GO
/****** Object:  StoredProcedure [dbo].[dnt_createtopictags]    Script Date: 06/10/2013 22:26:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dnt_createtopictags]
@tags nvarchar(55),
@tid int,
@userid int,
@postdatetime datetime
AS
BEGIN
	EXEC [dnt_createtags] @tags, @userid, @postdatetime

	UPDATE [dnt_tags] SET [fcount]=[fcount]+1,[count]=[count]+1
	WHERE EXISTS (SELECT [item] FROM [dnt_split](@tags, ' ') AS [newtags] WHERE [newtags].[item] = [tagname])

	INSERT INTO [dnt_topictags] (tagid, tid)
	SELECT tagid, @tid FROM [dnt_tags] WHERE EXISTS (SELECT [item] FROM [dnt_split](@tags, ' ') WHERE [item] = [dnt_tags].[tagname])
END
GO
/****** Object:  Default [DF_dnt_users_username]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_username]  DEFAULT ('') FOR [username]
GO
/****** Object:  Default [DF_dnt_users_nickname]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_nickname]  DEFAULT ('') FOR [nickname]
GO
/****** Object:  Default [DF__dnt_users_password]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF__dnt_users_password]  DEFAULT ('') FOR [password]
GO
/****** Object:  Default [DF_dnt_users_secques]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_secques]  DEFAULT ('') FOR [secques]
GO
/****** Object:  Default [DF_dnt_users_spaceid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_spaceid]  DEFAULT ((0)) FOR [spaceid]
GO
/****** Object:  Default [DF_dnt_users_gender]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_gender]  DEFAULT ((0)) FOR [gender]
GO
/****** Object:  Default [DF_dnt_users_adminid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_adminid]  DEFAULT ((0)) FOR [adminid]
GO
/****** Object:  Default [DF_dnt_users_groupid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_groupid]  DEFAULT ((0)) FOR [groupid]
GO
/****** Object:  Default [DF_dnt_users_groupexpiry]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_groupexpiry]  DEFAULT ((0)) FOR [groupexpiry]
GO
/****** Object:  Default [DF_dnt_users_extgroupids]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_extgroupids]  DEFAULT ('') FOR [extgroupids]
GO
/****** Object:  Default [DF_dnt_users_regip]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_regip]  DEFAULT ('') FOR [regip]
GO
/****** Object:  Default [DF_dnt_users_joindate]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_joindate]  DEFAULT (getdate()) FOR [joindate]
GO
/****** Object:  Default [DF_dnt_users_lastip]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_lastip]  DEFAULT ('') FOR [lastip]
GO
/****** Object:  Default [DF__dnt_users_lastvisit]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF__dnt_users_lastvisit]  DEFAULT (getdate()) FOR [lastvisit]
GO
/****** Object:  Default [DF_dnt_users_lastactivity]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_lastactivity]  DEFAULT (getdate()) FOR [lastactivity]
GO
/****** Object:  Default [DF_dnt_users_lastpost]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_lastpost]  DEFAULT (getdate()) FOR [lastpost]
GO
/****** Object:  Default [DF_dnt_users_lastpostid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_lastpostid]  DEFAULT ((0)) FOR [lastpostid]
GO
/****** Object:  Default [DF_dnt_users_lastposttitle]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_lastposttitle]  DEFAULT ('') FOR [lastposttitle]
GO
/****** Object:  Default [DF_dnt_users__posts_]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users__posts_]  DEFAULT ('0') FOR [posts]
GO
/****** Object:  Default [DF_dnt_users_digestposts]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_digestposts]  DEFAULT ('0') FOR [digestposts]
GO
/****** Object:  Default [DF__dnt_users__oltim__14F1071C]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF__dnt_users__oltim__14F1071C]  DEFAULT ('0') FOR [oltime]
GO
/****** Object:  Default [DF_dnt_users_pageviews]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_pageviews]  DEFAULT ('0') FOR [pageviews]
GO
/****** Object:  Default [DF_dnt_users_credits]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_credits]  DEFAULT ('0') FOR [credits]
GO
/****** Object:  Default [DF__dnt_users_extcredits1]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF__dnt_users_extcredits1]  DEFAULT ('0') FOR [extcredits1]
GO
/****** Object:  Default [DF__dnt_users_extcredits2]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF__dnt_users_extcredits2]  DEFAULT ('0') FOR [extcredits2]
GO
/****** Object:  Default [DF__dnt_users_extcredits3]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF__dnt_users_extcredits3]  DEFAULT ('0') FOR [extcredits3]
GO
/****** Object:  Default [DF__dnt_users_extcredits4]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF__dnt_users_extcredits4]  DEFAULT ('0') FOR [extcredits4]
GO
/****** Object:  Default [DF__dnt_users_extcredits5]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF__dnt_users_extcredits5]  DEFAULT ('0') FOR [extcredits5]
GO
/****** Object:  Default [DF__dnt_users_extcredits6]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF__dnt_users_extcredits6]  DEFAULT ('0') FOR [extcredits6]
GO
/****** Object:  Default [DF__dnt_users_extcredits7]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF__dnt_users_extcredits7]  DEFAULT ('0') FOR [extcredits7]
GO
/****** Object:  Default [DF__dnt_users_extcredits8]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF__dnt_users_extcredits8]  DEFAULT ('0') FOR [extcredits8]
GO
/****** Object:  Default [DF_dnt_users_avatarshowid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_avatarshowid]  DEFAULT ('0') FOR [avatarshowid]
GO
/****** Object:  Default [DF_dnt_users_email]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_email]  DEFAULT ('') FOR [email]
GO
/****** Object:  Default [DF_dnt_users_bday_]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_bday_]  DEFAULT ('') FOR [bday]
GO
/****** Object:  Default [DF_dnt_users_sigstatus]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_sigstatus]  DEFAULT ('0') FOR [sigstatus]
GO
/****** Object:  Default [DF_dnt_users_tpp_]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_tpp_]  DEFAULT ('0') FOR [tpp]
GO
/****** Object:  Default [DF_dnt_users_ppp_]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_ppp_]  DEFAULT ('0') FOR [ppp]
GO
/****** Object:  Default [DF_dnt_users_templateid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_templateid]  DEFAULT ('0') FOR [templateid]
GO
/****** Object:  Default [DF_dnt_users_pmsound]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_pmsound]  DEFAULT ('0') FOR [pmsound]
GO
/****** Object:  Default [DF_dnt_users_showemail]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_showemail]  DEFAULT ('0') FOR [showemail]
GO
/****** Object:  Default [DF__dnt_users_invisible]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF__dnt_users_invisible]  DEFAULT ('0') FOR [invisible]
GO
/****** Object:  Default [DF_dnt_users_newpm]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_newpm]  DEFAULT ('0') FOR [newpm]
GO
/****** Object:  Default [DF_dnt_users_newpmcount]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_newpmcount]  DEFAULT ((0)) FOR [newpmcount]
GO
/****** Object:  Default [DF_dnt_users_accessmasks]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_accessmasks]  DEFAULT ('0') FOR [accessmasks]
GO
/****** Object:  Default [DF_dnt_users_onlinestate]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_onlinestate]  DEFAULT ((0)) FOR [onlinestate]
GO
/****** Object:  Default [DF_dnt_users_newsletter]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_newsletter]  DEFAULT ('7') FOR [newsletter]
GO
/****** Object:  Default [DF_dnt_users_salt]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_users] ADD  CONSTRAINT [DF_dnt_users_salt]  DEFAULT ('') FOR [salt]
GO
/****** Object:  Default [DF_dnt_usergroups_type]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_usergroups] ADD  CONSTRAINT [DF_dnt_usergroups_type]  DEFAULT ((0)) FOR [type]
GO
/****** Object:  Default [DF_dnt_usergroups_system]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_usergroups] ADD  CONSTRAINT [DF_dnt_usergroups_system]  DEFAULT ('0') FOR [system]
GO
/****** Object:  Default [DF_dnt_usergroups_allowspace]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_usergroups] ADD  CONSTRAINT [DF_dnt_usergroups_allowspace]  DEFAULT ((0)) FOR [allowspace]
GO
/****** Object:  Default [DF_dnt_usergroups_maxspaceattachsize]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_usergroups] ADD  CONSTRAINT [DF_dnt_usergroups_maxspaceattachsize]  DEFAULT ((0)) FOR [maxspaceattachsize]
GO
/****** Object:  Default [DF_dnt_usergroups_maxspacephotosize]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_usergroups] ADD  CONSTRAINT [DF_dnt_usergroups_maxspacephotosize]  DEFAULT ((0)) FOR [maxspacephotosize]
GO
/****** Object:  Default [DF_dnt_usergroups_allowdebate]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_usergroups] ADD  CONSTRAINT [DF_dnt_usergroups_allowdebate]  DEFAULT ((0)) FOR [allowdebate]
GO
/****** Object:  Default [DF_dnt_usergroups_allowbonus]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_usergroups] ADD  CONSTRAINT [DF_dnt_usergroups_allowbonus]  DEFAULT ((0)) FOR [allowbonus]
GO
/****** Object:  Default [DF_dnt_usergroups_minbonusprice]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_usergroups] ADD  CONSTRAINT [DF_dnt_usergroups_minbonusprice]  DEFAULT ((0)) FOR [minbonusprice]
GO
/****** Object:  Default [DF_dnt_usergroups_maxbonusprice]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_usergroups] ADD  CONSTRAINT [DF_dnt_usergroups_maxbonusprice]  DEFAULT ((0)) FOR [maxbonusprice]
GO
/****** Object:  Default [DF_dnt_usergroups_allowtrade]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_usergroups] ADD  CONSTRAINT [DF_dnt_usergroups_allowtrade]  DEFAULT ((0)) FOR [allowtrade]
GO
/****** Object:  Default [DF_dnt_usergroups_allowdiggs]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_usergroups] ADD  CONSTRAINT [DF_dnt_usergroups_allowdiggs]  DEFAULT ((0)) FOR [allowdiggs]
GO
/****** Object:  Default [DF_dnt_userfields_website]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_website]  DEFAULT ('') FOR [website]
GO
/****** Object:  Default [DF_dnt_userfields_icq]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_icq]  DEFAULT ('') FOR [icq]
GO
/****** Object:  Default [DF_dnt_userfields_qq]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_qq]  DEFAULT ('') FOR [qq]
GO
/****** Object:  Default [DF_dnt_userfields_yahoo]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_yahoo]  DEFAULT ('') FOR [yahoo]
GO
/****** Object:  Default [DF_dnt_userfields_msn]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_msn]  DEFAULT ('') FOR [msn]
GO
/****** Object:  Default [DF_dnt_userfields_skype_]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_skype_]  DEFAULT ('') FOR [skype]
GO
/****** Object:  Default [DF_dnt_userfields_location]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_location]  DEFAULT ('') FOR [location]
GO
/****** Object:  Default [DF_dnt_userfields_customstatus]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_customstatus]  DEFAULT ('') FOR [customstatus]
GO
/****** Object:  Default [DF_dnt_userfields_avatar]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_avatar]  DEFAULT ('avatars\common\0.gif') FOR [avatar]
GO
/****** Object:  Default [DF_dnt_userfields_avatarwidth]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_avatarwidth]  DEFAULT ((60)) FOR [avatarwidth]
GO
/****** Object:  Default [DF_dnt_userfields_avatarheight]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_avatarheight]  DEFAULT ((60)) FOR [avatarheight]
GO
/****** Object:  Default [DF_dnt_userfields_medals]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_medals]  DEFAULT ('') FOR [medals]
GO
/****** Object:  Default [DF_dnt_userfields_bio]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_bio]  DEFAULT ('') FOR [bio]
GO
/****** Object:  Default [DF_dnt_userfields_signature]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_signature]  DEFAULT ('') FOR [signature]
GO
/****** Object:  Default [DF_dnt_userfields_sightml]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_sightml]  DEFAULT ('') FOR [sightml]
GO
/****** Object:  Default [DF_dnt_userfields_authstr]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_authstr]  DEFAULT ('') FOR [authstr]
GO
/****** Object:  Default [DF_dnt_userfields_authtime]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_authtime]  DEFAULT (getdate()) FOR [authtime]
GO
/****** Object:  Default [DF_dnt_userfields_authflag]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_authflag]  DEFAULT ((0)) FOR [authflag]
GO
/****** Object:  Default [DF_dnt_userfields_realname]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_realname]  DEFAULT ('') FOR [realname]
GO
/****** Object:  Default [DF_dnt_userfields_idcard]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_idcard]  DEFAULT ('') FOR [idcard]
GO
/****** Object:  Default [DF_dnt_userfields_mobile]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_mobile]  DEFAULT ('') FOR [mobile]
GO
/****** Object:  Default [DF_dnt_userfields_phone]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_phone]  DEFAULT ('') FOR [phone]
GO
/****** Object:  Default [DF_dnt_userfields_ignorepm]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_userfields] ADD  CONSTRAINT [DF_dnt_userfields_ignorepm]  DEFAULT ('') FOR [ignorepm]
GO
/****** Object:  Default [DF_dnt_ratelog_postdatetime]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_ratelog] ADD  CONSTRAINT [DF_dnt_ratelog_postdatetime]  DEFAULT (getdate()) FOR [postdatetime]
GO
/****** Object:  Default [DF_dnt_posts1_pid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_pid]  DEFAULT ((0)) FOR [pid]
GO
/****** Object:  Default [DF_dnt_posts1_parentid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_parentid]  DEFAULT ((0)) FOR [parentid]
GO
/****** Object:  Default [DF_dnt_posts1_layer]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_layer]  DEFAULT ((0)) FOR [layer]
GO
/****** Object:  Default [DF_dnt_posts1_poster]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_poster]  DEFAULT ('') FOR [poster]
GO
/****** Object:  Default [DF_dnt_posts1_posterid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_posterid]  DEFAULT ((0)) FOR [posterid]
GO
/****** Object:  Default [DF_dnt_posts1_postdatetime]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_postdatetime]  DEFAULT (getdate()) FOR [postdatetime]
GO
/****** Object:  Default [DF_dnt_posts1_message]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_message]  DEFAULT ('') FOR [message]
GO
/****** Object:  Default [DF_dnt_posts1_ip]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_ip]  DEFAULT ('') FOR [ip]
GO
/****** Object:  Default [DF_dnt_posts1_lastedit]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_lastedit]  DEFAULT ('') FOR [lastedit]
GO
/****** Object:  Default [DF_dnt_posts1_invisible]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_invisible]  DEFAULT ((0)) FOR [invisible]
GO
/****** Object:  Default [DF_dnt_posts1_usesig]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_usesig]  DEFAULT ((0)) FOR [usesig]
GO
/****** Object:  Default [DF_dnt_posts1_htmlon]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_htmlon]  DEFAULT ((0)) FOR [htmlon]
GO
/****** Object:  Default [DF_dnt_posts1_smileyoff]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_smileyoff]  DEFAULT ((0)) FOR [smileyoff]
GO
/****** Object:  Default [DF_dnt_posts1_parseurloff]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_parseurloff]  DEFAULT ((0)) FOR [parseurloff]
GO
/****** Object:  Default [DF_dnt_posts1_bbcodeoff]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_bbcodeoff]  DEFAULT ((0)) FOR [bbcodeoff]
GO
/****** Object:  Default [DF_dnt_posts1_attachment]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_attachment]  DEFAULT ((0)) FOR [attachment]
GO
/****** Object:  Default [DF_dnt_posts1_rate]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_rate]  DEFAULT ((0)) FOR [rate]
GO
/****** Object:  Default [DF_dnt_posts1_ratetimes]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_posts1] ADD  CONSTRAINT [DF_dnt_posts1_ratetimes]  DEFAULT ((0)) FOR [ratetimes]
GO
/****** Object:  Default [DF_dnt_postdebatefields_tid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_postdebatefields] ADD  CONSTRAINT [DF_dnt_postdebatefields_tid]  DEFAULT ((0)) FOR [tid]
GO
/****** Object:  Default [DF_dnt_postdebatefields_pid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_postdebatefields] ADD  CONSTRAINT [DF_dnt_postdebatefields_pid]  DEFAULT ((0)) FOR [pid]
GO
/****** Object:  Default [DF_dnt_postdebatefields_opinion]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_postdebatefields] ADD  CONSTRAINT [DF_dnt_postdebatefields_opinion]  DEFAULT ((0)) FOR [opinion]
GO
/****** Object:  Default [DF_dnt_postdebatefields_diggs]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_postdebatefields] ADD  CONSTRAINT [DF_dnt_postdebatefields_diggs]  DEFAULT ((0)) FOR [diggs]
GO
/****** Object:  Default [DF_dnt_polls_tid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_polls] ADD  CONSTRAINT [DF_dnt_polls_tid]  DEFAULT ((0)) FOR [tid]
GO
/****** Object:  Default [DF_dnt_polls_multiple]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_polls] ADD  CONSTRAINT [DF_dnt_polls_multiple]  DEFAULT ((0)) FOR [multiple]
GO
/****** Object:  Default [DF_dnt_polls_visible]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_polls] ADD  CONSTRAINT [DF_dnt_polls_visible]  DEFAULT ((0)) FOR [visible]
GO
/****** Object:  Default [DF_dnt_polls_maxchoices]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_polls] ADD  CONSTRAINT [DF_dnt_polls_maxchoices]  DEFAULT ((0)) FOR [maxchoices]
GO
/****** Object:  Default [DF_dnt_polls_uid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_polls] ADD  CONSTRAINT [DF_dnt_polls_uid]  DEFAULT ((0)) FOR [uid]
GO
/****** Object:  Default [DF_dnt_polls_voternames]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_polls] ADD  CONSTRAINT [DF_dnt_polls_voternames]  DEFAULT ('') FOR [voternames]
GO
/****** Object:  Default [DF_dnt_polloptions_tid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_polloptions] ADD  CONSTRAINT [DF_dnt_polloptions_tid]  DEFAULT ((0)) FOR [tid]
GO
/****** Object:  Default [DF_dnt_polloptions_pollid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_polloptions] ADD  CONSTRAINT [DF_dnt_polloptions_pollid]  DEFAULT ((0)) FOR [pollid]
GO
/****** Object:  Default [DF_dnt_polloptions_votes]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_polloptions] ADD  CONSTRAINT [DF_dnt_polloptions_votes]  DEFAULT ((0)) FOR [votes]
GO
/****** Object:  Default [DF_dnt_polloptions_displayorder]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_polloptions] ADD  CONSTRAINT [DF_dnt_polloptions_displayorder]  DEFAULT ((0)) FOR [displayorder]
GO
/****** Object:  Default [DF_dnt_polloptions_polloption]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_polloptions] ADD  CONSTRAINT [DF_dnt_polloptions_polloption]  DEFAULT ('') FOR [polloption]
GO
/****** Object:  Default [DF_dnt_polloptions_voternames]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_polloptions] ADD  CONSTRAINT [DF_dnt_polloptions_voternames]  DEFAULT ('') FOR [voternames]
GO
/****** Object:  Default [DF_dnt_paymentlog_buydate]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_paymentlog] ADD  CONSTRAINT [DF_dnt_paymentlog_buydate]  DEFAULT (getdate()) FOR [buydate]
GO
/****** Object:  Default [DF_dnt_invitation_usecount]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_invitation] ADD  CONSTRAINT [DF_dnt_invitation_usecount]  DEFAULT ((0)) FOR [successcount]
GO
/****** Object:  Default [DF_dnt_invitation_isdelete]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_invitation] ADD  CONSTRAINT [DF_dnt_invitation_isdelete]  DEFAULT ((0)) FOR [isdeleted]
GO
/****** Object:  Default [DF_dnt_debates_positidiggs]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_debates] ADD  CONSTRAINT [DF_dnt_debates_positidiggs]  DEFAULT ((0)) FOR [positivediggs]
GO
/****** Object:  Default [DF_dnt_debates_negatidiggs]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_debates] ADD  CONSTRAINT [DF_dnt_debates_negatidiggs]  DEFAULT ((0)) FOR [negativediggs]
GO
/****** Object:  Default [DF_dnt_attachpaymentlog_postdatetime]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_attachpaymentlog] ADD  CONSTRAINT [DF_dnt_attachpaymentlog_postdatetime]  DEFAULT (getdate()) FOR [postdatetime]
GO
/****** Object:  Default [DF_dnt_attachments_uid]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_attachments] ADD  CONSTRAINT [DF_dnt_attachments_uid]  DEFAULT ((0)) FOR [uid]
GO
/****** Object:  Default [DF__dnt_attac__width__060DEAE8]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_attachments] ADD  DEFAULT ((0)) FOR [width]
GO
/****** Object:  Default [DF__dnt_attac__heigh__07020F21]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_attachments] ADD  DEFAULT ((0)) FOR [height]
GO
/****** Object:  Default [DF_dnt_attachments_attachprice]    Script Date: 06/10/2013 22:26:02 ******/
ALTER TABLE [dbo].[dnt_attachments] ADD  CONSTRAINT [DF_dnt_attachments_attachprice]  DEFAULT ((0)) FOR [attachprice]
GO
/****** Object:  Default [DF_dnt_advertisements_code]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_advertisements] ADD  CONSTRAINT [DF_dnt_advertisements_code]  DEFAULT ('') FOR [code]
GO
/****** Object:  Default [DF_dnt_advertisements_parameters]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_advertisements] ADD  CONSTRAINT [DF_dnt_advertisements_parameters]  DEFAULT ('') FOR [parameters]
GO
/****** Object:  Default [DF_dnt_adminvisitlog_postdatetime]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_adminvisitlog] ADD  CONSTRAINT [DF_dnt_adminvisitlog_postdatetime]  DEFAULT (getdate()) FOR [postdatetime]
GO
/****** Object:  Default [DF_dnt_forums_parentid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_parentid]  DEFAULT ('0') FOR [parentid]
GO
/****** Object:  Default [DF_dnt_forums_layer]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_layer]  DEFAULT ('0') FOR [layer]
GO
/****** Object:  Default [DF_dnt_forums_pathlist]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_pathlist]  DEFAULT ('') FOR [pathlist]
GO
/****** Object:  Default [DF_dnt_forums_subforumcount]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_subforumcount]  DEFAULT ('') FOR [subforumcount]
GO
/****** Object:  Default [DF_dnt_forums_status]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_status]  DEFAULT ('0') FOR [status]
GO
/****** Object:  Default [DF_dnt_forums_colcount]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_colcount]  DEFAULT ('1') FOR [colcount]
GO
/****** Object:  Default [DF_dnt_forums_displayorder]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_displayorder]  DEFAULT ('0') FOR [displayorder]
GO
/****** Object:  Default [DF_dnt_forums_templateid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_templateid]  DEFAULT ('0') FOR [templateid]
GO
/****** Object:  Default [DF_dnt_forums_topics]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_topics]  DEFAULT ('0') FOR [topics]
GO
/****** Object:  Default [DF_dnt_forums_curtopics]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_curtopics]  DEFAULT ('0') FOR [curtopics]
GO
/****** Object:  Default [DF_dnt_forums_posts]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_posts]  DEFAULT ('0') FOR [posts]
GO
/****** Object:  Default [DF_dnt_forums_todayposts]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_todayposts]  DEFAULT ('0') FOR [todayposts]
GO
/****** Object:  Default [DF_dnt_forums_lasttid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_lasttid]  DEFAULT ('0') FOR [lasttid]
GO
/****** Object:  Default [DF_dnt_forums_lasttitle]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_lasttitle]  DEFAULT ('') FOR [lasttitle]
GO
/****** Object:  Default [DF_dnt_forums_lastpost]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_lastpost]  DEFAULT ('') FOR [lastpost]
GO
/****** Object:  Default [DF_dnt_forums_lastposterid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_lastposterid]  DEFAULT ('') FOR [lastposterid]
GO
/****** Object:  Default [DF_dnt_forums_lastposter]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_lastposter]  DEFAULT ('') FOR [lastposter]
GO
/****** Object:  Default [DF_dnt_forums_allowsmilies]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_allowsmilies]  DEFAULT ('0') FOR [allowsmilies]
GO
/****** Object:  Default [DF_dnt_forums_allowrss]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_allowrss]  DEFAULT ('0') FOR [allowrss]
GO
/****** Object:  Default [DF_dnt_forums_allowhtml]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_allowhtml]  DEFAULT ('0') FOR [allowhtml]
GO
/****** Object:  Default [DF_dnt_forums_allowbbcode]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_allowbbcode]  DEFAULT ('0') FOR [allowbbcode]
GO
/****** Object:  Default [DF_dnt_forums_allowimgcode]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_allowimgcode]  DEFAULT ('0') FOR [allowimgcode]
GO
/****** Object:  Default [DF_dnt_forums_allowblog]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_allowblog]  DEFAULT ('0') FOR [allowblog]
GO
/****** Object:  Default [DF_dnt_forums_allowtrade]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_allowtrade]  DEFAULT ('0') FOR [istrade]
GO
/****** Object:  Default [DF_dnt_forums_allowpostspecial_1]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_allowpostspecial_1]  DEFAULT ((0)) FOR [allowpostspecial]
GO
/****** Object:  Default [DF_dnt_forums_allowspecialonly]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_allowspecialonly]  DEFAULT ((0)) FOR [allowspecialonly]
GO
/****** Object:  Default [DF_dnt_forums_alloweditrules]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_alloweditrules]  DEFAULT ('0') FOR [alloweditrules]
GO
/****** Object:  Default [DF_dnt_forums_allowthumbnail]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_allowthumbnail]  DEFAULT ('0') FOR [allowthumbnail]
GO
/****** Object:  Default [DF_dnt_forums_allowtag]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_allowtag]  DEFAULT ((0)) FOR [allowtag]
GO
/****** Object:  Default [DF_dnt_forums_recyclebin]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_recyclebin]  DEFAULT ('0') FOR [recyclebin]
GO
/****** Object:  Default [DF_dnt_forums_modnewposts]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_modnewposts]  DEFAULT ('0') FOR [modnewposts]
GO
/****** Object:  Default [DF_dnt_forums_jammer]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_jammer]  DEFAULT ('0') FOR [jammer]
GO
/****** Object:  Default [DF_dnt_forums_disablewatermark]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_disablewatermark]  DEFAULT ('0') FOR [disablewatermark]
GO
/****** Object:  Default [DF_dnt_forums_inheritedmod]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_inheritedmod]  DEFAULT ('0') FOR [inheritedmod]
GO
/****** Object:  Default [DF_dnt_forums_autoclose]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forums] ADD  CONSTRAINT [DF_dnt_forums_autoclose]  DEFAULT ('0') FOR [autoclose]
GO
/****** Object:  Default [DF_dnt_forumfields_applytopictype]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forumfields] ADD  CONSTRAINT [DF_dnt_forumfields_applytopictype]  DEFAULT ((0)) FOR [applytopictype]
GO
/****** Object:  Default [DF_dnt_forumfields_postbytopictype]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forumfields] ADD  CONSTRAINT [DF_dnt_forumfields_postbytopictype]  DEFAULT ((0)) FOR [postbytopictype]
GO
/****** Object:  Default [DF_dnt_forumfields_viewbytopictype]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forumfields] ADD  CONSTRAINT [DF_dnt_forumfields_viewbytopictype]  DEFAULT ((0)) FOR [viewbytopictype]
GO
/****** Object:  Default [DF_dnt_forumfields_topictypeprefix]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_forumfields] ADD  CONSTRAINT [DF_dnt_forumfields_topictypeprefix]  DEFAULT ((0)) FOR [topictypeprefix]
GO
/****** Object:  Default [DF_dnt_favorites_typeid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_favorites] ADD  CONSTRAINT [DF_dnt_favorites_typeid]  DEFAULT ((0)) FOR [typeid]
GO
/****** Object:  Default [DF_dnt_failedlogins_errcount]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_failedlogins] ADD  CONSTRAINT [DF_dnt_failedlogins_errcount]  DEFAULT ((0)) FOR [errcount]
GO
/****** Object:  Default [DF_dnt_failedlogins_lastupdate]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_failedlogins] ADD  CONSTRAINT [DF_dnt_failedlogins_lastupdate]  DEFAULT (getdate()) FOR [lastupdate]
GO
/****** Object:  Default [DF_dnt_help_orderby]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_help] ADD  CONSTRAINT [DF_dnt_help_orderby]  DEFAULT ((0)) FOR [orderby]
GO
/****** Object:  Default [DF_dnt_navs_parentid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_navs] ADD  CONSTRAINT [DF_dnt_navs_parentid]  DEFAULT ((0)) FOR [parentid]
GO
/****** Object:  Default [DF_dnt_navs_target]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_navs] ADD  CONSTRAINT [DF_dnt_navs_target]  DEFAULT ((0)) FOR [target]
GO
/****** Object:  Default [DF_dnt_navs_type]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_navs] ADD  CONSTRAINT [DF_dnt_navs_type]  DEFAULT ((0)) FOR [type]
GO
/****** Object:  Default [DF_dnt_navs_available]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_navs] ADD  CONSTRAINT [DF_dnt_navs_available]  DEFAULT ((0)) FOR [available]
GO
/****** Object:  Default [DF_dnt_navs_highlight]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_navs] ADD  CONSTRAINT [DF_dnt_navs_highlight]  DEFAULT ((0)) FOR [highlight]
GO
/****** Object:  Default [DF_dnt_navs_level]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_navs] ADD  CONSTRAINT [DF_dnt_navs_level]  DEFAULT ((0)) FOR [level]
GO
/****** Object:  Default [DF_dnt_myattachments_pid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_myattachments] ADD  CONSTRAINT [DF_dnt_myattachments_pid]  DEFAULT ((0)) FOR [pid]
GO
/****** Object:  Default [DF_dnt_myattachments_tid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_myattachments] ADD  CONSTRAINT [DF_dnt_myattachments_tid]  DEFAULT ((0)) FOR [tid]
GO
/****** Object:  Default [DF_dnt_myattachments_extname]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_myattachments] ADD  CONSTRAINT [DF_dnt_myattachments_extname]  DEFAULT ('') FOR [extname]
GO
/****** Object:  Default [DF_dnt_moderatormanagelog_postdatetime]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_moderatormanagelog] ADD  CONSTRAINT [DF_dnt_moderatormanagelog_postdatetime]  DEFAULT (getdate()) FOR [postdatetime]
GO
/****** Object:  Default [DF_dnt_medalslog_postdatetime]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_medalslog] ADD  CONSTRAINT [DF_dnt_medalslog_postdatetime]  DEFAULT (getdate()) FOR [postdatetime]
GO
/****** Object:  Default [DF_dnt_medals_available]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_medals] ADD  CONSTRAINT [DF_dnt_medals_available]  DEFAULT ((0)) FOR [available]
GO
/****** Object:  Default [DF_dnt_medals_image]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_medals] ADD  CONSTRAINT [DF_dnt_medals_image]  DEFAULT ('') FOR [image]
GO
/****** Object:  Default [DF_dnt_locations_city]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_locations] ADD  CONSTRAINT [DF_dnt_locations_city]  DEFAULT ('') FOR [city]
GO
/****** Object:  Default [DF_dnt_locations_state]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_locations] ADD  CONSTRAINT [DF_dnt_locations_state]  DEFAULT ('') FOR [state]
GO
/****** Object:  Default [DF_dnt_locations_country]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_locations] ADD  CONSTRAINT [DF_dnt_locations_country]  DEFAULT ('') FOR [country]
GO
/****** Object:  Default [DF_dnt_locations_zipcode]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_locations] ADD  CONSTRAINT [DF_dnt_locations_zipcode]  DEFAULT ('') FOR [zipcode]
GO
/****** Object:  Default [DF_dnt_orders_createdtime]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_orders] ADD  CONSTRAINT [DF_dnt_orders_createdtime]  DEFAULT (getdate()) FOR [createdtime]
GO
/****** Object:  Default [DF_dnt_onlinetime_thismonth]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_onlinetime] ADD  CONSTRAINT [DF_dnt_onlinetime_thismonth]  DEFAULT ((0)) FOR [thismonth]
GO
/****** Object:  Default [DF_dnt_onlinetime_total]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_onlinetime] ADD  CONSTRAINT [DF_dnt_onlinetime_total]  DEFAULT ((0)) FOR [total]
GO
/****** Object:  Default [DF_dnt_onlinetime_lastupdate]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_onlinetime] ADD  CONSTRAINT [DF_dnt_onlinetime_lastupdate]  DEFAULT (getdate()) FOR [lastupdate]
GO
/****** Object:  Default [DF_dnt_online_userid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_userid]  DEFAULT ((-1)) FOR [userid]
GO
/****** Object:  Default [DF_dnt_online_ip]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_ip]  DEFAULT ('0.0.0.0') FOR [ip]
GO
/****** Object:  Default [DF_dnt_online_username]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_username]  DEFAULT ('') FOR [username]
GO
/****** Object:  Default [DF_dnt_online_nickname]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_nickname]  DEFAULT ('') FOR [nickname]
GO
/****** Object:  Default [DF_dnt_online_password]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_password]  DEFAULT ('') FOR [password]
GO
/****** Object:  Default [DF_dnt_online_groupid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_groupid]  DEFAULT ((0)) FOR [groupid]
GO
/****** Object:  Default [DF_dnt_online_olimg]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_olimg]  DEFAULT ('') FOR [olimg]
GO
/****** Object:  Default [DF_dnt_online_adminid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_adminid]  DEFAULT ((0)) FOR [adminid]
GO
/****** Object:  Default [DF_dnt_online_invisible]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_invisible]  DEFAULT ((0)) FOR [invisible]
GO
/****** Object:  Default [DF_dnt_online_action]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_action]  DEFAULT ((0)) FOR [action]
GO
/****** Object:  Default [DF_dnt_online_lastactivity]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_lastactivity]  DEFAULT ((0)) FOR [lastactivity]
GO
/****** Object:  Default [DF_dnt_online_lastposttime]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_lastposttime]  DEFAULT ('1900-1-1 00:00:00') FOR [lastposttime]
GO
/****** Object:  Default [DF_dnt_online_lastpostpmtime]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_lastpostpmtime]  DEFAULT ('1900-1-1 00:00:00') FOR [lastpostpmtime]
GO
/****** Object:  Default [DF_dnt_online_lastsearchtime]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_lastsearchtime]  DEFAULT ('1900-1-1 00:00:00') FOR [lastsearchtime]
GO
/****** Object:  Default [DF_dnt_online_lastupdatetime]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_lastupdatetime]  DEFAULT (getdate()) FOR [lastupdatetime]
GO
/****** Object:  Default [DF_dnt_online_forumid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_forumid]  DEFAULT ((0)) FOR [forumid]
GO
/****** Object:  Default [DF_dnt_online_forumname]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_forumname]  DEFAULT ('') FOR [forumname]
GO
/****** Object:  Default [DF_dnt_online_titleid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_titleid]  DEFAULT ((0)) FOR [titleid]
GO
/****** Object:  Default [DF_dnt_online_title]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_title]  DEFAULT ('') FOR [title]
GO
/****** Object:  Default [DF_dnt_online_verifycode]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_verifycode]  DEFAULT ('') FOR [verifycode]
GO
/****** Object:  Default [DF_dnt_online_newpms]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_newpms]  DEFAULT ((0)) FOR [newpms]
GO
/****** Object:  Default [DF_dnt_online_newnotices]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_online] ADD  CONSTRAINT [DF_dnt_online_newnotices]  DEFAULT ((0)) FOR [newnotices]
GO
/****** Object:  Default [DF_dnt_topictypes_displayorder]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topictypes] ADD  CONSTRAINT [DF_dnt_topictypes_displayorder]  DEFAULT ((0)) FOR [displayorder]
GO
/****** Object:  Default [DF_dnt_topictypes_name]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topictypes] ADD  CONSTRAINT [DF_dnt_topictypes_name]  DEFAULT ('') FOR [name]
GO
/****** Object:  Default [DF_dnt_topictypes_description]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topictypes] ADD  CONSTRAINT [DF_dnt_topictypes_description]  DEFAULT ('') FOR [description]
GO
/****** Object:  Default [DF_dnt_topictags_tagid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topictags] ADD  CONSTRAINT [DF_dnt_topictags_tagid]  DEFAULT ((0)) FOR [tagid]
GO
/****** Object:  Default [DF_dnt_topictags_tid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topictags] ADD  CONSTRAINT [DF_dnt_topictags_tid]  DEFAULT ((0)) FOR [tid]
GO
/****** Object:  Default [DF_dnt_topictagcaches_tid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topictagcaches] ADD  CONSTRAINT [DF_dnt_topictagcaches_tid]  DEFAULT ((0)) FOR [tid]
GO
/****** Object:  Default [DF_dnt_topictagcaches_linktid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topictagcaches] ADD  CONSTRAINT [DF_dnt_topictagcaches_linktid]  DEFAULT ((0)) FOR [linktid]
GO
/****** Object:  Default [DF_dnt_topics_iconid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_iconid]  DEFAULT ((0)) FOR [iconid]
GO
/****** Object:  Default [DF_dnt_topics_typeid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_typeid]  DEFAULT ((0)) FOR [typeid]
GO
/****** Object:  Default [DF_dnt_topics_readperm]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_readperm]  DEFAULT ((0)) FOR [readperm]
GO
/****** Object:  Default [DF_dnt_topics_price]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_price]  DEFAULT ((0)) FOR [price]
GO
/****** Object:  Default [DF_dnt_topics_poster]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_poster]  DEFAULT ('') FOR [poster]
GO
/****** Object:  Default [DF_dnt_topics_posterid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_posterid]  DEFAULT ((0)) FOR [posterid]
GO
/****** Object:  Default [DF_dnt_topics_attention]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_attention]  DEFAULT ((0)) FOR [attention]
GO
/****** Object:  Default [DF_dnt_topics_postdatetime]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_postdatetime]  DEFAULT (getdate()) FOR [postdatetime]
GO
/****** Object:  Default [DF_dnt_topics_lastpost]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_lastpost]  DEFAULT (getdate()) FOR [lastpost]
GO
/****** Object:  Default [DF_dnt_topics_lastpostid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_lastpostid]  DEFAULT ((0)) FOR [lastpostid]
GO
/****** Object:  Default [DF_dnt_topics_lastposter]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_lastposter]  DEFAULT ('') FOR [lastposter]
GO
/****** Object:  Default [DF_dnt_topics_lastposterid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_lastposterid]  DEFAULT ((0)) FOR [lastposterid]
GO
/****** Object:  Default [DF_dnt_topics_views]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_views]  DEFAULT ((0)) FOR [views]
GO
/****** Object:  Default [DF_dnt_topics_replies]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_replies]  DEFAULT ((0)) FOR [replies]
GO
/****** Object:  Default [DF_dnt_topics_displayorder]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_displayorder]  DEFAULT ((0)) FOR [displayorder]
GO
/****** Object:  Default [DF_dnt_topics_highlight]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_highlight]  DEFAULT ('') FOR [highlight]
GO
/****** Object:  Default [DF_dnt_topics_digest]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_digest]  DEFAULT ((0)) FOR [digest]
GO
/****** Object:  Default [DF_dnt_topics_rate]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_rate]  DEFAULT ((0)) FOR [rate]
GO
/****** Object:  Default [DF_dnt_topics_blog]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_blog]  DEFAULT ((0)) FOR [hide]
GO
/****** Object:  Default [DF_dnt_topics_attachment]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_attachment]  DEFAULT ((0)) FOR [attachment]
GO
/****** Object:  Default [DF_dnt_topics_moderated]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_moderated]  DEFAULT ((0)) FOR [moderated]
GO
/****** Object:  Default [DF_dnt_topics_closed]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_closed]  DEFAULT ((0)) FOR [closed]
GO
/****** Object:  Default [DF_dnt_topics_magic]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_magic]  DEFAULT ((0)) FOR [magic]
GO
/****** Object:  Default [DF_dnt_topics_identify]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_identify]  DEFAULT ('0') FOR [identify]
GO
/****** Object:  Default [DF_dnt_topics_special]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_topics] ADD  CONSTRAINT [DF_dnt_topics_special]  DEFAULT ((0)) FOR [special]
GO
/****** Object:  Default [DF_dnt_tags_userid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_tags] ADD  CONSTRAINT [DF_dnt_tags_userid]  DEFAULT ((0)) FOR [userid]
GO
/****** Object:  Default [DF_dnt_tags_orderid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_tags] ADD  CONSTRAINT [DF_dnt_tags_orderid]  DEFAULT ((0)) FOR [orderid]
GO
/****** Object:  Default [DF_dnt_tags_count]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_tags] ADD  CONSTRAINT [DF_dnt_tags_count]  DEFAULT ((0)) FOR [count]
GO
/****** Object:  Default [DF_dnt_tags_fcount]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_tags] ADD  CONSTRAINT [DF_dnt_tags_fcount]  DEFAULT ((0)) FOR [fcount]
GO
/****** Object:  Default [DF_dnt_tags_pcount]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_tags] ADD  CONSTRAINT [DF_dnt_tags_pcount]  DEFAULT ((0)) FOR [pcount]
GO
/****** Object:  Default [DF_dnt_tags_scount]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_tags] ADD  CONSTRAINT [DF_dnt_tags_scount]  DEFAULT ((0)) FOR [scount]
GO
/****** Object:  Default [DF_dnt_tags_vcount]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_tags] ADD  CONSTRAINT [DF_dnt_tags_vcount]  DEFAULT ((0)) FOR [vcount]
GO
/****** Object:  Default [DF_dnt_tags_gcount]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_tags] ADD  CONSTRAINT [DF_dnt_tags_gcount]  DEFAULT ((0)) FOR [gcount]
GO
/****** Object:  Default [DF_dnt_tablelist_createdatetime]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_tablelist] ADD  CONSTRAINT [DF_dnt_tablelist_createdatetime]  DEFAULT (getdate()) FOR [createdatetime]
GO
/****** Object:  Default [DF_dnt_tablelist_description]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_tablelist] ADD  CONSTRAINT [DF_dnt_tablelist_description]  DEFAULT ('') FOR [description]
GO
/****** Object:  Default [DF_dnt_tablelist_mintid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_tablelist] ADD  CONSTRAINT [DF_dnt_tablelist_mintid]  DEFAULT ((-1)) FOR [mintid]
GO
/****** Object:  Default [DF_dnt_tablelist_maxtid]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_tablelist] ADD  CONSTRAINT [DF_dnt_tablelist_maxtid]  DEFAULT ((-1)) FOR [maxtid]
GO
/****** Object:  Default [DF_dnt_stats_count]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_stats] ADD  CONSTRAINT [DF_dnt_stats_count]  DEFAULT ((0)) FOR [count]
GO
/****** Object:  Default [DF__dnt_statistics__yesterdayposts]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_statistics] ADD  CONSTRAINT [DF__dnt_statistics__yesterdayposts]  DEFAULT ((0)) FOR [yesterdayposts]
GO
/****** Object:  Default [DF_dnt_statistics_highestposts]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_statistics] ADD  CONSTRAINT [DF_dnt_statistics_highestposts]  DEFAULT ((0)) FOR [highestposts]
GO
/****** Object:  Default [DF_dnt_statistics_highestpostsdate]    Script Date: 06/10/2013 22:26:03 ******/
ALTER TABLE [dbo].[dnt_statistics] ADD  CONSTRAINT [DF_dnt_statistics_highestpostsdate]  DEFAULT ('') FOR [highestpostsdate]
GO
/****** Object:  ForeignKey [FK_COU_USER]    Script Date: 06/10/2013 22:26:06 ******/
ALTER TABLE [dbo].[mry_businesscoupon]  WITH CHECK ADD  CONSTRAINT [FK_COU_USER] FOREIGN KEY([buid])
REFERENCES [dbo].[mry_businessuser] ([buid])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[mry_businesscoupon] CHECK CONSTRAINT [FK_COU_USER]
GO
/****** Object:  ForeignKey [FK_ALBUM_USER]    Script Date: 06/10/2013 22:26:06 ******/
ALTER TABLE [dbo].[mry_businessalbum]  WITH CHECK ADD  CONSTRAINT [FK_ALBUM_USER] FOREIGN KEY([buid])
REFERENCES [dbo].[mry_businessuser] ([buid])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[mry_businessalbum] CHECK CONSTRAINT [FK_ALBUM_USER]
GO
/****** Object:  ForeignKey [FK_ACT_USER]    Script Date: 06/10/2013 22:26:06 ******/
ALTER TABLE [dbo].[mry_businessactivity]  WITH CHECK ADD  CONSTRAINT [FK_ACT_USER] FOREIGN KEY([buid])
REFERENCES [dbo].[mry_businessuser] ([buid])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[mry_businessactivity] CHECK CONSTRAINT [FK_ACT_USER]
GO
/****** Object:  ForeignKey [FK_RES_USER]    Script Date: 06/10/2013 22:26:06 ******/
ALTER TABLE [dbo].[mry_businessreserve]  WITH CHECK ADD  CONSTRAINT [FK_RES_USER] FOREIGN KEY([buid])
REFERENCES [dbo].[mry_businessuser] ([buid])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[mry_businessreserve] CHECK CONSTRAINT [FK_RES_USER]
GO
/****** Object:  ForeignKey [FK_USER_QUESTION]    Script Date: 06/10/2013 22:26:06 ******/
ALTER TABLE [dbo].[mry_businessquestions]  WITH CHECK ADD  CONSTRAINT [FK_USER_QUESTION] FOREIGN KEY([buid])
REFERENCES [dbo].[mry_businessuser] ([buid])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[mry_businessquestions] CHECK CONSTRAINT [FK_USER_QUESTION]
GO
/****** Object:  ForeignKey [FK_ALBUM_PUSER]    Script Date: 06/10/2013 22:26:06 ******/
ALTER TABLE [dbo].[mry_personalbum]  WITH CHECK ADD  CONSTRAINT [FK_ALBUM_PUSER] FOREIGN KEY([puid])
REFERENCES [dbo].[mry_personuser] ([puid])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[mry_personalbum] CHECK CONSTRAINT [FK_ALBUM_PUSER]
GO
/****** Object:  ForeignKey [FK_COMMENT_NEWS]    Script Date: 06/10/2013 22:26:06 ******/
ALTER TABLE [dbo].[mry_newscomment]  WITH CHECK ADD  CONSTRAINT [FK_COMMENT_NEWS] FOREIGN KEY([newsid])
REFERENCES [dbo].[mry_news] ([newsid])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[mry_newscomment] CHECK CONSTRAINT [FK_COMMENT_NEWS]
GO
/****** Object:  ForeignKey [FK_MRY_ASKP_REFERENCE_MRY_ASKT]    Script Date: 06/10/2013 22:26:06 ******/
ALTER TABLE [dbo].[mry_askposts]  WITH CHECK ADD  CONSTRAINT [FK_MRY_ASKP_REFERENCE_MRY_ASKT] FOREIGN KEY([topcid])
REFERENCES [dbo].[mry_asktopics] ([topcid])
GO
ALTER TABLE [dbo].[mry_askposts] CHECK CONSTRAINT [FK_MRY_ASKP_REFERENCE_MRY_ASKT]
GO
/****** Object:  ForeignKey [FK_MRY_PICT_REFERENCE_MRY_PICT]    Script Date: 06/10/2013 22:26:08 ******/
ALTER TABLE [dbo].[mry_picturephoto]  WITH CHECK ADD  CONSTRAINT [FK_MRY_PICT_REFERENCE_MRY_PICT] FOREIGN KEY([albumid])
REFERENCES [dbo].[mry_picturealbum] ([albumid])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[mry_picturephoto] CHECK CONSTRAINT [FK_MRY_PICT_REFERENCE_MRY_PICT]
GO
/****** Object:  ForeignKey [FK_PPHOTO_PALBUM]    Script Date: 06/10/2013 22:26:08 ******/
ALTER TABLE [dbo].[mry_personphoto]  WITH CHECK ADD  CONSTRAINT [FK_PPHOTO_PALBUM] FOREIGN KEY([albumid])
REFERENCES [dbo].[mry_personalbum] ([albumid])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[mry_personphoto] CHECK CONSTRAINT [FK_PPHOTO_PALBUM]
GO
/****** Object:  ForeignKey [FK_PHOTO_ALBUM]    Script Date: 06/10/2013 22:26:08 ******/
ALTER TABLE [dbo].[mry_businessphoto]  WITH CHECK ADD  CONSTRAINT [FK_PHOTO_ALBUM] FOREIGN KEY([albumid])
REFERENCES [dbo].[mry_businessalbum] ([albumid])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[mry_businessphoto] CHECK CONSTRAINT [FK_PHOTO_ALBUM]
GO
