SQL_查询当天、近几天、本周、本月的SQL语句
经常会有时候要用到查询当天,近几天,本周,本月的相关数据,所以记录一下这些比较特殊的SQL语句~~
--当天
(usrRegTime >=CONVERT(varchar(10),getDate(),120)+' 00:00:00' and usrRegTime <=CONVERT(varchar (10),getDate(),120)+' 23:59:59')
--近三天
DateDiff(day,usrRegTime,getdate()) <=3
--本周
Datepart(year,usrRegTime)=DatePart(year,Getdate()) and DatePart(week,usrRegTime)=DatePart (week,GetDate())
--本月
Datepart(year,usrRegTime)=DatePart(year,Getdate()) and DatePart(month,usrRegTime)=DatePart (month,GetDate())
相关文档:
准备工作
首先,操作系统中安装好SQL Server 2000/2005,如果系统中都装有2000和2005版,记得停用一个,只开一个行了。
然后,到微软网站下载Microsoft SQL Server 2005 JDBC Driver 1.1
,也可以使用这个地址直接下载
。
解压sqljdbc_1.1.1501.101_chs.exe,把sqljdbc_1.1复制到%ProgramFiles%(如果系统在C盘则为C:\ ......
1、WINDOWS身份登陆:
<connectionStrings>
<add name="connectionString" connectionString="Data Source=(local);Initial Catalog=AngelicaDB;Integrated Security=True" providerName="System .Data .SqlClient" /> ......
select * from books
where 1=1
and categoryid=29
and title like('%ASP.NET%')
and unitprice>10
order by id
Select top 20 * from books order by id
--m:每页显示行数 n:当前页数
select Top m * from books
where id not in
(Select top m(n-1) id from books order by id)
order by id
select * fro ......
1. 当前系统日期、时间
select getdate()
2. dateadd 在向指定日期加上一段时间的基础上,返回新的 datetime 值
例如:向日期加上2天
select dat ......
最简单的SQL Server数据库存储过程分页
发布时间:2008.07.02 05:11 来源:赛迪网 作者:Alizze
【赛迪网-IT技术报道】最简单的SQL Server数据库存储过程分页:
1.只需要提供Sql语句和每页的记录数,页数就可以了
2,速度超快哟,100W记录1~3秒就分出来了
......