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

 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日期格式代码

转换方法: convert(nvarchar(8),starttime,14)
    100   (1,   2)  
    默认设置  
    mon   dd   yyyy   hh:miAM(或   PM)     
    
    101  
&nbs ......

Datetime显示方式SQLServer


今天在写视图时,遇到要把Datetime类型转Varchar类型。以前在ORALCE就容易,直接ToChar(getdate(),'yyyy-mm-dd')。在SQL Server 2005
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12
select CONVERT(varchar(12) , getdate(), 112 )
200 ......

sqlserver 期中考试题

 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,
 sag ......

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 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号