IF EXISTS (SELECT 1 FROM sys.databases WHERE name = N'Wish')
DROP DATABASE [Wish]
GO
CREATE DATABASE [Wish]
GO
--论坛
--表
--Users表存储论坛注册成员的信息
USE Wish
GO
IF exists (SELECT 1 FROM sys.objects WHERE name = 'Users' AND type = 'U')
DROP TABLE [dbo].[Users]
GO
CREATE TABLE [dbo].[Users] (
[UserID] INT IDENTITY PRIMARY KEY CLUSTERED,
[UserName] [varchar](16) NOT NULL UNIQUE ,
[Nickname] [nvarchar](16) NOT NULL,
[Password] [varchar] (60) NOT NULL,
[Email] [varchar] (255) NOT NULL default '',
[Question] [nvarchar] (60) NOT NULL default '',
[Answer] [nvarchar](60) NOT NULL default '',
[Sex] [varchar](1) NOT NULL DEFAULT 'M',
[ShowEmail] [bit] NOT NULL DEFAULT (1),
[Signature] [nvarchar] (1000) NOT NULL default '',
[ImageUrl] [varchar] (100) NOT NULL default '',
[AddedDate] [datetime] NOT NULL DEFAULT (getdate()),
[Type][tinyint] NOT NULL DEFAULT (0)
)
GO
--数据
--密码为wishwish
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('admin','admin','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','admin@wish-edu.com','admin','admin','M','images/faces/image1.gif',getdate(), 9)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('amandag','高歌','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','amandag@vip.sina.com','amandag','amandag','M','images/faces/image2.gif',getdate(), 1)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('moon','月亮之上','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','moon@wish-edu.com','moon','moon','F','images/faces/image3.gif',getdate(), 1)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('rebecca','雪儿','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','rebecca@wish-edu.com','rebecca','rebecca','F','images/faces/image4.gif',getdate(), 0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('Mickey','馨','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','Mickey@wish-edu.com','Mickey','Mickey','F','images/faces/image5.gif',getdate(),0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('Jia','佳佳','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','M','images/faces/image6.gif',getdate(),0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('aaa','aaa','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','F','images/faces/image7.gif',getdate(), 0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('bbb','bbb','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','F','images/faces/image8.gif',getdate(),0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('ccc','ccc','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','M','images/faces/image9.gif',getdate(),0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('ddd','ddd','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','F','images/faces/image10.gif',getdate(), 0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('eee','eee','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','F','images/faces/image11.gif',getdate(),0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('fff','fff','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','M','images/faces/image12.gif',getdate(),0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('ggg','ggg','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','F','images/faces/image13.gif',getdate(), 0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('hhh','hhh','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','F','images/faces/image14.gif',getdate(),0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('iii','iii','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','M','images/faces/image15.gif',getdate(),0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('jjj','jjj','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','F','images/faces/image16.gif',getdate(), 0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('kkk','kkk','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','F','images/faces/image17.gif',getdate(),0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('lll','lll','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','M','images/faces/image18.gif',getdate(),0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('mmm','mmm','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','F','images/faces/image19.gif',getdate(), 0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('nnn','nnn','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','F','images/faces/image20.gif',getdate(),0)
INSERT INTO Users([UserName], [NickName], [Password], [Email], [Question], [Answer], [Sex], [ImageUrl], [AddedDate],[Type])
VALUES('ooo','ooo','D7-63-C1-D4-53-8E-21-6A-34-1F-70-29-1B-4F-94-1E-9B-BB-FB-AE','test@wish-edu.com','test','test','M','images/faces/image21.gif',getdate(),0)
--返回所有可用用户信息
if exists (select 1 from sys.objects where name = 'GetUserList' and
type = 'P')
drop procedure [dbo].GetUserList
GO
CREATE PROCEDURE [dbo].GetUserList
AS
SELECT UserID, UserName, Nickname, Email, Question, Answer, Sex, ShowEmail, Signature, ImageUrl, AddedDate, [Type]
FROM Users
GO
--删除用户
if exists (select 1 from sys.objects where name = 'DeleteUser' and
type = 'P')
drop procedure [dbo].[DeleteUser]
GO
CREATE PROCEDURE DeleteUser
@UserID int
AS
DELETE FROM Users WHERE UserID = @UserID
GO
--更新用户Type
if exists (select 1 from sys.objects where name = 'UpdateType' and
type = 'P')
drop procedure [dbo].UpdateType
GO
CREATE PROCEDURE UpdateType
@UserID int ,
@Type varchar(255)
AS
UPDATE Users
Set [Type] = @Type
Where UserID = @UserID
GO