你的意思是如果15条纪录序号分别1-15的话 第一次打开网页读取1-5 然后第二次打开网页读取6-10。这样?那多个网页同时打开怎么算?select top 5 ??? 然后同时把这5条纪录的状态更新为已读? 不理解意图
用一个变量times表示第几次,初始为1,值存放在文件或数据库里。打开网页时读出times的值,用sql语句 select top 5 * from 表名 where id not in(select top ((times-1)*5) id from 表名); 关闭网页时,times++,再写入文件或数据库。
--新建一个表 create table tb(id int) insert tb values(1) gocreate proc sptest as begin declare @id int select @id = id from tbselect * from 记录表 where id > (@id-1)*5 and id <= @id * 5update tb set id = case id + 1 when 4 then 1 else id + 1 endend --直接调用即可 exec sptest
第一次打开网页读取1-5
然后第二次打开网页读取6-10。这样?那多个网页同时打开怎么算?select top 5 ??? 然后同时把这5条纪录的状态更新为已读?
不理解意图
select top 5 * from 表名 where id not in(select top ((times-1)*5) id from 表名);
关闭网页时,times++,再写入文件或数据库。
我还是把问题重新描述一遍吧我的数据库里有15条记录,是网站地址,每一个记录有唯一的ID。。
现在我要用C#同时访问5条记录(ID=1到ID=5),并打开这些网站后,调用process.Kill()关闭这些网站,这是一个完整的过程。
紧接着我继续打开ID是6-10的记录,再打开再关闭网页。。一直这样循环下去。。谢谢楼上各位的答复!
--新建一个表
create table tb(id int)
insert tb values(1)
gocreate proc sptest
as
begin
declare @id int
select @id = id from tbselect * from 记录表 where id > (@id-1)*5 and id <= @id * 5update tb set id = case id + 1 when 4 then 1 else id + 1 endend
--直接调用即可
exec sptest