|
|
#6
mywisdom882017-05-23 09:14
/*
create table Class(ClassNo char(6),ClassName varchar(30),Institute varchar(30),Grade datetime)
insert into Class(ClassNo,ClassName,Institute,Grade)
select 'CP0801','注册会计08-01班','会计学院','2008-09-01' union all
select 'CP0802','注册会计08-02班','会计学院','2008-09-01' union all
select 'CP0803','注册会计08-03班','会计学院','2008-09-01' union all
select 'CS0701','计算机科学与技术07-01班','信息管理学院','2007-09-01' union all
select 'CS0702','计算机科学与技术07-02班','信息管理学院','2007-09-01'
*/
select * from Class
/*
create table Student(StudentNo char(6),StudentName varchar(30),Sex char(2),ClassNo char(6))
declare @i int,@stuNo char(6),@stuName varchar(30),@sex char(2),@classNo char(6),@k int
set @i=1
set @k=1
while @k<20
begin
set @stuNo='S'+right('00000'+cast(@i as varchar(5)),5)
set @stuName = '张'+right('00000'+cast(@i as varchar(5)),5)
set @sex='男'
set @classNo='CP0801'
insert into Student(StudentNo,StudentName,Sex,ClassNo) values(@stuNo,@stuName,@sex,@classNo)
set @i=@i+1
set @k=@k+1
end
set @k=1
while @k<25
begin
set @stuNo='S'+right('00000'+cast(@i as varchar(5)),5)
set @stuName = '李'+right('00000'+cast(@i as varchar(5)),5)
set @sex='女'
set @classNo='CP0802'
insert into Student(StudentNo,StudentName,Sex,ClassNo) values(@stuNo,@stuName,@sex,@classNo)
set @i=@i+1
set @k=@k+1
end
set @k=1
while @k<30
begin
set @stuNo='S'+right('00000'+cast(@i as varchar(5)),5)
set @stuName = '王'+right('00000'+cast(@i as varchar(5)),5)
set @sex='男'
set @classNo='CP0803'
insert into Student(StudentNo,StudentName,Sex,ClassNo) values(@stuNo,@stuName,@sex,@classNo)
set @i=@i+1
set @k=@k+1
end
set @k=1
while @k<35
begin
set @stuNo='S'+right('00000'+cast(@i as varchar(5)),5)
set @stuName = '陈'+right('00000'+cast(@i as varchar(5)),5)
set @sex='女'
set @classNo='CS0701'
insert into Student(StudentNo,StudentName,Sex,ClassNo) values(@stuNo,@stuName,@sex,@classNo)
set @i=@i+1
set @k=@k+1
end
set @k=1
while @k<40
begin
set @stuNo='S'+right('00000'+cast(@i as varchar(5)),5)
set @stuName = '刘'+right('00000'+cast(@i as varchar(5)),5)
set @sex='男'
set @classNo='CS0702'
insert into Student(StudentNo,StudentName,Sex,ClassNo) values(@stuNo,@stuName,@sex,@classNo)
set @i=@i+1
set @k=@k+1
end
*/
select * from Student
|