Sql分页代码
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 * from
(select Row_number() over(order by id) as num,
* from books) as table1
where num between 21 and 30
相关文档:
有这样一个数据库表
t1 t2 t3……n
--------------------------
aaa ......
在SQL Server中, 我们有时需要在清空数据表之后,重新添加记录时,标识列重新从1开始计数。
我们只需要在插入记录之前,执行下面的命令:
DBCC CHECKIDENT (表名, RESEED, 0)
如果是清空表中内容再重置标识列可以选择使用 Truncate Table 命令:
Truncate Table tablename
TRUNCATE TABLE 在功能上与不带 WHERE 子句的 ......
select * from sq_donglong.achi_news where ID in (select ID from (select top 6 ID from sq_donglong.achi_news where SortID=82)a union all select ID from (select top 6 ID from sq_donglong.achi_news where SortID=84)b)
......
准备工作
首先,操作系统中安装好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:\ ......