sqlserver分页
现在一般常用的有以下2种方法:
1. select top @pagesize * from table1 where id not in (select top @pagesize*(@page-1) id from table1 order by id) order by id
2. select * from (select top @pagesize * from (select top @pagesize*@page * from table1 order by id) a order by id desc) b order by id
相关文档:
SQLServer2005通过intersect,union,except和三个关键字对应交、并、差三种集合运算。
他们的对应关系可以参考下面图示
相关测试实例如下:
use tempdb
go
if (object_id ('t1' ) is not null ) drop table t1
if (object_id ('t2' ) is not null ) drop table t2
go ......
在
SQLServer2005
中对
XML
的处理功能显然增强了很多,提供了
query(),value(),exist(),modify(),nodes()
等函数。
关于
xml
,难以理解的不是
SQLServer
提供的函数,而是对
xml
本身的理解,看似很简单的文件格式,处理起来却是非常困难的。本文只是初探一下而已。
详见
SQLServer
联机帮助:
主题
说 ......
--每个月的第一天
select dateadd(dd,-datepart(dd,getdate())+1,getdate())
--第个月的最后一天
select dateadd(dd,-datepart(dd,getdate()),dateadd(mm,1,getdate()))
--本月的天数
select datediff(dd,getdate(),dateadd(mm,1,getdate()))
......
一、SQLServer 通用索引字段
1、Primary Key's 主键
2、Foreign Key's 外键
3、支持SELECT、INSERT、UPDATE和DELETE命令的字段 :
(1)、INNER JOIN
(2)、RIGHT | LEFT OUTER JOIN
(3)、WHERE
(4)、ORDER BY
(5)、GROUP BY
(6)、HAVING
二、创建索引的其他因素(主要因素都因为索引是数据表外部 ......