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

sql server 2000 日期函数(联机帮助)

1.DATEADD函数
  在向指定日期加上一段时间的基础上,返回新的 datetime 值。
语法
DATEADD ( datepart , number, date )
参数
datepart
日期部分
缩写
Year
yy, yyyy
quarter
qq, q
Month
mm, m
dayofyear
dy, y
Day
dd, d
Week
wk, ww
Hour
hh
minute
mi, n
second
ss, s
millisecond
ms
2. DATEDIFF函数
返回跨两个指定日期的日期和时间边界数
参数
 datepart
是规定了应在日期的哪一部分计算差额的参数。
同上
 
测试数据:
if object_id('mma') is not null drop table mma
go
create table mma(mydate datetime)
go
insert into mma
select '20090203' union all
select '20090205' union all
select '20090209' union all
select '20091231' union all
select '20100102' union all
select '20100112' union all
select '20100116'
 
--查询返回本月的记录
方法一
select mydate from mma where datediff(m,mydate,getdate())=0(注当前日期是20100116)
方法二
SELECT * from mma WHERE CONVERT(CHAR(6), mydate,112)=CONVERT(CHAR(6),GETDATE(),112)
方法三
select mydate from aa where substring(convert(varchar(20),getdate(),120),0,8)=substring(convert(varchar(20),mydate,120),0,8)


相关文档:

Oracle 查询并删除重复记录的SQL语句


查询及删除重复记录的SQL语句
1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断
select * from people
where peopleId in (select   peopleId from   people group by   peopleId having count(peopleId) > 1)
 
2、删除表中多余的重复记录,重复记录是 ......

SQL命令查询Oracle存储过程信息(代码内容等)

SELECT * from ALL_SOURCE 
where TYPE='PROCEDURE'  AND TEXT LIKE
'%0997500%';
--查询ALL_SOURCE中,(脚本代码)内容与0997500模糊匹配的类型为PROCEDURE(存储过程)的信息。
根据GROUP
BY TYPE
该ALL_SOURCE中只有以下5种类型
1 FUNCTION
2 JAVA
SOURCE
3 PACKAGE
4 P ......

sql特殊语法

复制表的结构
select * into newtable from oldtable where 1<>1
复制表达额内容
insert into new table select *(列名) from oldtable
datediff函数用法
作用     
  返回两个日期之间的间隔。  
   
    语法   ......

在SQL Server 2005数据库中实现自动备份

第1种方法:
企业管理器
  --管理
  --右键数据库维护计划
  --新建维护计划
  --<下一步>
  --选择你要备份的数据库
  --<下一步>直到"指定数据库备份计划"这项
  --指定存储备份文件的位置,这里根据需要选择备分到磁带还是磁盘
  --单击调度后面的"更改"按 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号