求SQL 2005中取随机记录,并且每次要取不同的记录,取过的不在获取
求SQL2005中取随机记录,并且每次要取不同的记录,取过的不在获取如:假设表A中一万条记录,用户B从表A中随机取出1条记录C,当B用户重新获取时记录直接过滤掉之前取到过...
求SQL 2005中取随机记录,并且每次要取不同的记录,取过的不在获取
如:
假设表A中一万条记录,用户B从表A中随机取出1条记录C,当B用户重新获取时记录直接过滤掉之前取到过的C记录,当D用户来取记录时重复用户B的步骤,以经类推。
求表设计方案和存储过程
有偿服务!5572367
在线等 展开
如:
假设表A中一万条记录,用户B从表A中随机取出1条记录C,当B用户重新获取时记录直接过滤掉之前取到过的C记录,当D用户来取记录时重复用户B的步骤,以经类推。
求表设计方案和存储过程
有偿服务!5572367
在线等 展开
展开全部
create table tb
(
id int identity (1,1),
tname varchar(20)
)
insert into tb (tname ) values ('a');
insert into tb (tname ) values ('b');
insert into tb (tname ) values ('c');
insert into tb (tname ) values ('d');
insert into tb (tname ) values ('e');
insert into tb (tname ) values ('f');
insert into tb (tname ) values ('g');
insert into tb (tname ) values ('h');
insert into tb (tname ) values ('i');
insert into tb (tname ) values ('j');
insert into tb (tname ) values ('k');
insert into tb (tname ) values ('l');
insert into tb (tname ) values ('m');
insert into tb (tname ) values ('n');
insert into tb (tname ) values ('o');
insert into tb (tname ) values ('p');
insert into tb (tname ) values ('q');
insert into tb (tname ) values ('r');
insert into tb (tname ) values ('s');
insert into tb (tname ) values ('t');
insert into tb (tname ) values ('u');
insert into tb (tname ) values ('v');
insert into tb (tname ) values ('w');
insert into tb (tname ) values ('x');
insert into tb (tname ) values ('y');
insert into tb (tname ) values ('z');
create table tb_ls
(
id_new int identity(1,1),
id int,
tname varchar(20),
strname varchar(20)
)
declare @strname varchar(20)
set @strname ='m'
insert into tb_ls (id,tname ,strname )
select top (1) * ,@strname from tb
where id not in (select id from tb_ls where strname =@strname )
order by NEWID ()
select id ,tname from tb_ls where strname =@strname and id_new =(select MAX(id_new ) from tb_ls where strname =@strname )
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询