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

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

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

CREATE TABLE [dbo].[Asean_adclass] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[S_typeid] [int] NULL ,
	[S_sortname] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[S_jifeng] [int] NULL ,
	[S_remark] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[S_rebate] [decimal](18, 2) NULL ,
	[S_w] [int] NULL ,
	[S_H] [int] NULL ,
	[S_num] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Asean_adlist] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[A_userid] [nvarchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
	[A_jifen] [float] NULL ,
	[A_starttime] [smalldatetime] NULL ,
	[A_endtime] [smalldatetime] NULL ,
	[A_typeid] [int] NULL ,
	[A_sortid] [int] NULL ,
	[A_rebate] [float] NULL ,
	[A_pic] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[A_place] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[A_website] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[A_explain] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[A_webname] [nvarchar] (40) COLLATE Chinese_PRC_CI_AS NULL ,
	[A_unit] [int] NULL 
) ON [PRIMARY]
GO

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

ALTER TABLE [dbo].[Asean_adclass] ADD 
	CONSTRAINT [PK_Asean_adclass] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[Asean_adlist] ADD 
	CONSTRAINT [PK_Asean_adlist] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[Asean_adtype] ADD 
	CONSTRAINT [PK_Asean_adtype] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

if not exists(SELECT 1 FROM sysobjects a,syscolumns b WHERE a.id=b.id AND OBJECTPROPERTY(a.id,N'IsUserTable')=1 and a.name='Siruo_config' and b.name='A_passed')
alter table Siruo_config add A_passed int default 0
if not exists(SELECT 1 FROM sysobjects a,syscolumns b WHERE a.id=b.id AND OBJECTPROPERTY(a.id,N'IsUserTable')=1 and a.name='Siruo_config' and b.name='Q_passed')
alter table Siruo_config add Q_passed int default 0

if not exists(SELECT 1 FROM sysobjects a,syscolumns b WHERE a.id=b.id AND OBJECTPROPERTY(a.id,N'IsUserTable')=1 and a.name='Siruo_answer' and b.name='passed')
alter table Siruo_answer add passed int default 0

if not exists(SELECT 1 FROM sysobjects a,syscolumns b WHERE a.id=b.id AND OBJECTPROPERTY(a.id,N'IsUserTable')=1 and a.name='Siruo_user' and b.name='User_type')
alter table Siruo_user add User_type int default 0

alter table [Siruo_user]  add  user_fax [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL
alter table [Siruo_user]  add  user_code [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL
alter table [Siruo_user]  add  user_Products [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL
alter table [Siruo_user]  add  user_companyname [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL

update Siruo_config set A_passed=0
update Siruo_config set Q_passed=0
update Siruo_answer set passed=1
update Siruo_user set user_type=0