易截截图软件、单文件、免安装、纯绿色、仅160KB

sqlserver 视图

/*drop table scourse
drop table course
drop table student
drop table major*/
create database db
use db
--专业表
create table major
(spno char(5) not null primary key,
 spname varchar(20) not null,
 pno char(2) )
--学生表
create table student
(sno char(7) not null primary key,
 sname varchar(20) not null,
 ssex char(2) not null,
 sage smalldatetime ,
 spno char(5) not null foreign key references major(spno),
 classid char(5),
 Inyear char(4) not null )
--课程表
create table course
(cno char(10) not null primary key,
cname varchar(20) not null,
credit smallint ,
tno char(3))
--选课表
create table scourse
(sno char(7) not null foreign key references student(sno),
 cno char(10) not null foreign key references course(cno),
 Gmark numeric(4,1),
primary key(sno,cno))
/*(1)建立00312专业选修了001号课程的学生视图Stu_01312_1;
(2)建立00312专业选修了1号课程并且成绩不及格的学生视图Stu_00312_2;
(3)建立视图Stu_year,由学生学号、姓名、年龄组成;
(4)通过视图查询20岁以上的学生姓名;
(5)通过视图查询00312专业选修了1号课程并且成绩不及格的学生的学号、姓名、年龄。*/
//第一题
 drop view Stu_01312_1
 go
  create view Stu_01312_1 as select * from student where spno='00312' and sno in (select sno from scourse where cno='1')
 go
  select * from Stu_01312_1
//第二题
drop view Stu_00312_2
  go
  create view   Stu_00312_2 as select * from student where spno='00312'  and sno in(select sno from scourse where cno='1' and Gmark < 60)
 go
select * from Stu_00312_2
//第三题
 drop view Stu_00312_3
go
create view Stu_00312_3 as select sno,sname,sage from student
go
//第四题
select sname from Stu_00312_3 where sage >20
//第五题
select sno,sname,sage from Stu_00312_2


相关文档:

用SQL语句得到SQLServer 的表中的列的描述值

 select   case   when   c.colid=1   then   object_name(c.id)   else   ''   end   as   表名    
  ,c.name   as   字段名  
  ,t.name   数据类型  
  ,c.prec   as   长度   ......

sqlserver 上机练习题

 create database db
use db
go
create table course
(
 sno varchar(20),
 cno int ,
 Gmark int
)
insert into course values('20071513115',1,80)
insert into course values('20071513114',2,80)
insert into course values('20071513113',3,80)
insert into course values('20071513 ......

通用的SqlServer操控类

 using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;


public class CommandInfo
{
public string CommandText;
public SqlPa ......

sqlserver安装问题总结(SqlServer2000/2005)

 SQL Server 2000
Installing SQL Server 2000 (E文)
http://msdn.microsoft.com/en-us/library/aa299042(SQL.80).aspx
SQL Server 2000补丁
Microsoft SQL Server 2000 Service Pack 3a
http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=90DCD52C-0488-4E46-AFBF-ACACE536 ......

sqlserver 中使用程序集Assembly

                               **在sqlserver中如果要使用一个程序集一般有如下注意事项 
一:打开sqlserver 的CLR支持
 
   &nb ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号