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

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,
 sage smalldatetime ,
 spno char(5) not null foreign key references major(spno),
 classid char(5),
 Inyear char(4) not null )
select datediff(yyyy,'1981-8-12',getdate())from student
--课程表
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))
//第一题
select * from student where datediff(yyyy,sage,getdate()) between 25 and (select datediff(yyyy,sage,getdate()) from student  where sname='李勇')
//第二题
select sno,sname from student where sno in  (  select sno from scourse where cno=(select cno from course where cname='操作系统'))
//第三题
 
select sname from student where sno in (select distinct sno from scourse where cno not in('1'))
//第四题
select sname,sno  from student where sno in(select sno from scourse group by sno having count(sno)=(select count(*) from course))
select student.sname,student.sno  from student where student.sno in(select scourse.sno from scourse group by scourse.sno having count(scourse.sno)=(select count(*) from course))
//第五题
select sname from student where sno in (select sno from student where Inyear='1999') and sno in (select sno from scourse where Gmark is null) and spno in(select spno from major where spname='计算机软件')
select student.sname from student where  student.sno in (select student.sno from student where student.Inyear='1999')   and student.sno in (select scourse.sno from scourse where


相关文档:

SqlServer中自定义类似Split截取字段函数

if exists (select * from dbo.sysobjects where name='SplitStr' )
drop FUNCTION SplitStr
go
CREATE   FUNCTION   SplitStr   (@splitString   varchar(8000),   @separate   varchar(10))  
RETURNS   @returnTable   ......

SQLServer导出表到EXCEL文件的存储过程

 SQL Server导出表到EXCEL文件的存储过程:
  *--数据导出EXCEL
  导出表中的数据到Excel,包含字段名,文件为真正的Excel文件
  ,如果文件不存在,将自动创建文件
  ,如果表不存在,将自动创建表
  基于通用性考虑,仅支持导出标准数据类型
  ---*/
  /**//*--调用示例
  p_exporttb @tbname='地区 ......

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

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