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
相关文档:
SQLServer和Oracle是大家经常用到的数据库,在此总结出这些常用函数以供
大家参考。
数学函数
1.绝对值
S:select abs(-1) value
O:select abs(-1) value from dual
2.取整(大)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.取整(小)
S:s ......
--每个月的第一天
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
二、创建索引的其他因素(主要因素都因为索引是数据表外部 ......
原文出处:http://www.cnblogs.com/luoht/archive/2010/03/01/1676049.html
用IN写出来的SQL的优点是比较容易写及清晰易懂,这比较适合现代软件开发的风格。
但是用IN的SQL性能总是比较低的,从SQL执行的步骤来分析用IN的SQL与不用IN的SQL有以下区别:
SQL试图将其转换成多个表的连接,如果转换不成功则先执行 ......