use master
go
disk init
name="mai1dev",
physname="c:\mai1dev",
vdevno=6,
size=1024
go
disk init
name="mai1dev2",
physname="c:\mai1dev2",
vdevno=7,
size=2048
go
disk mirror
name="mai1dev",
mirror="c:\mai1dev.mir"
go
sp_diskdefault mai1dev,defaulton
set nocount on
if exists (select * from master.dbo.sysdatabases
where name = "maidb")
begin
drop database maidb
end
go
print 'Creating the "maidb" database'
go
create database maidb
on mai1dev2=4
log on mai1dev=2
with override
go
set dateformat mdy
go
use maidb
go
if exists (select * from master.dbo.sysdatabases
where name = "maidb")
begin
execute sp_addtype id, "varchar(11)", "not null"
execute sp_addtype cid , "varchar(6)", "not null"
end
go
if exists (select * from master.dbo.sysdatabases
where name = "maidb")
begin
create table banji
(bj_id char(8) not null,
bj_name varchar(20) not null,
banzhang varchar(20) not null,
phone char(12) not null)
end
go
grant select on banji to public
go
if exists (select * from master.dbo.sysdatabases
where name = "maidb")
begin
create table kecheng
(kc_id char(8) not null,
kc_name varchar(20) null)
end
go
grant select on kecheng to public
go
if exists (select * from master.dbo.sysdatabases
where name = "maidb")
begin
create table jiaoshi
(js_id char(8) not null,
js_name char(8) not null,
zhiye varchar(20) not null,
xi_id char(8) not null,
zy_id char(8) not null,
xb char(2) not null)
end
go
grant select on jiaoshi to public
go
if exists (select * from master.dbo.sysdatabases
where name = "maidb")
begin
create table xi
(xi_id char(8) not null,
xi_name varchar(20) not null,
xzr varchar(20) not null,
jxms varchar(20) not null,
phone char(12) not null)
end
go
grant select on xi to public
go
if exists (select * from master.dbo.sysdatabases
where name = "maidb")
begin
create table zhuanye
(zy_id char(8) not null,
zy_name varchar(20) not null,
xyzr varchar(20) not null,
phone char(12) not null)
end
go
grant select on zhuanye to public
go
if exists (select * from master.dbo.sysdatabases
where name = "maidb")
begin
create table jskc
(js_id char(8) not null,
kc_id char(8) not null,
bj_id char(8) not null,
jc_id char(8) not null,
xs int not null,
cxf int not null,
didian varchar(20) not null,
ks int not null)
end
go
grant select on jske to public
go
if exists (select * from master.dbo.sysdatabases
where name = "maidb")
begin
create table jiaocai
(jc_id char(8) not null,
jiaocai varchar(20) not null)
end
go
grant select on jiaocai to public
go
if exists (select * from master.dbo.sysdatabases
where name = "maidb")
begin
create table xskc
(bj_id char(8) not null,
kc_id char(8) not null,
xuehao char(8) not null,
chengji int not null,)
end
go
grant select on xske to public
go
if exists (select * from master.dbo.sysdatabases
where name = "maidb")
begin
create table xueshen
( xuehao char(8) not null,
name varchar(20) not null,
xb char(2) not null,
bj_id char(8) not null,
rq datetime not null,
zy_id cha