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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

CREATE TABLE [dbo].[App_Activity] (
	[ActiveID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Content] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[CreationTime] [datetime] NOT NULL ,
	[AppID] [int] NOT NULL ,
	[Params] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[App_App] (
	[AppID] [int] IDENTITY (1, 1) NOT NULL ,
	[AppName] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Description] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[CreationTime] [datetime] NOT NULL ,
	[UserID] [int] NOT NULL ,
	[IsLock] [int] NOT NULL ,
	[Url] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Icon] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Type] [int] NOT NULL ,
	[Hot] [int] NOT NULL ,
	[MidIcon] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[BigIcon] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsSys] [int] NOT NULL ,
	[AppKey] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Toadmin] [tinyint] NULL ,
	[mobile] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[tel] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[email] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[App_Developer] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[CreationTime] [datetime] NOT NULL ,
	[Enabled] [int] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[App_UserApp] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[AppID] [int] NOT NULL ,
	[CreationTime] [datetime] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_DisVote] (
	[ID] [int] NOT NULL ,
	[UserID] [int] NULL ,
	[VoteID] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_Mail] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Sender] [int] NOT NULL ,
	[Receiver] [int] NOT NULL ,
	[Title] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Content] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[TopicID] [int] NOT NULL ,
	[IsReply] [bit] NOT NULL ,
	[LtType] [int] NOT NULL ,
	[RelativeID] [int] NULL ,
	[IsRead] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_Mailinbox] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[LetterID] [int] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_Mailoutbox] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[LetterID] [int] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_admin] (
	[AdminID] [int] IDENTITY (1, 1) NOT NULL ,
	[LoginName] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[TrueName] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[Password] [char] (32) COLLATE Chinese_PRC_CI_AS NULL ,
	[LastLoginTime] [datetime] NULL ,
	[LastLoginIP] [char] (15) COLLATE Chinese_PRC_CI_AS NULL ,
	[LoginTimes] [int] NOT NULL ,
	[State] [int] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_adminlog] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[AdminID] [int] NOT NULL ,
	[ActionType] [int] NOT NULL ,
	[LogTime] [datetime] NOT NULL ,
	[LogIP] [nchar] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Description] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_album] (
	[AlbumID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Title] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Description] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ImagesCount] [int] NOT NULL ,
	[CreateTime] [datetime] NOT NULL ,
	[Privacy] [int] NOT NULL ,
	[LastUploadTime] [datetime] NULL ,
	[GroupID] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_ask] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[ClassID] [int] NULL ,
	[ParentID] [int] NULL ,
	[Title] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[Content] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[CreatTime] [datetime] NULL ,
	[jiFen] [int] NULL ,
	[UserID] [int] NULL ,
	[isLock] [tinyint] NULL ,
	[Tag] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[click] [int] NULL ,
	[Pic] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[isClose] [tinyint] NULL ,
	[isJinji] [tinyint] NULL ,
	[isBest] [tinyint] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_askClass] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[ClassName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[ParentID] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_askUser] (
	[UserID] [int] NULL ,
	[jifen] [int] NULL ,
	[huida] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_bill] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NULL ,
	[bName] [nvarchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
	[bType] [tinyint] NULL ,
	[bmoney] [money] NULL ,
	[BillTime] [datetime] NULL ,
	[CreatTime] [datetime] NULL ,
	[ClassID] [int] NULL ,
	[fID] [int] NULL ,
	[Content] [nvarchar] (150) COLLATE Chinese_PRC_CI_AS NULL ,
	[isPub] [tinyint] NULL ,
	[islock] [tinyint] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_billclass] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[parentid] [int] NULL ,
	[btype] [tinyint] NULL ,
	[className] [nvarchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
	[UserID] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_billcomment] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[title] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[UserID] [int] NULL ,
	[ParentID] [int] NULL ,
	[bID] [int] NULL ,
	[CreatTime] [datetime] NULL ,
	[islock] [tinyint] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_billfamily] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[fName] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[sex] [nvarchar] (5) COLLATE Chinese_PRC_CI_AS NULL ,
	[UserID] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_blog] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Title] [nvarchar] (40) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsLock] [bit] NOT NULL ,
	[Comments] [int] NOT NULL ,
	[Privacy] [int] NOT NULL ,
	[PicPath] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[LastModTime] [datetime] NOT NULL ,
	[Reads] [int] NOT NULL ,
	[relatUser] [ntext] COLLATE Chinese_PRC_CI_AS NULL ,
	[isRec] [tinyint] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_blogcomment] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[BlogID] [int] NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Content] [nvarchar] (300) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsLock] [bit] NOT NULL ,
	[CommentID] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_blogdraft] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Title] [nvarchar] (40) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Privacy] [int] NOT NULL ,
	[PicPath] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[IsLock] [bit] NOT NULL ,
	[LastModTime] [datetime] NOT NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_blogfoot] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[BlogID] [int] NULL ,
	[UserID] [int] NULL ,
	[CreatTime] [datetime] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_constellation] (
	[Id] [int] IDENTITY (1, 1) NOT NULL ,
	[Constellation] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_dict_academy] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Name] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[SchoolID] [int] NULL ,
	[IsLock] [bit] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_dict_area] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ParentID] [int] NOT NULL ,
	[Name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsLock] [bit] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_dict_school] (
	[SchoolID] [int] IDENTITY (1, 1) NOT NULL ,
	[DegreeID] [int] NOT NULL ,
	[AreaID] [int] NOT NULL ,
	[SchoolName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsLock] [bit] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_dict_vocation] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[VocName] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsLock] [bit] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_dyn] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[appID] [int] NULL ,
	[dynType] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[cID] [int] NULL ,
	[UserID] [int] NULL ,
	[bUserID] [int] NULL ,
	[CreatTime] [datetime] NULL ,
	[Descript] [nvarchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
	[infoarr] [nvarchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
	[IP] [nvarchar] (16) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_emailnotify] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[ItemID] [int] NOT NULL ,
	[Announce] [bit] NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_friend] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[FriendID] [int] NOT NULL ,
	[State] [int] NOT NULL ,
	[Relation] [int] NULL ,
	[AddTime] [datetime] NOT NULL ,
	[ClassID] [int] NULL ,
	[FDegree] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_friendclass] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[CName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[UserID] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_frienddesc] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Modifier] [int] NOT NULL ,
	[Affirmant] [int] NOT NULL ,
	[DescType] [int] NOT NULL ,
	[Reply] [int] NOT NULL ,
	[DescStartYear] [int] NULL ,
	[DescEndYear] [int] NULL ,
	[DescIsKnow] [bit] NULL ,
	[DescText] [nvarchar] (30) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_friendinvite] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Method] [int] NOT NULL ,
	[Invitee] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[Reply] [int] NOT NULL ,
	[Postscript] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[PostTime] [datetime] NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NULL ,
	[ReplyTime] [datetime] NULL ,
	[ReplyIP] [char] (15) COLLATE Chinese_PRC_CI_AS NULL ,
	[ValidCode] [char] (11) COLLATE Chinese_PRC_CI_AS NULL ,
	[RealEmail] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[RegUserID] [int] NULL ,
	[RealInviter] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_gbook] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[SendID] [int] NOT NULL ,
	[RecID] [int] NOT NULL ,
	[ParentID] [int] NULL ,
	[Content] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsLock] [tinyint] NOT NULL ,
	[isPub] [tinyint] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_gift] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[GName] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[Picture] [nvarchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
	[UseNumber] [int] NULL ,
	[isLock] [tinyint] NULL ,
	[point] [int] NULL ,
	[Content] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[ClassID] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_giftClass] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[CName] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_giftuser] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NULL ,
	[gID] [int] NULL ,
	[SendUserID] [int] NULL ,
	[pType] [tinyint] NULL ,
	[Content] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[CreatTime] [datetime] NULL ,
	[isDel] [tinyint] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_greet] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[FriendID] [int] NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsRead] [tinyint] NOT NULL ,
	[gType] [int] NULL ,
	[isPub] [tinyint] NULL ,
	[poketo] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[pokefrom] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[isDel] [tinyint] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_groupdiscuss] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[GroupID] [int] NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Topic] [nvarchar] (40) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL ,
	[DiscussType] [int] NOT NULL ,
	[BelongTopic] [int] NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[LastPostTime] [datetime] NULL ,
	[LastPostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NULL ,
	[LastPoster] [int] NULL ,
	[Replys] [int] NOT NULL ,
	[State] [int] NOT NULL ,
	[LastModifyTime] [datetime] NULL ,
	[LastModifyIP] [char] (15) COLLATE Chinese_PRC_CI_AS NULL ,
	[ReplyID] [int] NULL ,
	[ReplyTack] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[SeriesNum] [int] NULL ,
	[TopNum] [int] NOT NULL ,
	[isBest] [bit] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_groupinvite] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[GroupID] [int] NOT NULL ,
	[JoinUserID] [int] NOT NULL ,
	[UserID] [int] NULL ,
	[Postscript] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Response] [int] NOT NULL ,
	[RespTime] [datetime] NULL ,
	[RespIP] [char] (15) COLLATE Chinese_PRC_CI_AS NULL ,
	[InviteFlag] [bit] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_groupmember] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[GroupID] [int] NOT NULL ,
	[UserID] [int] NOT NULL ,
	[JoinTime] [datetime] NOT NULL ,
	[Grade] [int] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_help] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[SN] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Title] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_message] (
	[id] [int] NOT NULL ,
	[title] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[content] [ntext] COLLATE Chinese_PRC_CI_AS NULL ,
	[CreatTime] [datetime] NULL ,
	[isRec] [tinyint] NULL ,
	[isLock] [tinyint] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_mood] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Content] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsLock] [bit] NOT NULL ,
	[Comments] [int] NOT NULL ,
	[MType] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL ,
	[isRec] [tinyint] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_moodcomment] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Commentator] [int] NOT NULL ,
	[MiniBlogID] [int] NOT NULL ,
	[Content] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[CommentID] [int] NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsLock] [bit] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_movie] (
	[MovieID] [int] IDENTITY (1, 1) NOT NULL ,
	[Title] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Director] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Billing] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[YearOnShow] [int] NULL ,
	[Gut] [ntext] COLLATE Chinese_PRC_CI_AS NULL ,
	[Comments] [int] NULL ,
	[Score] [int] NULL ,
	[Seen] [int] NULL ,
	[Wanna] [int] NULL ,
	[Wonna] [int] NULL ,
	[SortID] [int] NULL ,
	[PosterFile] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL ,
	[zt_dy] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[zt_dy1] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[zt_url] [ntext] COLLATE Chinese_PRC_CI_AS NULL ,
	[zt_url1] [ntext] COLLATE Chinese_PRC_CI_AS NULL ,
	[UserID] [int] NULL ,
	[hits] [int] NULL ,
	[Comment] [int] NULL ,
	[CreatTime] [datetime] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_moviecomment] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[MovieID] [int] NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Score] [int] NULL ,
	[Comment] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_movieposter] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[MovieID] [int] NOT NULL ,
	[UserID] [int] NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[FileName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[islock] [tinyint] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_moviesort] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[SortName] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_movieurl] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[MovieID] [int] NULL ,
	[UserID] [int] NULL ,
	[PicURL] [nvarchar] (300) COLLATE Chinese_PRC_CI_AS NULL ,
	[MovieName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[MovieURL] [nvarchar] (300) COLLATE Chinese_PRC_CI_AS NULL ,
	[CreatTime] [datetime] NULL ,
	[isLock] [tinyint] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_news] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[title] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL ,
	[UserID] [int] NULL ,
	[ClassID] [int] NULL ,
	[CreatTime] [datetime] NULL ,
	[islock] [tinyint] NULL ,
	[IP] [nvarchar] (15) COLLATE Chinese_PRC_CI_AS NULL ,
	[click] [int] NULL ,
	[isSys] [tinyint] NULL ,
	[shareNum] [int] NULL ,
	[pic] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_newsclass] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[className] [nvarchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
	[ParentID] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_newscomment] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[newsID] [int] NULL ,
	[content] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[UserID] [int] NULL ,
	[parentID] [int] NULL ,
	[IP] [nvarchar] (15) COLLATE Chinese_PRC_CI_AS NULL ,
	[CreatTime] [datetime] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_notepad] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[title] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Content] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[TXTime] [datetime] NULL ,
	[LastPostTime] [datetime] NOT NULL ,
	[LastPostIP] [nvarchar] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsLock] [tinyint] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_notice] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Receiver] [int] NOT NULL ,
	[Content] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[IsRead] [bit] NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Sender] [int] NULL ,
	[MsgType] [int] NOT NULL ,
	[Correspond] [int] NULL ,
	[IsLock] [bit] NOT NULL ,
	[IsDel] [bit] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_onlineuser] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NULL ,
	[LastIP] [nvarchar] (18) COLLATE Chinese_PRC_CI_AS NULL ,
	[LastUrl] [nvarchar] (256) COLLATE Chinese_PRC_CI_AS NULL ,
	[LastTime] [datetime] NULL ,
	[UserName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_photo] (
	[PhotoID] [int] IDENTITY (1, 1) NOT NULL ,
	[AlbumID] [int] NOT NULL ,
	[UploadUser] [int] NOT NULL ,
	[Description] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
	[Views] [int] NOT NULL ,
	[FileSize] [int] NOT NULL ,
	[State] [int] NOT NULL ,
	[IsCover] [bit] NOT NULL ,
	[Comments] [int] NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsLock] [bit] NOT NULL ,
	[PhotoType] [int] NOT NULL ,
	[Width] [int] NULL ,
	[Height] [int] NULL ,
	[FilePath] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_photocomment] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[PhotoID] [int] NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Content] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [nvarchar] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsLock] [bit] NOT NULL ,
	[CommentID] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_photolasso] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[PhotoID] [int] NOT NULL ,
	[FriendID] [int] NOT NULL ,
	[UserID] [int] NOT NULL ,
	[PosX] [int] NOT NULL ,
	[PosY] [int] NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsLock] [bit] NOT NULL ,
	[Description] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[PosW] [int] NULL ,
	[PosH] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_request] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Receiver] [int] NOT NULL ,
	[Demander] [int] NOT NULL ,
	[RequestType] [int] NOT NULL ,
	[Content] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ReplyResult] [int] NOT NULL ,
	[ReplyScript] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[ReplyTime] [datetime] NULL ,
	[ReplyIP] [char] (15) COLLATE Chinese_PRC_CI_AS NULL ,
	[CorrespondInfo] [int] NULL ,
	[IsLock] [bit] NOT NULL ,
	[IsDel] [bit] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_retrievepwd] (
	[ValidCode] [char] (32) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Email] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[State] [int] NOT NULL ,
	[ConfirmTime] [datetime] NULL ,
	[ConfirmIP] [char] (15) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_share] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Title] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Description] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
	[URL] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[ShareType] [int] NULL ,
	[CaseID] [int] NULL ,
	[IsLock] [bit] NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Comments] [int] NOT NULL ,
	[Privacy] [int] NOT NULL ,
	[FriendIDGroup] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_sharecomment] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[ShareID] [int] NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Content] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsLock] [bit] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_spacetemplate] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[TName] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[TPath] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[CreatTime] [datetime] NOT NULL ,
	[TPicture] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[IsLock] [tinyint] NOT NULL ,
	[IPoint] [int] NULL ,
	[GPoint] [int] NULL ,
	[isBG] [tinyint] NULL ,
	[UserID] [int] NULL ,
	[UserNumber] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_spareemail] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Email] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[PostTime] [datetime] NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_tovote] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NULL ,
	[VoteID] [int] NULL ,
	[OptionID] [nvarchar] (3000) COLLATE Chinese_PRC_CI_AS NULL ,
	[Content] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_user] (
	[UserID] [int] IDENTITY (1, 1) NOT NULL ,
	[Email] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Password] [nchar] (32) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[UserName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[State] [int] NOT NULL ,
	[LastLoginTime] [datetime] NULL ,
	[LastLoginIP] [nvarchar] (15) COLLATE Chinese_PRC_CI_AS NULL ,
	[LoginTimes] [int] NOT NULL ,
	[Province] [int] NOT NULL ,
	[City] [int] NULL ,
	[RegTime] [datetime] NOT NULL ,
	[RegIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Portrait] [int] NULL ,
	[InviterID] [int] NULL ,
	[VerifyCode] [char] (11) COLLATE Chinese_PRC_CI_AS NULL ,
	[ConfirmTime] [datetime] NULL ,
	[isRec] [tinyint] NULL ,
	[integral] [int] NULL ,
	[inteyb] [int] NULL ,
	[Click] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_usercareer] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Company] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Description] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
	[IsStill] [bit] NOT NULL ,
	[JoinYear] [int] NULL ,
	[JoinMonth] [int] NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[LeaveYear] [int] NULL ,
	[LeaveMonth] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_usereducation] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[DegreeID] [int] NOT NULL ,
	[SchoolID] [int] NOT NULL ,
	[AcademyID] [int] NULL ,
	[MatriculationYear] [int] NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[IsLock] [bit] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_usergroup] (
	[GroupID] [int] IDENTITY (1, 1) NOT NULL ,
	[GroupName] [nvarchar] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[UserID] [int] NOT NULL ,
	[Members] [int] NOT NULL ,
	[Bulletin] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[NetWork] [int] NOT NULL ,
	[Publicity] [int] NOT NULL ,
	[Portrait] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[State] [int] NOT NULL ,
	[PostTime] [datetime] NOT NULL ,
	[PostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[isRec] [tinyint] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_userinfo] (
	[UserID] [int] NOT NULL ,
	[Sex] [bit] NOT NULL ,
	[Birthday] [datetime] NULL ,
	[BirthidayDisplay] [int] NULL ,
	[Marriage] [tinyint] NULL ,
	[Constellation] [int] NULL ,
	[MSN] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[GTalk] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[QQ] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[Skype] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Mobile] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[MobilePrivacy] [int] NULL ,
	[EmailPrivacy] [int] NULL ,
	[Tel] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[Addr] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[WebSite] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Favourite] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[FavMusics] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[FavMovies] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[FavCartoons] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[FavGames] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[FavSports] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[FavBooks] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[FavAdages] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[AppreciateMen] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[Presentation] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[Vocation] [int] NULL ,
	[HomeProv] [int] NULL ,
	[HomeCity] [int] NULL ,
	[MSNPrivacy] [int] NULL ,
	[GTalkPrivacy] [int] NULL ,
	[QQPrivacy] [int] NULL ,
	[SkypePrivacy] [int] NULL ,
	[TelPrivacy] [int] NULL ,
	[AddrPrivacy] [int] NULL ,
	[WebSitePrivacy] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_userlog] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[ActionType] [int] NOT NULL ,
	[LogTime] [datetime] NOT NULL ,
	[LogIP] [nchar] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Description] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Remark] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[CorrespondInfo] [int] NULL ,
	[IsLock] [bit] NOT NULL ,
	[IsDel] [bit] NOT NULL ,
	[CorreUserID] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_userpointhistory] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NULL ,
	[Content] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Point] [int] NULL ,
	[GPoint] [int] NULL ,
	[UTF] [tinyint] NULL ,
	[CreatTime] [datetime] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_usersetting] (
	[UserID] [int] NOT NULL ,
	[PrivSpace] [int] NOT NULL ,
	[PrivFavourite] [int] NOT NULL ,
	[PrivEducate] [int] NOT NULL ,
	[PrivLasso] [int] NOT NULL ,
	[PrivFriends] [int] NOT NULL ,
	[PrivLeaveWord] [int] NOT NULL ,
	[PrivMiniBlog] [int] NOT NULL ,
	[PrivShare] [int] NOT NULL ,
	[PrivGroup] [int] NOT NULL ,
	[PrivMovies] [int] NOT NULL ,
	[ActUpdateData] [bit] NOT NULL ,
	[ActAddFriend] [bit] NOT NULL ,
	[ActLeaveWord] [bit] NOT NULL ,
	[ActPicComment] [bit] NOT NULL ,
	[ActSecede] [bit] NOT NULL ,
	[ActDeliver] [bit] NOT NULL ,
	[ActLogComment] [bit] NOT NULL ,
	[ActMovieComment] [bit] NOT NULL ,
	[ActPhotoLasso] [bit] NOT NULL ,
	[ActShareComment] [bit] NOT NULL ,
	[LastPostTime] [datetime] NOT NULL ,
	[LastPostIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_visit] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[VisitorID] [int] NOT NULL ,
	[LastVisitTime] [datetime] NOT NULL ,
	[LastVisitIP] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[VisitTimes] [int] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_vote] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Title] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[Intro] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[UserID] [int] NULL ,
	[AddTime] [datetime] NULL ,
	[Mode] [int] NULL ,
	[EndTime] [datetime] NULL ,
	[JCnt] [int] NULL ,
	[VCnt] [int] NULL ,
	[IsFriend] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_votecomm] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NULL ,
	[VoteID] [int] NULL ,
	[Content] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[PID] [int] NULL ,
	[AddTime] [datetime] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NT_voteoption] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[VoteID] [int] NULL ,
	[OptionName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[Cnt] [int] NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[App_Activity] WITH NOCHECK ADD 
	CONSTRAINT [PK_APP_ACTIVITY] PRIMARY KEY  CLUSTERED 
	(
		[ActiveID]
	)  ON [PRIMARY] 
GO

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

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

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

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

ALTER TABLE [dbo].[NT_admin] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_Admin] PRIMARY KEY  CLUSTERED 
	(
		[AdminID]
	)  ON [PRIMARY] 
GO

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

ALTER TABLE [dbo].[NT_album] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_AlbumCategory] PRIMARY KEY  CLUSTERED 
	(
		[AlbumID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[NT_ask] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_ask] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[NT_askClass] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_askClass] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[NT_bill] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_bill] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[NT_billclass] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_billclass] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[NT_billcomment] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_billcomment] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[NT_billfamily] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_billfamily] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

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

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

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

ALTER TABLE [dbo].[NT_blogfoot] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_BlogFoot] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[NT_constellation] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_Constellation] PRIMARY KEY  CLUSTERED 
	(
		[Id]
	)  ON [PRIMARY] 
GO

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

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

ALTER TABLE [dbo].[NT_dict_school] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_DICT_SCHOOL] PRIMARY KEY  CLUSTERED 
	(
		[SchoolID]
	)  ON [PRIMARY] 
GO

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

ALTER TABLE [dbo].[NT_dyn] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_dyn] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

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

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

ALTER TABLE [dbo].[NT_friendclass] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_FriendClass] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

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

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

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

ALTER TABLE [dbo].[NT_gift] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_Gift_1] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

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

ALTER TABLE [dbo].[NT_giftuser] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_Gift] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

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

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

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

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

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

ALTER TABLE [dbo].[NT_message] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_Message] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

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

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

ALTER TABLE [dbo].[NT_movie] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_Movie] PRIMARY KEY  CLUSTERED 
	(
		[MovieID]
	)  ON [PRIMARY] 
GO

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

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

ALTER TABLE [dbo].[NT_moviesort] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_MovieSort] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[NT_movieurl] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_MovieURL] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[NT_news] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_news] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[NT_newsclass] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_newsclass] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[NT_newscomment] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_newscomment] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

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

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

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

ALTER TABLE [dbo].[NT_photo] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_Photos] PRIMARY KEY  CLUSTERED 
	(
		[PhotoID]
	)  ON [PRIMARY] 
GO

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

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

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

ALTER TABLE [dbo].[NT_retrievepwd] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_RetrievePwd] PRIMARY KEY  CLUSTERED 
	(
		[ValidCode]
	)  ON [PRIMARY] 
GO

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

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

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

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

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

ALTER TABLE [dbo].[NT_user] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_User] PRIMARY KEY  CLUSTERED 
	(
		[UserID]
	)  ON [PRIMARY] 
GO

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

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

ALTER TABLE [dbo].[NT_usergroup] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_UserGroup] PRIMARY KEY  CLUSTERED 
	(
		[GroupID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[NT_userinfo] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_UserInfo] PRIMARY KEY  CLUSTERED 
	(
		[UserID]
	)  ON [PRIMARY] 
GO

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

ALTER TABLE [dbo].[NT_userpointhistory] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_UserPointHistory] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[NT_usersetting] WITH NOCHECK ADD 
	CONSTRAINT [PK_NT_USERSETTING] PRIMARY KEY  CLUSTERED 
	(
		[UserID]
	)  ON [PRIMARY] 
GO

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

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

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

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

ALTER TABLE [dbo].[App_App] ADD 
	CONSTRAINT [DF_App_App_Toadmin] DEFAULT (0) FOR [Toadmin],
	CONSTRAINT [PK_APP_APP] PRIMARY KEY  NONCLUSTERED 
	(
		[AppID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[App_Developer] ADD 
	CONSTRAINT [PK_APP_DEVELOPER] PRIMARY KEY  NONCLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[App_UserApp] ADD 
	CONSTRAINT [PK_APP_USERAPP] PRIMARY KEY  NONCLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[NT_Mail] ADD 
	CONSTRAINT [DF__NT_Letter__Topic__53B90BF3] DEFAULT (0) FOR [TopicID],
	CONSTRAINT [DF__NT_Letter__IsRep__54AD302C] DEFAULT (0) FOR [IsReply],
	CONSTRAINT [DF__NT_Letter__LtTyp__55A15465] DEFAULT (0) FOR [LtType]
GO

 CREATE  INDEX [Mail_S_R] ON [dbo].[NT_Mail]([Sender], [Receiver], [TopicID]) ON [PRIMARY]
GO

 CREATE  INDEX [Box_U_L] ON [dbo].[NT_Mailinbox]([UserID], [LetterID]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_admin] ADD 
	CONSTRAINT [DF__NT_Admin__LoginT__6BFAA9D8] DEFAULT (0) FOR [LoginTimes],
	CONSTRAINT [DF__NT_Admin__State__6CEECE11] DEFAULT (0) FOR [State]
GO

ALTER TABLE [dbo].[NT_album] ADD 
	CONSTRAINT [DF_NT_AlbumCategory_ImagesCount] DEFAULT (0) FOR [ImagesCount]
GO

 CREATE  INDEX [Album_UserID_Time] ON [dbo].[NT_album]([UserID], [CreateTime]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_ask] ADD 
	CONSTRAINT [DF_NT_ask_ClassID] DEFAULT (0) FOR [ClassID],
	CONSTRAINT [DF_NT_ask_ParentID] DEFAULT (0) FOR [ParentID],
	CONSTRAINT [DF_NT_ask_jiFen] DEFAULT (0) FOR [jiFen],
	CONSTRAINT [DF_NT_ask_UserID] DEFAULT (0) FOR [UserID],
	CONSTRAINT [DF_NT_ask_isLock] DEFAULT (0) FOR [isLock],
	CONSTRAINT [DF_NT_ask_click] DEFAULT (0) FOR [click],
	CONSTRAINT [DF_NT_ask_isClose] DEFAULT (0) FOR [isClose],
	CONSTRAINT [DF_NT_ask_isJinji] DEFAULT (0) FOR [isJinji],
	CONSTRAINT [DF_NT_ask_isBest] DEFAULT (0) FOR [isBest]
GO

ALTER TABLE [dbo].[NT_askUser] ADD 
	CONSTRAINT [DF_NT_askUser_huida] DEFAULT (0) FOR [huida]
GO

ALTER TABLE [dbo].[NT_blog] ADD 
	CONSTRAINT [DF__NT_Blog__IsLock__17A421EC] DEFAULT (0) FOR [IsLock],
	CONSTRAINT [DF__NT_Blog__Comment__18984625] DEFAULT (0) FOR [Comments],
	CONSTRAINT [DF_NT_Blog_Reads] DEFAULT (0) FOR [Reads]
GO

 CREATE  INDEX [Blog_User_P] ON [dbo].[NT_blog]([ID], [UserID], [IsLock], [Privacy]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_blogcomment] ADD 
	CONSTRAINT [DF__NT_BLogCo__IsLoc__748FEFD9] DEFAULT (0) FOR [IsLock],
	CONSTRAINT [DF_NT_BlogComment_CommentID] DEFAULT (0) FOR [CommentID]
GO

ALTER TABLE [dbo].[NT_blogdraft] ADD 
	CONSTRAINT [DF__NT_BlogDr__IsLoc__1B74B2D0] DEFAULT (0) FOR [IsLock]
GO

ALTER TABLE [dbo].[NT_dict_academy] ADD 
	CONSTRAINT [DF__NT_Dict_A__IsLoc__7E195A13] DEFAULT (0) FOR [IsLock]
GO

ALTER TABLE [dbo].[NT_dict_area] ADD 
	CONSTRAINT [DF_NT_Dict_Area_ParentID] DEFAULT (0) FOR [ParentID],
	CONSTRAINT [DF__NT_Dict_A__IsLoc__1F4543B4] DEFAULT (0) FOR [IsLock]
GO

 CREATE  INDEX [Area_ParentID] ON [dbo].[NT_dict_area]([ParentID]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_dict_school] ADD 
	CONSTRAINT [DF__NT_Dict_S__IsLoc__03D23369] DEFAULT (0) FOR [IsLock]
GO

 CREATE  INDEX [DYN_USERID_B] ON [dbo].[NT_dyn]([cID], [UserID], [bUserID], [infoarr]) ON [PRIMARY]
GO

 CREATE  INDEX [DYN_UserID_Time] ON [dbo].[NT_dyn]([id], [UserID], [CreatTime]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_friend] ADD 
	CONSTRAINT [DF__NT_Friend__State__17D92C16] DEFAULT (0) FOR [State],
	CONSTRAINT [DF_NT_friend_FDegree] DEFAULT (0) FOR [FDegree]
GO

 CREATE  INDEX [Friend_UserID_F] ON [dbo].[NT_friend]([UserID], [FriendID], [State]) ON [PRIMARY]
GO

 CREATE  INDEX [Friend_UserID_S] ON [dbo].[NT_friend]([UserID], [State]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_frienddesc] ADD 
	CONSTRAINT [DF__NT_Friend__Reply__1AB598C1] DEFAULT (0) FOR [Reply]
GO

ALTER TABLE [dbo].[NT_friendinvite] ADD 
	CONSTRAINT [DF__NT_Friend__Posts__1D92056C] DEFAULT ('0') FOR [Postscript]
GO

ALTER TABLE [dbo].[NT_gbook] ADD 
	CONSTRAINT [DF__NT_LeaveW__IsLoc__30A4D9E0] DEFAULT (0) FOR [IsLock]
GO

 CREATE  INDEX [GBook_S_R] ON [dbo].[NT_gbook]([SendID], [RecID], [IsLock]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_gift] ADD 
	CONSTRAINT [DF_NT_gift_ClassID] DEFAULT (0) FOR [ClassID]
GO

 CREATE  INDEX [PK_GIFT_Lock] ON [dbo].[NT_gift]([id], [isLock]) ON [PRIMARY]
GO

 CREATE  INDEX [PK_GIFT_GID] ON [dbo].[NT_giftuser]([UserID], [gID]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_greet] ADD 
	CONSTRAINT [DF__NT_Greet__IsRead__206E7217] DEFAULT (0) FOR [IsRead]
GO

 CREATE  INDEX [Greet_U_F] ON [dbo].[NT_greet]([UserID], [FriendID], [isDel]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_groupdiscuss] ADD 
	CONSTRAINT [DF__NT_GroupD__Discu__234ADEC2] DEFAULT (0) FOR [DiscussType],
	CONSTRAINT [DF__NT_GroupD__Reply__243F02FB] DEFAULT (0) FOR [Replys],
	CONSTRAINT [DF__NT_GroupD__State__25332734] DEFAULT (0) FOR [State],
	CONSTRAINT [DF__NT_GroupD__TopNu__26274B6D] DEFAULT (0) FOR [TopNum]
GO

 CREATE  INDEX [Discuss_User_O] ON [dbo].[NT_groupdiscuss]([GroupID], [UserID], [State], [TopNum], [isBest]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_groupinvite] ADD 
	CONSTRAINT [DF__NT_GroupI__Respo__2903B818] DEFAULT (0) FOR [Response]
GO

ALTER TABLE [dbo].[NT_mood] ADD 
	CONSTRAINT [DF__NT_MiniBl__IsLoc__3845FBA8] DEFAULT (0) FOR [IsLock],
	CONSTRAINT [DF_NT_MiniBlog_Comments] DEFAULT (0) FOR [Comments],
	CONSTRAINT [DF_NT_MiniBlog_isRec] DEFAULT (0) FOR [isRec]
GO

 CREATE  INDEX [Mood_U] ON [dbo].[NT_mood]([UserID], [IsLock]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_moodcomment] ADD 
	CONSTRAINT [DF_NT_MiniBlogComment_CommentID] DEFAULT (0) FOR [CommentID],
	CONSTRAINT [DF_NT_MiniBlogComment_IsLock] DEFAULT (0) FOR [IsLock]
GO

 CREATE  INDEX [Movie_Y_C] ON [dbo].[NT_movie]([YearOnShow], [Comments], [Score]) ON [PRIMARY]
GO

 CREATE  INDEX [Movie_U_S] ON [dbo].[NT_movie]([MovieID], [SortID], [UserID]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_movieposter] ADD 
	CONSTRAINT [DF_NT_movieposter_islock] DEFAULT (0) FOR [islock]
GO

 CREATE  INDEX [idx_movieID,UserID] ON [dbo].[NT_movieurl]([MovieID], [UserID]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_notepad] ADD 
	CONSTRAINT [DF__NT_Notepa__IsLoc__26E6657C] DEFAULT (0) FOR [IsLock]
GO

ALTER TABLE [dbo].[NT_notice] ADD 
	CONSTRAINT [DF__NT_Notice__IsRea__459FF6C6] DEFAULT (0) FOR [IsRead],
	CONSTRAINT [DF__NT_Notice__IsLoc__46941AFF] DEFAULT (0) FOR [IsLock],
	CONSTRAINT [DF__NT_Notice__IsDel__47883F38] DEFAULT (0) FOR [IsDel]
GO

 CREATE  INDEX [Notice_S_R] ON [dbo].[NT_notice]([Receiver], [Sender], [IsLock], [IsDel]) ON [PRIMARY]
GO

 CREATE  INDEX [Online_UserID] ON [dbo].[NT_onlineuser]([UserID]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_photo] ADD 
	CONSTRAINT [DF_NT_Photo_ViewTimes] DEFAULT (0) FOR [Views],
	CONSTRAINT [DF_NT_Photo_FileSize] DEFAULT (0) FOR [FileSize],
	CONSTRAINT [DF_NT_Photo_IsCover] DEFAULT (0) FOR [IsCover],
	CONSTRAINT [DF_NT_Photo_CommentCount] DEFAULT (0) FOR [Comments],
	CONSTRAINT [DF__NT_Photo__IsLock__2D93630B] DEFAULT (0) FOR [IsLock]
GO

 CREATE  INDEX [Photo_UserID] ON [dbo].[NT_photo]([AlbumID], [UploadUser], [IsLock], [FilePath]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_photocomment] ADD 
	CONSTRAINT [DF__NT_PhotoC__IsLoc__4F296100] DEFAULT (0) FOR [IsLock],
	CONSTRAINT [DF_NT_PhotoComment_CommentID] DEFAULT (0) FOR [CommentID]
GO

ALTER TABLE [dbo].[NT_photolasso] ADD 
	CONSTRAINT [DF__NT_PhotoL__IsLoc__5205CDAB] DEFAULT (0) FOR [IsLock]
GO

ALTER TABLE [dbo].[NT_request] ADD 
	CONSTRAINT [DF__NT_Reques__Reply__54E23A56] DEFAULT (0) FOR [ReplyResult],
	CONSTRAINT [DF__NT_Reques__IsLoc__55D65E8F] DEFAULT (0) FOR [IsLock],
	CONSTRAINT [DF__NT_Reques__IsDel__56CA82C8] DEFAULT (0) FOR [IsDel]
GO

 CREATE  INDEX [Request_N_F] ON [dbo].[NT_request]([Receiver], [Demander], [IsLock]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_retrievepwd] ADD 
	CONSTRAINT [DF_NT_RetrievePwd_State] DEFAULT (0) FOR [State]
GO

ALTER TABLE [dbo].[NT_share] ADD 
	CONSTRAINT [DF__NT_Share__IsLock__59A6EF73] DEFAULT (0) FOR [IsLock],
	CONSTRAINT [DF__NT_Share__Commen__5A9B13AC] DEFAULT (0) FOR [Comments],
	CONSTRAINT [DF__NT_Share__Privac__5B8F37E5] DEFAULT (0) FOR [Privacy]
GO

 CREATE  INDEX [Share_UserID_C] ON [dbo].[NT_share]([UserID], [ShareType], [CaseID]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_sharecomment] ADD 
	CONSTRAINT [DF__NT_ShareC__IsLoc__5E6BA490] DEFAULT (0) FOR [IsLock]
GO

ALTER TABLE [dbo].[NT_user] ADD 
	CONSTRAINT [DF_NT_User_LoginTimes] DEFAULT (0) FOR [LoginTimes],
	CONSTRAINT [DF_NT_User_integral] DEFAULT (0) FOR [integral],
	CONSTRAINT [DF_NT_User_inteyb] DEFAULT (0) FOR [inteyb]
GO

 CREATE  UNIQUE  INDEX [IX_NT_User] ON [dbo].[NT_user]([Email], [UserID]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_NT_State] ON [dbo].[NT_user]([State], [LastLoginTime]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_usercareer] ADD 
	CONSTRAINT [CK_NT_UserCareer] CHECK ([JoinMonth] > 0 and [JoinMonth] < 13)
GO

ALTER TABLE [dbo].[NT_usergroup] ADD 
	CONSTRAINT [DF__NT_UserGr__Membe__67F50ECA] DEFAULT (1) FOR [Members]
GO

ALTER TABLE [dbo].[NT_userinfo] ADD 
	CONSTRAINT [DF_NT_userinfo_Birthday] DEFAULT (1900 - 1 - 1) FOR [Birthday],
	CONSTRAINT [DF_NT_userinfo_BirthidayDisplay] DEFAULT (0) FOR [BirthidayDisplay],
	CONSTRAINT [DF_NT_userinfo_Constellation] DEFAULT (0) FOR [Constellation],
	CONSTRAINT [DF_NT_userinfo_MobilePrivacy] DEFAULT (0) FOR [MobilePrivacy],
	CONSTRAINT [DF_NT_userinfo_EmailPrivacy] DEFAULT (0) FOR [EmailPrivacy],
	CONSTRAINT [DF_NT_userinfo_MSNPrivacy] DEFAULT (0) FOR [MSNPrivacy],
	CONSTRAINT [DF_NT_userinfo_GTalkPrivacy] DEFAULT (0) FOR [GTalkPrivacy],
	CONSTRAINT [DF_NT_userinfo_QQPrivacy] DEFAULT (0) FOR [QQPrivacy],
	CONSTRAINT [DF_NT_userinfo_SkypePrivacy] DEFAULT (0) FOR [SkypePrivacy],
	CONSTRAINT [DF_NT_userinfo_TelPrivacy] DEFAULT (0) FOR [TelPrivacy],
	CONSTRAINT [DF_NT_userinfo_AddrPrivacy] DEFAULT (0) FOR [AddrPrivacy],
	CONSTRAINT [DF_NT_userinfo_WebSitePrivacy] DEFAULT (0) FOR [WebSitePrivacy]
GO

 CREATE  INDEX [UserBase_Sex] ON [dbo].[NT_userinfo]([UserID], [Sex]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_userlog] ADD 
	CONSTRAINT [DF__NT_UserLo__IsLoc__6CB9C3E7] DEFAULT (0) FOR [IsLock],
	CONSTRAINT [DF__NT_UserLo__IsDel__6DADE820] DEFAULT (0) FOR [IsDel]
GO

 CREATE  INDEX [UP_UG] ON [dbo].[NT_userpointhistory]([UserID], [Point], [GPoint]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NT_usersetting] ADD 
	CONSTRAINT [DF_NT_usersetting_ActUpdateData] DEFAULT (1) FOR [ActUpdateData],
	CONSTRAINT [DF_NT_usersetting_ActAddFriend] DEFAULT (1) FOR [ActAddFriend],
	CONSTRAINT [DF_NT_usersetting_ActPicComment] DEFAULT (1) FOR [ActPicComment],
	CONSTRAINT [DF_NT_usersetting_ActSecede] DEFAULT (1) FOR [ActSecede],
	CONSTRAINT [DF_NT_usersetting_ActDeliver] DEFAULT (1) FOR [ActDeliver],
	CONSTRAINT [DF_NT_usersetting_ActLogComment] DEFAULT (1) FOR [ActLogComment],
	CONSTRAINT [DF_NT_usersetting_ActMovieComment] DEFAULT (1) FOR [ActMovieComment],
	CONSTRAINT [DF_NT_usersetting_ActPhotoLasso] DEFAULT (1) FOR [ActPhotoLasso],
	CONSTRAINT [DF_NT_usersetting_ActShareComment] DEFAULT (1) FOR [ActShareComment]
GO

ALTER TABLE [dbo].[NT_visit] ADD 
	CONSTRAINT [DF_NT_Visit_VisitTimes] DEFAULT (1) FOR [VisitTimes]
GO

 CREATE  INDEX [Visit_U_V] ON [dbo].[NT_visit]([UserID], [VisitorID]) ON [PRIMARY]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO




CREATE VIEW dbo.NTV_FriendDetail
AS
SELECT a.ID,a.UserID,a.FriendID, b.DescType
FROM dbo.NT_Friend a LEFT JOIN
      dbo.NT_FriendDesc b ON a.UserID = b.Modifier AND a.FriendID = b.Affirmant OR 
      a.UserID = b.Affirmant AND a.FriendID = b.Modifier




GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO




CREATE VIEW dbo.NTV_FriendDetailStat
AS
SELECT Modifier, Affirmant, DescType
FROM dbo.NT_FriendDesc
GROUP BY Modifier, Affirmant, DescType




GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_AddMovieSort
@SortName nvarchar(50)
as
begin
	Insert Into NT_MovieSort(SortName) values(@SortName)
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_AddPoke
@UserID int,
@FriendID int,
@PostTime DateTime,
@PostIP char(15),
@IsRead tinyint,
@gType int,
@isPub tinyint,
@poketo nvarchar(50),
@pokefrom nvarchar(50)
as

begin
	insert into NT_Greet (UserID,FriendID,PostTime,PostIP,IsRead,gType,isPub,poketo,pokefrom,isDel) values (@UserID,@FriendID,@PostTime,@PostIP,@IsRead,@gType,@isPub,@poketo,@pokefrom,0)
	Select @@IDENTITY
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_BillStat
@Num int=1,--返回记录数
@UserID int
as 
begin
	if @Num=0--本月总收支
	begin 
		select sum(bmoney) from NT_Bill where DATEPART(mm, BillTime) = DATEPART(mm, GETDATE()) and DATEPART(yy, BillTime) = DATEPART(yy, GETDATE()) and UserID=@UserID and islock=0
	end
	if @Num=1--本月支出
	begin 
		select sum(bmoney) from NT_Bill where DATEPART(mm, BillTime) = DATEPART(mm, GETDATE()) and DATEPART(yy, BillTime) = DATEPART(yy, GETDATE()) and UserID=@UserID and bType=1 and islock=0	
	end
	if @Num=2--本月收入
	begin 
		select sum(bmoney) from NT_Bill where DATEPART(mm, BillTime) = DATEPART(mm, GETDATE()) and DATEPART(yy, BillTime) = DATEPART(yy, GETDATE()) and UserID=@UserID and bType=0 and islock=0	
	end
	if @Num=3--本周总收支
	begin 
		select sum(bmoney) from NT_Bill where DATEPART(wk, BillTime) = DATEPART(wk, GETDATE()) and DATEPART(yy, BillTime) = DATEPART(yy, GETDATE()) and UserID=@UserID and islock=0
	end
	if @Num=4--本周支出
	begin 
		select sum(bmoney) from NT_Bill where DATEPART(wk, BillTime) = DATEPART(wk, GETDATE()) and DATEPART(yy, BillTime) = DATEPART(yy, GETDATE()) and UserID=@UserID and islock=0 and bType=1
	end
	if @Num=5--本周收入
	begin 
		select sum(bmoney) from NT_Bill where DATEPART(wk, BillTime) = DATEPART(wk, GETDATE()) and DATEPART(yy, BillTime) = DATEPART(yy, GETDATE()) and UserID=@UserID and islock=0 and bType=0
	end

	if @Num=6--本季度总收支
	begin 
		select sum(bmoney) from NT_Bill where DATEPART(qq, BillTime) = DATEPART(qq, GETDATE()) and DATEPART(yy, BillTime) = DATEPART(yy, GETDATE()) and UserID=@UserID and islock=0
	end
	if @Num=7--本季度支出
	begin 
		select sum(bmoney) from NT_Bill where DATEPART(qq, BillTime) = DATEPART(qq, GETDATE()) and DATEPART(yy, BillTime) = DATEPART(yy, GETDATE()) and UserID=@UserID and islock=0 and bType=1
	end
	if @Num=8--本季度收入
	begin 
		select sum(bmoney) from NT_Bill where DATEPART(qq, BillTime) = DATEPART(qq, GETDATE()) and DATEPART(yy, BillTime) = DATEPART(yy, GETDATE()) and UserID=@UserID and islock=0 and bType=0
	end
	if @Num=9--本年总收支
	begin 
		select sum(bmoney) from NT_Bill where  DATEPART(yy, BillTime) = DATEPART(yy, GETDATE()) and UserID=@UserID and islock=0
	end
	if @Num=10--本年支出
	begin 
		select sum(bmoney) from NT_Bill where  DATEPART(yy, BillTime) = DATEPART(yy, GETDATE()) and UserID=@UserID and islock=0 and bType=1
	end
	if @Num=11--本年收入
	begin 
		select sum(bmoney) from NT_Bill where  DATEPART(yy, BillTime) = DATEPART(yy, GETDATE()) and UserID=@UserID and islock=0 and bType=0
	end

end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_BlogFoot
@Num int=1,--返回记录数
@UserID int
as
--设置返回数
set rowcount @Num
--处理

begin
	select a.ID,a.BlogID,a.UserID,a.CreatTime  from NT_BlogFoot a  inner  join NT_Blog b on b.id=a.blogid  where a.UserID=@UserID order by a.CreatTime Desc,a.id desc
end

--还原返回数
set rowcount 0
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_BlogFootID
@Num int=1,--返回记录数
@BlogID int,
@UserID int
as
--设置返回数
set rowcount @Num
--处理

begin
	select  UserID,CreatTime  from NT_BlogFoot where BlogID=@BlogID and UserID!=@UserID order by id Desc
end

--还原返回数
set rowcount 0
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc  JuSNS_BlogFootIDValue
@UserID int,
@BlogID int,
@Date datetime
as

begin
	select count(id) from NT_BlogFoot where UserID=@UserID and BlogID=@BlogID
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_BlogMore
@BlogID int,
@UserID int=0,
@Num int=1

as
--设置返回数
set rowcount @Num
--处理

begin
	select ID,Title,PostTime,UserID from NT_Blog where ID!=@BlogID and UserID=@UserID order by id Desc
end

--还原返回数
set rowcount 0

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE proc JuSNS_DelAllAdv
@Type nvarchar(50)
as
begin
	if @Type='all'
	begin 
		delete from NT_adminlog
		delete from NT_album
		delete from NT_bill
		delete from NT_billclass
		delete from NT_billcomment
		delete from NT_billfamily
		delete from NT_blog
		delete from NT_blogcomment
		delete from NT_blogdraft
		delete from NT_blogfoot
		delete from NT_constellation
		delete from NT_DisVote
		delete from NT_dyn
		delete from NT_emailnotify
		delete from NT_friend
		delete from NT_friendclass
		delete from NT_frienddesc
		delete from NT_friendinvite
		delete from NT_gbook
		delete from NT_gift
		delete from NT_giftClass
		delete from NT_giftuser
		delete from NT_greet
		delete from NT_groupdiscuss
		delete from NT_groupinvite
		delete from NT_groupmember
		delete from NT_Mail
		delete from NT_Mailinbox
		delete from NT_Mailoutbox
		delete from NT_message
		delete from NT_mood
		delete from NT_moodcomment
		delete from NT_movie
		delete from NT_moviecomment
		delete from NT_movieposter
		delete from NT_moviesort
		delete from NT_movieurl
		delete from NT_news
		delete from NT_newsclass
		delete from NT_newscomment
		delete from NT_notepad
		delete from NT_notice
		delete from NT_onlineuser
		delete from NT_photo
		delete from NT_photocomment
		delete from NT_photolasso
		delete from NT_request
		delete from NT_retrievepwd
		delete from NT_share
		delete from NT_sharecomment
		delete from NT_spacetemplate
		delete from NT_spareemail
		delete from NT_tovote
		delete from NT_user
		delete from NT_usercareer
		delete from NT_usereducation
		delete from NT_usergroup
		delete from NT_userinfo
		delete from NT_userlog
		delete from NT_userpointhistory
		delete from NT_usersetting
		delete from NT_visit
		delete from NT_vote
		delete from NT_votecomm
		delete from NT_voteoption
	end
	
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_DelBillInfo
@UserID int,
@ID int
as
begin
	delete  from NT_bill where UserID=@UserID and Id=@ID
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_DelClassInfo
@UserID int,
@ID int
as
begin
	delete  from NT_billclass where UserID=@UserID and Id=@ID
	update NT_bill set classid=0 where ClassID=@ID
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_DelFamilyInfo
@UserID int,
@ID int
as
begin
	delete  from NT_billfamily where UserID=@UserID and Id=@ID
	update NT_bill set fid=0 where fID=@ID
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_DelNote
@UserID int,
@NoteID int
as

begin
	delete from NT_NotePad where [ID]=@NoteID and UserID=@UserID
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_DelPoke
@UserID int,
@ID int
as

begin
	delete from NT_Greet where [ID]=@ID and FriendID=@UserID
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE proc JuSNS_DelUserAdv
@UserID int,
@Type nvarchar(50)
as
begin
	if @Type='blog'
	begin 
		delete from nt_blog where UserID=@UserID
		--delete from nt_blogcomment where userid=@UserID
		delete from NT_blogdraft where userid=@UserID
	end
	if @Type='album'
	begin 
		delete from nt_album where UserID=@UserID
	end
	if @Type='pic'
	begin 
		delete from nt_photo where UploadUser=@UserID
	end
	if @Type='group'
	begin 
		
		delete from NT_Usergroup where UserID=@UserID
	end
	if @Type='mood'
	begin 
		delete from nt_mood where UserID=@UserID
	end
	if @Type='poke'
	begin 
		delete from NT_greet where UserID=@UserID
		delete from NT_greet where FriendID=@UserID
	end
	if @Type='gift'
	begin 		
		delete from nt_giftuser where UserID=@UserID
		delete from nt_giftuser where SendUserID=@UserID
	end
	if @Type='share'
	begin 
		delete from nt_share where UserID=@UserID
	end
	if @Type='bill'
	begin 
		delete from nt_bill where UserID=@UserID
		delete from nt_billclass where UserID=@UserID
	end
	if @Type='movie'
	begin 
		delete from NT_movie where UserID=@UserID
	end
	if @Type='vote'
	begin 
		delete from nt_vote where UserID=@UserID
	end
	if @Type='news'
	begin 
		delete from nt_news where UserID=@UserID
	end
	if @Type='gbook'
	begin 
		delete from nt_gbook where SendID=@UserID
		delete from nt_gbook where RecID=@UserID
	end
	if @Type='friend'
	begin 
		delete from nt_friend where UserID=@UserID
		delete from nt_friend where FriendID=@UserID
		delete from nt_friendclass where UserID=@UserID
	end
	if @Type='note'
	begin 
		delete from NT_notepad where UserID=@UserID
	end
	if @Type='box'
	begin 
		delete from NT_Mailinbox where UserID=@UserID
		delete from NT_Mailoutbox where UserID=@UserID
	end
	if @Type='notes'
	begin 
		delete from NT_notice where Receiver=@UserID
	end
	
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE proc JuSNS_DelUserCommAdv
@UserID int,
@Type nvarchar(50)
as
begin
	if @Type='blog'
	begin 
		delete from nt_blogcomment where userid=@UserID		
	end
	if @Type='pic'
	begin 
		delete from NT_photocomment where UserID=@UserID
	end
	if @Type='group'
	begin 
		delete from NT_groupdiscuss where UserID=@UserID

	end
	if @Type='mood'
	begin 
		delete from NT_moodcomment where Commentator=@UserID
	end

	if @Type='share'
	begin 
		delete from NT_sharecomment where UserID=@UserID
	end
	if @Type='movie'
	begin 
		delete from NT_moviecomment where UserID=@UserID
	end
	if @Type='vote'
	begin 
		delete from NT_votecomm where UserID=@UserID
	end
	if @Type='news'
	begin 
		delete from NT_newscomment where UserID=@UserID
	end
	
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_DelUserSelf
@UserID int
as

begin
	delete from NT_User where UserID=@UserID
	delete from NT_Friend where UserID=@UserID or FriendID=@UserID
	delete from NT_Friendclass where UserID=@UserID
	delete from NT_FriendInvite where UserID=@UserID
	--  开始删除其他表
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_DeleteUnOnlineUser
@LastTime datetime
as

begin
	delete from NT_OnlineUser where LastTime<@LastTime
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_EditbillClass
@cName nvarchar(30),
@UserID int,
@id int
as

begin
	update nt_billClass set className=@cName where UserID=@UserID and id=@id

end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_EditbillFamily
@cName nvarchar(30),
@UserID int,
@id int
as

begin
	update nt_billfamily set fName=@cName where UserID=@UserID and id=@id

end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_FriendClass
@UserID int
as

begin
	select a.Id,a.CName,a.UserID,(select count(c.id) from NT_Friend c inner join NT_User b on b.UserID=c.FriendID where b.State!=0 and c.ClassID=a.ID and c.UserID=@UserID) as FCount from NT_FriendClass a where a.UserID=@UserID order by a.id  asc
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_FriendNote
@type int=1,
@UserID int
as

begin
	if @type=1
	begin
		select count(id) from NT_Request where Receiver=@UserID and ReplyResult=0 and RequestType=1
	end
	if @type=3
	begin
		select count(id) from NT_GroupInvite where InviteFlag=1 and JoinUserID=@UserID and Response=0
	end
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_GetBillClassName
@ClassID int,
@UserID int
as
begin
	select className  from NT_billclass where id=@ClassID and UserID=@UserID
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_GetBillInfo
@UserID int,
@ID int
as
begin
	select *  from NT_bill where UserID=@UserID and Id=@ID
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_GetClassList
@UserID int
as
begin
	select id,className from NT_billclass where UserID=@UserID order by Id desc
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_GetDictMovieSortList
as

begin
	Select [ID],SortName,(select count(MovieID) from NT_Movie where NT_Movie.SortID=NT_MovieSort.ID) as Scount From NT_MovieSort order by ID asc
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_GetDynInfoId
@ID int,--返回记录数
@Flg int

as

begin

	if @Flg=0
	begin
	   select AlbumID,Title,Description from NT_album where AlbumID=@ID and Privacy!=3
	end
	
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_GetFamily
@fid int,
@UserID int
as
begin
	select fname  from NT_billfamily where id=@fid and UserID=@UserID
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_GetFamilyList
@UserID int
as
begin
	select id,fname,sex from NT_billfamily where UserID=@UserID order by Id desc
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_GetFriendBirthday
@UserID int
as 
begin 
	declare @CompareDate datetime
	--基准参照日期
	set @CompareDate = getdate()     --'2007-02-06'
	--生日 大于等于 基准参照日期的数据的排在第1区段
	select   '1' as PeriodSection,(select UserName 
	from NT_User 
	WHERE NT_User.UserID=NT_UserInfo.UserID)as uName,
	UserID,substring(convert(varchar(10),birthday,21),6,5) as date1,birthday
	 from NT_UserINFO
	where substring(convert(varchar(10),birthday,21),6,5)
	>= substring(convert(varchar(10),@CompareDate,21),6,5) and datediff(dd,cast(year(birthday)as varchar(30))
	+right(convert(varchar(10),getdate(),120),6),birthday) between -1 and 7 and UserID in (select FriendID
	 from NT_Friend 
	where UserID=@UserID) 
	union all
	--生日 小于 基准参照日期的数据的排在第2区段
	select   '2' as PeriodSection,(select UserName
	 from NT_User 
	WHERE NT_User.UserID=NT_UserInfo.UserID)as uName,UserID,
	substring(convert(varchar(10),birthday,21),6,5) as date1,birthday
	 from NT_UserINFO
	where substring(convert(varchar(10),birthday,21),6,5)
	< substring(convert(varchar(10),@CompareDate,21),6,5) and datediff(dd,cast(year(birthday)as varchar(30))
	+right(convert(varchar(10),getdate(),120),6),birthday) between -1 and 7 and UserID in (select FriendID 
	from NT_Friend 
	where UserID=@UserID) 
	order by PeriodSection,substring(convert(varchar(10),birthday,21),6,5)
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE proc JuSNS_GetIndexFriendCity
@Num int=6,--返回记录数
@City int,
@UserID int,
@Sex int
as
set rowcount @Num

begin
	if @Sex=0
	begin
		select a.UserID,a.UserName,a.City,b.FilePath from NT_User a inner join NT_Photo b on a.Portrait=b.PhotoID inner join NT_Userinfo d on a.UserID=d.UserID and d.sex=1 and b.IsLock=0 where a.City=@City and a.State!=0 and a.UserID not in (select FriendID from NT_Friend where UserID=@UserID) and a.UserID!=@UserID order by newid()
	end

	if @Sex=1
	begin
		select a.UserID,a.UserName,a.City,b.FilePath from NT_User a inner join NT_Photo b on a.Portrait=b.PhotoID inner join NT_Userinfo d on a.UserID=d.UserID and d.sex=0 and b.IsLock=0 where a.City=@City and a.State!=0 and a.UserID not in (select FriendID from NT_Friend where UserID=@UserID) and a.UserID!=@UserID order by newid()
	end
	
	else

	begin
		select a.UserID,a.UserName,a.City,b.FilePath from NT_User a inner join NT_Photo b on a.Portrait=b.PhotoID and b.IsLock=0 where a.City=@City and a.State!=0 and a.UserID not in (select FriendID from NT_Friend where UserID=@UserID) and a.UserID!=@UserID order by newid()
	end
	
	
end
--还原返回数
set rowcount 0
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE proc JuSNS_GetIndexFriendRam
@Num int=6,--返回记录数
@UserID int
as
set rowcount @Num

begin
	
	select a.UserID,a.UserName,b.Name,c.FilePath
	 from NT_User a
	 inner join NT_Dict_Area b on a.Province=b.ID inner join NT_Photo c on a.Portrait=c.PhotoID and c.IsLock=0 
	where a.State!=0 and a.UserID not in (select FriendID from NT_Friend where UserID=@UserID) and a.UserID!=@UserID  
	order by newid()
	
end
--还原返回数
set rowcount 0
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE proc JuSNS_GetIndexNewUserReg
@Num int,--返回记录数
@UserID int,
@Sex int
as
set rowcount @Num

begin
	if @Sex=0
	begin
		select a.UserID,a.UserName,a.City,b.FilePath from NT_User a inner join NT_Photo b on a.Portrait=b.PhotoID inner join NT_Userinfo d on a.UserID=d.UserID and d.sex=1 and b.IsLock=0 where  a.State!=0 and a.UserID not in (select FriendID from NT_Friend where UserID=@UserID) and a.UserID!=@UserID order by RegTime desc,a.Userid desc
	end

	if @Sex=1
	begin
		select a.UserID,a.UserName,a.City,b.FilePath from NT_User a inner join NT_Photo b on a.Portrait=b.PhotoID inner join NT_Userinfo d on a.UserID=d.UserID and d.sex=0 and b.IsLock=0 where  a.State!=0 and a.UserID not in (select FriendID from NT_Friend where UserID=@UserID) and a.UserID!=@UserID order by RegTime desc,a.Userid desc
	end
	
	else

	begin
		select a.UserID,a.UserName,a.City,b.FilePath from NT_User a inner join NT_Photo b on a.Portrait=b.PhotoID and b.IsLock=0 where a.State!=0 and a.UserID not in (select FriendID from NT_Friend where UserID=@UserID) and a.UserID!=@UserID order by  RegTime desc,a.Userid desc
	end
	
	
end
--还原返回数
set rowcount 0
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_GetIsFriend
@UserID int,
@uID int
as

begin
	select count(ID) from NT_Friend where UserID=@UserID and FriendID=@uID and State=0
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_GetIsFriend1
@UserID int,
@uID int
as

begin
	select count(ID) from NT_Friend where UserID=@uID and FriendID=@UserID and State=0
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_GetMovieSortName
@SortID int
as

begin
	
	select SortName from NT_MovieSort where [ID]=@SortID
	
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_GetMovieUserList
@MovieID int
as

begin
	select [ID],MovieID,UserID,MovieURL,MovieName,PicURL,CreatTime from NT_MovieURL where MovieID=@MovieID and islock=0  order by [ID]  asc
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_GetNewsClass
@ParentID int
as

begin
	select ID,ParentID,className from NT_NewsClass where ParentID=@ParentID order by id asc
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_GetNewsCommentID
@ID int,
@NewsID int
as
begin
	select [id],NewsID,content,UserID,(select Count(id) from NT_NewsComment where NT_NewsComment.NewsID=@NewsID) as ReplayNum,(select Title from NT_News where ID=@NewsID) as Title,(select pic from NT_News where ID=@NewsID) as pic from NT_NewsComment where  [Id]=@ID
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_GetNoteNumber
@UserID int,
@noteDate int
as

begin
	select count(id) from NT_NotePad where UserID=@UserID and (DATEDIFF(d,getdate() , TXTime)<=@noteDate) and  (DATEDIFF(d,getdate() , TXTime)>=0)
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_GetParentCity
@cid int
as
begin
	select parentid from NT_Dict_Area where id=@cid
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_GetRepayBook
@ParentID int,
@UserID int
as
begin
	select a.id,a.SendID,a.RecID,a.ParentID,a.Content,a.PostTime,(select c.UserName from NT_User c where c.UserID=a.SendID) as UserName,(select count(b.id) from NT_gbook b where b.ParentID=a.ID) as ReplayCount  from NT_Gbook a where a.Parentid=@ParentID and a.islock=0 order by a.id asc
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_GetTopIDBlog
@ID int
as
begin
	select id,Title,Content,PostTime,(select count(id) from NT_blogComment where NT_blogComment.BlogID=NT_blog.ID and isLock=0) as ReplayNum from NT_blog where isLock=0  and [ID]=@ID
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_GetTopIDMood
@ID int
as
begin
	select id,Content,PostTime,(select count(id) from NT_MoodComment where NT_MoodComment.MiniBlogID=NT_Mood.ID and isLock=0) as ReplayNum from NT_Mood where isLock=0  and [ID]=@ID
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_gettopmood
@UserID int
as
begin
	select top 1 [id],Content,PostTime,(select count(id) from NT_MoodComment where NT_MoodComment.MiniBlogID=NT_Mood.ID and isLock=0) as ReplayNum from NT_Mood where isLock=0 and UserID=@UserID order by Id desc
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_GetTopMovie
@Num int=1,--返回记录数
@flg int
as
set rowcount @Num
begin
	if @flg=0
	begin 
		select MovieID,Title,PosterFile,Director,Billing,YearOnShow,hits,comment,UserID,CreatTime  from NT_Movie order by hits desc,[MovieID] desc
	end
	if @flg=1
	begin 
		select MovieID,Title,PosterFile,Director,Billing,YearOnShow,hits,comment,UserID,CreatTime  from NT_Movie where comment!=0 order by comment desc,[MovieID] desc
	end

	if @flg=2
	begin 
		select MovieID,Title,PosterFile,Director,Billing,YearOnShow,hits,comment,UserID,CreatTime  from NT_Movie order by newid()
	end
end
--还原返回数
set rowcount 0
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_GetUnClassFriend
@UserID int
as

begin
	select count(id) from NT_Friend where (ClassID=0 or ClassID=null) and UserID=@UserID
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_GetUserIDFromEmail
@Email nvarchar(200)
as
begin
	select UserID  from NT_User where Email=@Email and State!=0
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_GiftInfo
@ID int
as

begin
	select [ID],islock,GName,picture,usenumber,point,classID,content from NT_Gift where ID=@ID
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_GiftUserInfo
@ID int
as

begin
	select Content,content from NT_GiftUser where ID=@ID
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_GroupCount
@UserID int,
@a nvarchar(6)
as
begin
	if(@a='creat')
	begin
		Select Count([GroupID]) From [NT_UserGroup] Where [UserID]=@UserID
	end 
	if(@a='join')
	begin
		Select Count([ID]) From [NT_GroupMember] Where [UserID]=@UserID
	end 
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_InsertMovieURL
@MovieID int,
@UserID int,
@MovieName nvarchar(50)='',
@MovieURL nvarchar(300)='',
@CreatTime DateTime,
@isLock tinyint
as

begin
	insert into NT_MovieURL(MovieID,UserID,MovieName,MovieURL,isLock,CreatTime) values(@MovieID,@UserID,@MovieName,@MovieURL,@isLock,@CreatTime)
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_IsOnline
@UserID int
as

begin
	select count(ID) from NT_OnlineUser where userid=@UserID
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_IsOnline1
as

begin
	select count(ID) from NT_OnlineUser
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_OnlineAddUser
@LastIP NVarChar(18)='',
@UserID int,
@UserName nvarchar(50)='',
@LastUrl nvarchar(256)='',
@LastTime DateTime
as

begin
	insert into NT_OnlineUser(userid,username,lastip,lasturl,lasttime) values(@UserID,@UserName,@LastIP,@LastUrl,@LastTime)
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_OnlineCheckOnline
@UserID int,
@LastIP nvarchar(18)=''
as

begin
	select count(id) from NT_OnlineUser where UserID=@UserID and LastIP=@LastIP
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_OnlineDeleteUser
@LastIP NVarChar(18)=''
as

begin
	delete from NT_OnlineUser where LastIP=@LastIP
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc  JuSNS_OnlineDeleteUser1
@id int
as

begin
	delete from NT_OnlineUser where id=@id
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc  JuSNS_OnlineDeleteUser2
@userid int
as

begin
	delete from NT_OnlineUser where userid=@userid
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_OnlineGetInfo
@id int
as

begin
	select userid,username,lastip,lasturl,id,lasttime from NT_OnlineUser where id=@id
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_OnlineGetInfo1
@UserID int
as

begin
	select userid,username,lastip,lasturl,id,lasttime from NT_OnlineUser where userid=@UserID
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_OnlineList
@LastTime datetime
as

begin
	select userid,username,lastip,lasturl,id,lasttime from NT_OnlineUser where  LastTime>@LastTime
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_OnlineNumber
@UserID int,
@Num int = 50
as
set rowcount @Num
begin
	select [ID],UserID,UserName,(select count(id) from NT_onlineuser) AS TotelNumber from NT_onlineuser where UserID in (select FriendID from NT_Friend where NT_Friend.UserID=@UserID) and UserID!=@UserID order by LastTime desc,id desc
end
set rowcount 0
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_OnlineUserUpdate
@LastIP NVarChar(18)='',
@UserID int,
@UserName nvarchar(50)='',
@LastUrl nvarchar(256)='',
@LastTime DateTime
as

begin
	update NT_OnlineUser set UserName=@UserName,LastUrl=@LastUrl,LastTime=@LastTime where UserID=@UserID and LastIP=@LastIP
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_PokeNum
@UserID int
as
begin
	select count(id) from NT_Greet where UserID=@UserID and isRead=0 and isDel=0 and Convert(varchar(10),PostTime,120) = Convert(varchar(10),getDate(),120)
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_PokeUpdateChangeState
@ID int,
@UserID int
as

begin
	update NT_Greet set isRead=1 where ID=@ID and FriendID=@UserID
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE JuSNS_Register
@Email nvarchar(100),
@IP char(15),
@Password nchar(32),
@Username nvarchar(50),
@State int,
@Province int,
@City int,
@NowTime datetime,--为统一时间,用传入参数
@VerifyCode char(11),
@EmailItem varchar(1000),---设置项ID,以逗号分隔
@PrivDef int,--用户隐私设置默认值
@Sex int
 AS
DECLARE @R int
DECLARE @NewUid int
select @R=count(UserID) from NT_User where Email=@Email
IF @R >0 
RETURN 2
select @R=count(ID) from NT_SpareEmail where Email=@Email
IF @R > 0
RETURN 2
BEGIN TRAN
   Insert into NT_User ([Email],[Password],[Username],[State],[LoginTimes],[Province],[City],[RegTime],[RegIP],[VerifyCode]) values (@Email,@Password,@Username,@State,0,@Province,@City,@NowTime,@IP,@VerifyCode)
   SELECT @NewUid=@@IDENTITY
   insert into NT_UserInfo(UserID,sex) VALUES(@NewUid,@Sex)
   Insert into NT_UserSetting (UserID,PrivSpace,PrivFavourite,PrivEducate,PrivLasso,PrivFriends,PrivLeaveWord,PrivMiniBlog,PrivShare,PrivGroup,PrivMovies,ActUpdateData,ActAddFriend,ActLeaveWord,ActPicComment,ActSecede,ActDeliver,ActLogComment,ActMovieComment,ActPhotoLasso,ActShareComment,LastPostTime,LastPostIP)
         values (@NewUid,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,1,1,1,1,1,1,1,1,1,1,@NowTime,@IP)
-------以下为设置邮件通知
 EXEC NTP_EmailNotifyInit @EmailItem,@NewUid,@NowTime,@IP
IF @@error=0
BEGIN
  COMMIT TRAN
  RETURN 1
END
ELSE
BEGIN
  ROLLBACK TRAN
  RETURN 3
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE proc JuSNS_SaveGift
@UserID int,
@gID int,
@SendUserID int,
@pType tinyint,
@Content nvarchar(200),
@CreatTime datetime
as

begin
	insert into NT_GiftUser(UserID,gID,SendUserID,pType,Content,CreatTime,isDel) values(@UserID,@gID,@SendUserID,@pType,@Content,@CreatTime,0)
	update NT_Gift set useNumber=useNumber+1 where [ID]=@gID
	Select @@IDENTITY
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_SpaceInfoARR
@ID int,
@flag int
as
begin
	if(@flag=0)--根据会员编号获取会员基本信息
	begin
		select a.UserID,a.UserName,a.Click,a.integral,inteyb,Pro=a.Province,citys=a.City,VocName=(select VocName from NT_Dict_Vocation where ID=(select Vocation from NT_UserInfo where UserID=a.UserID)),Province=(select Name from NT_Dict_Area where id=a.Province),City=(select Name from NT_Dict_Area where id=a.City),Sex=(select Sex=case Sex when 0 then '女' when 1 then '男' end from NT_UserInfo where UserID=a.UserID),Birthday=(select Birthday from NT_UserInfo where UserID=a.UserID),Marriage=(select Marriage from NT_UserInfo where UserID=a.UserID),BirthidayDisplay=(select BirthidayDisplay from NT_UserInfo where UserID=a.UserID),Constellation=(select Constellation from NT_Constellation where Id=(select Constellation from NT_UserInfo where UserID=a.UserID)),HomeProv=(select Name from NT_Dict_Area where id=(select HomeProv from NT_UserInfo where UserID=a.UserID)),HomeCity=(select Name from NT_Dict_Area where id=(select HomeCity from NT_UserInfo where UserID=a.UserID)),Photo=(select FilePath from NT_Photo where PhotoID=a.Portrait and PhotoType=0) from NT_User a where a.UserId=@ID
	end 
	if(@flag=1)--根据会员编号读取我的好友信息
	begin
		select  a.UserID,a.UserName,a.Portrait,FilePath=(select FilePath from NT_Photo where PhotoID=a.Portrait ) from NT_User a where a.UserID in (select b.FriendID from NT_Friend b where b.UserID=@ID) order by a.LastLoginTime desc
	end 
	if(@flag=2)--根据会员编号读取其发表的心情日记
	begin
		select ID,Content,PostTime,(select count(ID) from NT_MoodComment where MiniBlogID=NT_Mood.ID) as MCount from NT_Mood where UserID=@ID and IsLock=0 order by PostTime desc
	end 
	if(@flag=3)--根据会员编号读取会员分享
	begin
		select top 5 ID,Num=(select count(*) from NT_Share where UserId=@ID and IsLock=0),Title,Description,ShareType,CaseID,PostTime,Comments,Privacy from NT_Share where UserId=@ID and IsLock=0 order by PostTime desc
	end 
	if(@flag=4)--根据会员编号读取群组信息
	begin
		select a.GroupID,a.GroupName,a.UserID,a.Members,a.Portrait from NT_UserGroup a where a.GroupID In(Select c.GroupID From NT_GroupMember as c Where c.UserID=@ID) order by a.PostTime desc
	end 
	if(@flag=5)--根据会员编号读取电影
	begin
		select MovieID,Title,Gut,PosterFile from NT_Movie where UserID=@ID order by MovieID desc
	end 
	if(@flag=6)--根据会员编号读取相册信息
	begin
		select AlbumID,Title,ImagesCount,LastUploadTime,Privacy from NT_Album where UserID=@ID order by LastUploadTime desc
	end 
	if(@flag=7)--根据相册编号读取其封面图
	begin
		select AlbumID,FilePath from NT_Photo where AlbumID=@ID and IsCover=0 and PhotoType=1 and IsLock=0
	end 
	if(@flag=8)--根据会员编号读取日志
	begin
		select a.ID,a.Title,a.Content,a.PostTime,Comments=(select count(ID) from NT_BlogComment where BlogID=a.ID ),a.PicPath,a.LastModTime,a.Privacy from dbo.NT_Blog a where a.UserID=@ID and a.IsLock=0 order by a.PostTime desc
	end 
	if(@flag=9)--读取会员工作信息
	begin
		select ID,Company,Description,IsStill,JoinYear,JoinMonth,LeaveYear,LeaveMonth from NT_UserCareer where UserID=@ID order by PostTime desc
	end 
	if(@flag=10)--读取会员学校信息
	begin
		select a.ID,a.UserID,a.DegreeID,a.SchoolID,SchoolName=(select SchoolName from NT_Dict_School where SchoolID=a.SchoolID),Name=(select Name from NT_Dict_Academy where ID=a.AcademyID),a.MatriculationYear,a.AcademyID from NT_UserEducation a where a.UserID=@ID and a.IsLock=0
	end 
	if(@flag=11)--读取会员联系信息和爱好
	begin
		select a.Sex,a.Birthday,a.Constellation,a.MSN,a.GTalk,a.QQ,a.Skype,a.Mobile,a.Tel,a.Addr,a.WebSite,a.Favourite,a.FavMusics,a.FavMovies,a.FavCartoons,a.FavGames,a.FavSports,a.FavBooks,a.AppreciateMen,a.FavAdages,a.Presentation,b.Email,a.MobilePrivacy,a.EmailPrivacy,a.MSNPrivacy,a.GTalkPrivacy,a.QQPrivacy,a.SkypePrivacy,a.TelPrivacy,a.AddrPrivacy,a.WebSitePrivacy from NT_UserInfo a inner join NT_User b on a.UserID=b.UserID where a.UserID=@ID
	end 
	if(@flag=12)--读取会员留言信息
	begin
		select top 8 a.ID,a.SendID,a.Content,a.PostTime,b.UserName,Province=(select Name from NT_Dict_Area where id=b.Province) from NT_gbook a inner join NT_User b on a.SendID=b.UserID where a.RecID=@ID and a.IsLock=0 order by a.PostTime desc
	end 
	if(@flag=13)--读取会员个人动态
	begin
		select ID from NT_dyn where UserID=@ID order by id desc
	end 
	if(@flag=14)--根据一级地区读取二级地区
	begin
		select ID,ParentID,Name from NT_Dict_Area where IsLock=0 and ParentID=@ID
	end 
	if(@flag=15)--根据学校编号读取院系信息
	begin
		select ID,Name from NT_Dict_Academy where SchoolID=@ID and IsLock=0
	end 
	if(@flag=16)--根据日志编号读取日志
	begin
		select ID,Title,Content,Comments,PicPath from dbo.NT_Blog where ID=@ID and IsLock=0
	end 
	if(@flag=17)--根据分享ID读取分享的日志信息
	begin
		select a.Description,a.Comments,a.Privacy ,b.ID,b.Title,b.Content,b.Comments,b.PicPath from NT_Share a inner join NT_Blog b on a.CaseID=b.ID where a.CaseID=@ID and a.ShareType=4 and b.IsLock=0
	end 
	if(@flag=18)--根据电影的评论编号读取评论信息
	begin
		select a.MovieID,a.Title,a.PosterFile,b.Score,b.Comment,b.PostTime from NT_Movie a inner join NT_MovieComment b on b.MovieID=a.MovieID  where b.ID=@ID
	end 
	if(@flag=19)--读取上传的相片
	begin
		select a.AlbumID,a.Title,b.FilePath,b.PhotoID from NT_Album a inner join NT_Photo b on a.AlbumID=b.AlbumID where b.PhotoID=@ID
	end 
	if(@flag=20)--读取心情日记
	begin
		select ID,Content,Comments from dbo.NT_Mood where ID=@ID
	end 
	if(@flag=21)--读取分享的相册信息
	begin
		select a.Description,a.Comments,a.Privacy ,b.AlbumID,b.Title,b.ImagesCount from NT_Share a inner join dbo.NT_Album b on a.CaseID=b.AlbumID where a.CaseID=@ID and a.ShareType=3
	end 
	if(@flag=22)--读取分享的相片信息
	begin
		select a.CaseID,a.Description,a.Comments,a.Privacy ,PhotoDes=b.Description,b.FilePath,c.AlbumID,c.Title from NT_Share a inner join dbo.NT_Photo b on b.PhotoID=a.CaseID inner join dbo.NT_Album c on b.AlbumID=c.AlbumID where a.CaseID=@ID and a.ShareType=2
	end 
	if(@flag=23)--读取我被别人圈的照片数
	begin
		select number=Count(*) from NT_PhotoLasso where FriendID=@ID and IsLock=0
	end 
	if(@flag=24)--获取头像路径
	begin
		select b.FilePath,b.PhotoID from  NT_Photo b where b.PhotoID=@ID
	end 
	if(@flag=25)--读取心情的评论数
	begin
		select ID=Count(ID) from dbo.NT_MoodComment where MiniBlogID=@ID
	end 
	if(@flag=26)--读取推荐的会员
	begin
		select top 30 UserID from NT_User where isRec=0 order by RegTime desc
	end 

	if(@flag=27)--根据评论编号读取评论信息
	begin
		select a.ID,a.Title from dbo.NT_Blog a inner join NT_BlogComment b on a.ID=b.BlogID where b.ID=@ID and a.IsLock=0 order by a.PostTime desc
	end 

	if(@flag=28)--根据相册编号相册名称
	begin
		select AlbumID,Title from dbo.NT_Album where AlbumID=@ID
	end 

	if(@flag=29)--根据会员编号读取投票
	begin
		select a.ID,a.Title,a.Intro,a.AddTime,Comments=(select count(ID) from NT_voteComm where VoteID=a.ID )from NT_vote a where a.UserID=@ID order by a.AddTime desc,id desc
	end 
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_TopUser
@Num int=1,--返回记录数
@TN int,
@ProID int,
@Sex int,
@TablesAndWhere varchar(200)='',
@UserID int
as
set rowcount @Num
declare @strSQL nvarchar(1000) -- 主语句
begin
	if @Sex=0 
	set @TablesAndWhere=' and b.Sex=0'	
	if @Sex=1 
	set @TablesAndWhere=' and b.Sex=1'	

	if @TN=0
	begin
		set @strSQL ='select a.UserID,a.UserName from NT_User a left  join  NT_UserInfo b on a.UserID=b.UserID  where a.State=5 '+ @TablesAndWhere+'   order by a.userid desc'
	end
	if @TN=1
	begin
		set @strSQL ='select a.UserID,a.UserName from NT_User a left join  NT_UserInfo b on a.UserID=b.UserID where a.State=5 '+ @TablesAndWhere+' order by a.LastLoginTime desc,a.userid desc'
	end
	if @TN=2
	begin
		set @strSQL ='select a.UserID,a.UserName from NT_User a left join  NT_UserInfo b on a.UserID=b.UserID where a.State=5 '+ @TablesAndWhere+' order by a.integral desc,a.userid desc'
	end
	if @TN=3
	begin
		set @strSQL ='select a.UserID,a.UserName from NT_User a left join  NT_UserInfo b on a.UserID=b.UserID where a.State=5 '+ @TablesAndWhere+' order by a.inteyb desc,a.userid desc'
	end
	if @TN=4
	begin
		set @strSQL ='select a.UserID,a.UserName from NT_User a left join  NT_UserInfo b on a.UserID=b.UserID where a.State=5 '+ @TablesAndWhere+' order by a.LoginTimes desc,a.userid desc'
	end
	if @TN=5
	begin
		set @strSQL ='select a.UserID,a.UserName from NT_User a left join  NT_UserInfo b on a.UserID=b.UserID where a.State=5 '+ @TablesAndWhere+' order by a.click desc,a.userid desc'
	end
	if @TN=6
	begin
		set @strSQL ='select a.UserID,a.UserName from NT_User a left join  NT_UserInfo b on a.UserID=b.UserID where a.State=5 '+ @TablesAndWhere+' order by a.Recommended desc,a.userid desc'
	end
	if @TN=7
	begin
		set @strSQL ='select a.UserID,a.UserName from NT_User a left join  NT_UserInfo b on a.UserID=b.UserID where a.State=5 '+ @TablesAndWhere+' order by  newid()'
	end
	if @TN=8
	begin
		set @strSQL ='select a.UserID,a.UserName from NT_User a left join  NT_UserInfo b on a.UserID=b.UserID where a.State=5 '+ @TablesAndWhere+' and Province=@ProID and UserID=@UserID  order by newid()'
	end
	if @TN=9
	begin
		set @strSQL ='select a.UserID,a.UserName from NT_User a left join  NT_UserInfo b on a.UserID=b.UserID where a.State=5 '+ @TablesAndWhere+' and City=@ProID and UserID=@UserID  order by  newid()'
	end
	
end
exec sp_executesql @strSQL
--还原返回数
set rowcount 0

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_UpdateBlogFoot
@UserID int,
@BlogID int,
@Date datetime
as

begin
	insert into NT_BlogFoot(UserID,BlogID,CreatTime) values (@UserID,@BlogID,@date)
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_UpdateBlogFoot1
@UserID int,
@BlogID int,
@Date datetime
as

begin
	update NT_BlogFoot set CreatTime=@Date where BlogID=@BlogID and UserID=@UserID
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_UpdateFriendClass
@UserID int,
@ID int,
@CName nvarchar(50)
as

begin
	update NT_FriendClass set CName=@CName where ID=@ID and UserID=@UserID
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_UserDyn
@appID int,
@dynType nvarchar(20),
@cID int,
@UserID int,
@bUserID int,
@Descript nvarchar(30),
@infoarr nvarchar(30),
@IP nvarchar(15),
@ID int
as

begin
	if @ID =0
		begin
			insert into NT_dyn(appID,dynType,cID,UserID,bUserID,Descript,infoarr,CreatTime,IP) values(@appID,@dynType,@cID,@UserID,@bUserID,@Descript,@infoarr,getdate(),@IP)
		end
	else
		begin
			update NT_dyn set appID=@appID,dynType=@dynType,cID=@cID,UserID=@UserID,bUserID=@bUserID,Descript=@Descript,infoarr=@infoarr,CreatTime=getdate(),IP=@IP where ID=@ID
		end
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_UserInfo
@UserID int
as
begin
	select a.*,b.FilePath from NT_User a left join NT_Photo b on a.Portrait=b.PhotoID and b.IsLock=0 where UserID=@UserID
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE proc JuSNS_addBill
@UserID int,
@bName nvarchar(30),
@bType tinyint,
@bmoney money,
@ClassID int,
@fID int,
@Content nvarchar(150),
@isPub tinyint,
@CreatTime datetime,
@isLock tinyint,
@billTime datetime,
@bID int
as

begin
	if @bID=0
	begin
		insert into NT_Bill(UserID,bName,bType,bmoney,ClassID,fID,Content,isPub,CreatTime,isLock,billTime) values(@UserID,@bName,@bType,@bmoney,@ClassID,@fID,@Content,@isPub,@CreatTime,@isLock,@billTime);Select @@IDENTITY
	end 
	if @bID>0
	begin
		update NT_Bill set bName=@bName,bType=@bType,bmoney=@bmoney,classid=@ClassID,fid=@fID,content=@Content,ispub=@isPub,creattime=@CreatTime,billtime=@billTime where UserID=@UserID and Id=@bID
	end 
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_addbillClass
@cName nvarchar(30),
@UserID int
as

begin
	
	insert into NT_billClass (parentid,btype,classname,userid) values(0,0,@cName,@UserID)

end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_addbillFamily
@cName nvarchar(30),
@UserID int
as

begin
	
	insert into NT_billfamily (fname,sex,userid) values(@cName,'',@UserID)

end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE procedure JuSNS_noteinfo
@UserID int
as
begin
	select count(id) from NT_Notice where Receiver=@UserID and IsLock=0 and IsDel=0 and IsRead=0
end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc  JuSNS_ramTopAlbum
@Num int=1,--返回记录数
@UserID int,
@By int
as
set rowcount @Num
begin
	if @By=0
	begin
		SELECT  [AlbumID],[UserID],[Title],[Description],[ImagesCount],[CreateTime],[Privacy],[GroupID] from 
		[NT_Album] Where [UserID] !=@UserID and UserID not in (select UserID from NT_Friend where FriendID=@UserID) and Privacy=0
		order by AlbumID desc
	end 
	if @By=1
	begin
		SELECT  [AlbumID],[UserID],[Title],[Description],[ImagesCount],[CreateTime],[Privacy],[GroupID] from 
		[NT_Album] Where [UserID] !=@UserID and UserID not in (select UserID from NT_Friend where FriendID=@UserID) and Privacy=0
		order by newid()

	end
end
--还原返回数
set rowcount 0
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_ramTopBlog
@Num int=1,--返回记录数
@By int
as
set rowcount @Num
begin
	if @By=0
	begin 
		SELECT  a.ID, a.UserID,(select UserName from NT_User c  where c.UserID=a.UserID) as UName, b.Title, b.Content, b.PostTime, b.Comments 
		FROM (SELECT UserID, MAX(ID) AS ID FROM NT_Blog 
		WHERE IsLock=0 and Privacy=0 GROUP BY UserID) a 
		INNER 	JOIN NT_blog b ON b.ID = a.ID 
		ORDER BY a.ID DESC
	end
	if @By=1
	begin 
		SELECT  a.ID, a.UserID,(select UserName from NT_User c  where c.UserID=a.UserID) as UName, b.Title, b.Content, b.PostTime, b.Comments 
		FROM (SELECT UserID, MAX(ID) AS ID FROM NT_Blog 
		WHERE IsLock=0 and Privacy=0 GROUP BY UserID) a 
		INNER 	JOIN NT_blog b ON b.ID = a.ID 
		ORDER BY newid()
	end
end
--还原返回数
set rowcount 0

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_ramTopMood
@Num int=1,--返回记录数
@By int
as
set rowcount @Num
begin
	if @By=0
	begin
		SELECT  a.ID, a.UserID,(select UserName from NT_User c  where c.UserID=a.UserID) as UName, b.Content, b.PostTime, b.MType 
		FROM (SELECT UserID, MAX(ID) AS ID FROM NT_Mood 
		WHERE IsLock=0 GROUP BY UserID) a 
		INNER 	JOIN NT_Mood b ON b.ID = a.ID 
		ORDER BY a.ID DESC
	end 
	if @By=1
	begin
		SELECT  a.ID, a.UserID,(select UserName from NT_User c  where c.UserID=a.UserID) as UName, b.Content, b.PostTime, b.MType 
		FROM (SELECT UserID, MAX(ID) AS ID FROM NT_Mood 
		WHERE IsLock=0 GROUP BY UserID) a 
		INNER 	JOIN NT_Mood b ON b.ID = a.ID 
		ORDER BY newid()
	end
end
--还原返回数
set rowcount 0

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


CREATE proc JuSNS_ramTopShare
@Num int=1,--返回记录数
@By int
as
set rowcount @Num
begin
	if @By=0
	begin
		SELECT  a.ID, a.UserID,(select UserName from NT_User c  where c.UserID=a.UserID) as UName, b.Title, b.[Description], b.PostTime,b.shareType, b.Comments 
		FROM (SELECT UserID, MAX(ID) AS ID FROM NT_Share 
		WHERE IsLock=0 and FriendIDGroup=0 and Privacy=0 GROUP BY UserID) a 
		INNER 	JOIN NT_Share b ON b.ID = a.ID 
		ORDER BY a.ID DESC
	end 
	if @By=1
	begin
		SELECT  a.ID, a.UserID,(select UserName from NT_User c  where c.UserID=a.UserID) as UName, b.Title, b.[Description], b.PostTime,b.shareType, b.Comments 
		FROM (SELECT UserID, MAX(ID) AS ID FROM NT_Share 
		WHERE IsLock=0 and FriendIDGroup=0 and Privacy=0 GROUP BY UserID) a 
		INNER 	JOIN NT_Share b ON b.ID = a.ID 
		ORDER BY newid()
	end 
end
--还原返回数
set rowcount 0

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO




CREATE PROCEDURE [dbo].[NTP_FriendStatistic] 
@UserID int,
@FriendsCount int output
AS
--先执行按好友描述进行统计
--select desctype,count(desctype) as Total from ntv_frienddetailstat where Modifier=@UserID or Affirmant=@UserID group by desctype
--再执行按好友所在网络统计
SELECT COUNT(a.FriendID) AS Total, b.Province, c.Name FROM NT_Friend a INNER JOIN NT_User b ON a.FriendID = b.UserID INNER JOIN 
NT_Dict_Area c ON b.Province = c.ID WHERE (a.UserID = @UserID) GROUP BY b.Province, c.Name
SELECT @FriendsCount=COUNT(ID) FROM NT_Friend WHERE UserID=@UserID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO




CREATE PROCEDURE [dbo].[NTP_InviterRegister]
@Email nvarchar(100),
@IP char(15),
@Password nchar(32),
@Username nvarchar(50),
@State int,
@Province int,
@City int,
@NowTime datetime,--为统一时间,用传入参数
@EmailItem varchar(1000),---设置项ID,以逗号分隔
@Code char(11),
@PrivDef int,--用户隐私设置默认值
@Sex int,
@NewUid int output--输出注册用户的ID
AS
DECLARE @Invitee int
DECLARE @Reply int
DECLARE @R int
DECLARE @InvtMail nvarchar(100)
Select @R=count(ID) from NT_FriendInvite where Method=1 and ValidCode=@Code
IF @R<1
RETURN 2
Select @Invitee=UserID,@InvtMail=Invitee,@Reply=Reply from NT_FriendInvite where Method=1 and ValidCode=@Code
if @Reply <> 0 
RETURN 3
select @R=count(UserID) from NT_User where Email=@Email
IF @R >0 
RETURN 4
select @R=count(ID) from NT_SpareEmail where Email=@Email
IF @R > 0
RETURN 4
BEGIN TRAN
   Insert into NT_User ([Email],[Password],[Username],[State],[LoginTimes],[Province],[City],[RegTime],[RegIP],[InviterID],[LastLoginTime],[LastLoginIP]) values (@Email,@Password,@Username,@State,1,@Province,@City,@NowTime,@IP,@Invitee,@NowTime,@IP)
   SELECT @NewUid=@@IDENTITY
   insert into NT_UserInfo(UserID,sex) VALUES(@NewUid,@Sex)
   Insert into NT_UserSetting (UserID,PrivSpace,PrivFavourite,PrivEducate,PrivLasso,PrivFriends,PrivLeaveWord,PrivMiniBlog,PrivShare,PrivGroup,PrivMovies,ActUpdateData,ActAddFriend,ActLeaveWord,ActPicComment,ActSecede,ActDeliver,ActLogComment,ActMovieComment,ActPhotoLasso,ActShareComment,LastPostTime,LastPostIP)
         values (@NewUid,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,1,1,1,1,1,1,1,1,1,1,@NowTime,@IP)
   UPDATE NT_FriendInvite SET Reply=1,ReplyTime=@NowTime,ReplyIP=@IP,RealEmail=@Email,RegUserID=@NewUid,RealInviter=@Invitee  where Invitee=@InvtMail
-------加为好友
   Insert into NT_Friend (UserID,FriendID,State,AddTime) values (@NewUid,@Invitee,0,@NowTime)
    Insert into NT_Friend (UserID,FriendID,State,AddTime) values (@Invitee,@NewUid,0,@NowTime)
-------以下为设置邮件通知
 EXEC NTP_EmailNotifyInit @EmailItem,@NewUid,@NowTime,@IP
 ---设置登录
  
IF @@error=0
BEGIN
  COMMIT TRAN
  RETURN 1
END
ELSE
BEGIN
  ROLLBACK TRAN
  RETURN 5
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO




CREATE  PROCEDURE [dbo].[NTP_Page] 
@IndexField varchar(50)='id',
@AllFields varchar(1000)='*', --需要返回的列 
@TablesAndWhere varchar(1000)='', -- 表名和条件,from后面的,不要from,要一条where
@OrderFields varchar(255)='',-- 排序的字段名
@PageSize int = 10, -- 页尺寸
@PageIndex int = 1, -- 页码
@RecordCount int output,
@PageCount int output
AS
if @PageSize < 1
set @PageSize = 10
declare @strSQL nvarchar(4000) -- 主语句
set @strSQL = 'select @RecordCount=count('+ @IndexField +') from '+ @TablesAndWhere
exec sp_executesql @strSQL,N'@RecordCount int output',@RecordCount out
if @RecordCount % @PageSize = 0
set @PageCount = @RecordCount/@PageSize
else
set @PageCount = @RecordCount/@PageSize+1
if(@PageIndex > @PageCount)
set @PageIndex = @PageCount
if @PageIndex < 1
set @PageIndex = 1
if @PageIndex = 1
set @strSQL='select top ' + CAST(@PageSize as nvarchar) + ' ' + @AllFields + ' from '+ @TablesAndWhere + ' ' + @OrderFields
else
begin
declare @start int
set @start = (@PageIndex - 1) * @PageSize
set @strSQL= 'select top ' + CAST(@PageSize as nvarchar) + ' ' +  @AllFields  + ' from ' +  @TablesAndWhere + ' and '+ @IndexField  + ' not in (select top ' + CAST(@start as nvarchar) + ' ' + @IndexField + ' from ' + @TablesAndWhere + ' ' + @OrderFields +') '+ @OrderFields
end
exec sp_executesql @strSQL




GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE [dbo].[NTP_UrlRegister]
@InviterID int,
@Email nvarchar(100),
@IP char(15),
@Password nchar(32),
@Username nvarchar(50),
@State int,
@Province int,
@City int,
@NowTime datetime,--为统一时间,用传入参数
@VerifyCode char(11),
@EmailItem varchar(1000),---设置项ID,以逗号分隔
@PrivDef int,--用户隐私设置默认值
@Sex int,
@NewUid int output
 AS
DECLARE @R int
select @R=count(UserID) from NT_User where Email=@Email
IF @R >0 
RETURN 2
select @R=count(ID) from NT_SpareEmail where Email=@Email
IF @R > 0
RETURN 2
BEGIN TRAN
   Insert into NT_User ([Email],[Password],[Username],[State],[LoginTimes],[Province],[City],[RegTime],[RegIP],[VerifyCode],[InviterID]) values (@Email,@Password,@Username,@State,0,@Province,@City,@NowTime,@IP,@VerifyCode,@InviterID)
   SELECT @NewUid=@@IDENTITY
   insert into NT_UserInfo(UserID,sex) VALUES(@NewUid,@Sex)
   Insert into NT_UserSetting (UserID,PrivSpace,PrivFavourite,PrivEducate,PrivLasso,PrivFriends,PrivLeaveWord,PrivMiniBlog,PrivShare,PrivGroup,PrivMovies,ActUpdateData,ActAddFriend,ActLeaveWord,ActPicComment,ActSecede,ActDeliver,ActLogComment,ActMovieComment,ActPhotoLasso,ActShareComment,LastPostTime,LastPostIP)
         values (@NewUid,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,@PrivDef,1,1,1,1,1,1,1,1,1,1,@NowTime,@IP)
   Insert into NT_FriendInvite (UserID,Method,Reply,ReplyTime,ReplyIP,RealEmail,RegUserID,RealInviter) values (@InviterID,2,1,@NowTime,@IP,@Email,@NewUid,@InviterID)
   Insert into NT_Friend (UserID,FriendID,State,AddTime,ClassID,FDegree)values(@NewUid,@InviterID,0,@NowTime,0,0)
   Insert into NT_Friend (UserID,FriendID,State,AddTime,ClassID,FDegree)values(@InviterID,@NewUid,0,@NowTime,0,0)
-------以下为设置邮件通知
 EXEC NTP_EmailNotifyInit @EmailItem,@NewUid,@NowTime,@IP

IF @@error=0
BEGIN
  COMMIT TRAN
  RETURN 1
END
ELSE
BEGIN
  ROLLBACK TRAN
  RETURN 3
END


GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

