存在于文本文件中的多条Sql语句如何一次性在aspx页面中执行,在线等待
在不借助SqlServer2000的工具的情况下,我如何将存在于my.sql文本文件中的多条sql语句在aspx页面中执行,该文本文件主要是创建表的语句和一些数据插入语句,我能够正确地连接到数据库,但是我需要通过aspx页面在数据库中创建所有的表,下面是My.sql文件中的一部分内容
--创建学生信息表
--学生信息表中的S_ID为“系别-年级-六位编码”,比如1993级采矿系王廷华的S_ID为CK-1993-199703
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[student_info]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[student_info]
GO
create table student_info
(
S_ID varchar(14) primary key,
S_Name varchar(20) not null,
S_iflogin bit,
Constraint S_ID_CHECK check(S_ID like '[A-Z][A-Z]-[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]')
)
insert into student_info values('CK-1993-199703','王廷华',0)
insert into student_info values('CK-1993-199701','王立朝',0)
insert into student_info values('CK-1993-199702','陈江波',0)
insert into student_info values('CK-1993-199704','秦立论',0)
insert into student_info values('CK-1993-199705','林学历',0)
insert into student_info values('CK-1993-199706','陈伟',0)
insert into student_info values('CK-1993-199707','侯乐军',0)
insert into student_info values('CK-1993-199708','白冰',0)
insert into student_info values('CK-1993-199709','杨士朝',0)
insert into student_info values('CK-1993-199710','赵军',0)
insert into student_info values('CK-1993-199711','google',0)
GO
--========================================================================================
--创建学生注册表student_login
if exists (select * from dbo.sysobjects where id=object_id(N'[dbo].[student_login]') and OBJECTPROPERTY(id,N'IsUserTable')=1)
drop table [dbo].[student_login]
go
Create table student_login
(
S_ID varchar(14) primary key ,--学生学号
SL_Name varchar(20) unique not null,--学生注册笔名
SL_Pwd varchar(20) not null,--注册用的密码
SL_Date datetime default(getDate()),--注册时间,采用该行创建的时间
SL_MailBox varchar(30),--注册邮箱
SL_phone varchar(20),--注册电话
SL_Remark varchar(500),--备注
SL_ifclass bit,--是否选择班级
Foreign key(S_ID) references student_info(S_ID)
)
GO
--=========================================================================================
--创建班级学生表class_student
if exists (select * from dbo.sysobjects where id=object_id(N'[dbo].[class_student]') and OBJECTPROPERTY(id,N'IsUserTable')=1)
drop table [dbo].[class_student]
go
create table class_student
(
S_ID varchar(14) primary key,
class_id int,--班级序号
seat_id varchar(10),--作为序号
foreign key(S_ID) references student_info(S_ID)
)
GO
--=======================================================================================================
--创建通知信息表(Notice_info)
if exists (select * from dbo.sysobjects where id=object_id(N'[dbo].[Notice_info]') and OBJECTPROPERTY(id,N'IsUserTable')=1)
drop table [dbo].[Notice_info]
go
create table Notice_info
(
N_ID varchar(20) primary key,--通知序号
N_title varchar(100) not null,--通知标题
N_content varchar(5000) not null,--通知内容
Nu_date dateTime,--通知发布时间
Nu_student varchar(100) default 'All'--发布对象,默认所有
)
GO
--=======================================================================================================
--作业提交表(Exercise_update)
if exists (select * from dbo.sysobjects where id=object_id(N'[dbo].[Exercise_update]') and OBJECTPROPERTY(id,N'IsUserTable')=1)
drop table [dbo].[Exercise_update]
go
create Table Exercise_update
(
EU_ID varchar(20) not null,--作业序号
S_ID varchar(14) foreign key references student_info(S_ID),--学生学好
E_title varchar(100) not null,--作业标题
Eu_date datetime,--提交日期
constraint Exercise_update_pri primary key clustered--聚焦主键
(
EU_ID,S_ID
)
)
GO
--=======================================================================================================
--学生成绩表(stument_mark)
if exists (select * from dbo.sysobjects where id=object_id(N'[dbo].[stument_mark]') and OBJECTPROPERTY(id,N'IsUserTable')=1)
drop table [dbo].[stument_mark]
go
create Table stument_mark
(
S_ID varchar(14) primary key,--学生学号
Lab1_mark numeric,--试验课1成绩
Lab2_mark numeric,--试验课2成绩
Lab3_mark numeric,--试验课3成绩
Lab4_mark numeric,--试验课4成绩
Lab5_mark numeric,--试验课5成绩
exercise_mark numeric,--作业成绩
Exam_mark numeric,--考试成绩
foreign key(S_ID) references student_info(S_ID)
)
GO