易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

SQLserver中用convert函数转换日期格式

【问题描述:】
      一个用户表中的注册日期显示格式是:yyyy-mm-dd Thh:mm:ss.mmm 。而我想统计出每天的用户注册数,直接group注册日期字段显然是不行的。
【问题处理:】
      利用SQLserver中的convert函数对日期进行转换转换。group转换后的日期。
【脚  ......

sqlserver 存储过程例子

 什么是存储过程呢?
  定义:
  将常用的或很复杂的工作,预先用SQL语句写好并用一个指定的名称存储起来, 那么以后要叫数据库提供与已定义好的存储过程的功能相同的服务时,只需调用execute,即可自动完成命令。
  讲到这里,可能有人要问:这么说存储过程就是一堆SQL语句而已啊?
  Microsoft公司为什么还 ......

Sqlserver:从XML文件中读取配置信息

如何在Sqlserver中从外部XML文件中读取配置信息呢?该问题源自一家企业的笔试信息有感。
一xml文件内容:
<?xml version="1.0" encoding="utf-8"?>
<root>
  <db name="ClientDB1" datasize="512MB" datagrowth="100MB" logsize="100MB" loggrowth ="50MB">
  </db>
  <db ......

Python连接SqlServer练习记录


import pymssql

#connect database
conn=pymssql.connect(host="192.168.1.28",user="boomink",password="boomink",
database="boomink")

cur=conn.cursor()

print '========================================'

cur.execute("exec Orders_GetTest1 @Valu ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号