if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[StuPoints]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

CREATE TABLE [dbo].[StuPoints](
[StuPointsID] [Int]  IDENTITY(1,1) NOT NULL ,
[StudentID] [Int]   NULL ,
[Points] [Int]   NULL ,
[DateAndTime] [DateTime]   NULL ,
[Remark] [NVarChar] (100)  NULL ,
[UserID] [Int]   NULL ,
[TrueName] [NVarChar] (50)  NULL ,
[InsertTime] [DateTime]   NULL CONSTRAINT [DF_StuPoints_InsertTime]  DEFAULT (getdate()),

CONSTRAINT [PK_StuPoints] PRIMARY KEY CLUSTERED 
(
	[StuPointsID] ASC
))
GO

Alter Table [Sending] ADD [DataLevel] int CONSTRAINT [DF_Sending_DataLevel] Default (0) 
GO

Alter Table [SendLog] ADD [DataLevel] int CONSTRAINT [DF_SendLog_DataLevel] Default (0) 
GO



Alter Table [Sending] ADD [UserLevel] int CONSTRAINT [DF_Sending_UserLevel] Default (0) 
GO

Alter Table [SendLog] ADD [UserLevel] int CONSTRAINT [DF_SendLog_UserLevel] Default (0) 
GO

Alter Table [SmsTemplate] ADD [UserLevel] int CONSTRAINT [DF_SmsTemplate_UserLevel] Default (0) 
GO



Update [Sending] set DataLevel = 0 where DataLevel is null
GO

Update [SendLog] set DataLevel = 0 where DataLevel is null
GO



Update [Sending] set UserLevel = 0 where UserLevel is null
GO

Update [SendLog] set UserLevel = 0 where UserLevel is null
GO

Update [SmsTemplate] set UserLevel = 2 where UserLevel is null or UserLevel = 0
GO



Update DBInfo set DateAndTime='2012-08-02'
GO