表结构大致如下id username state
1 a 0
2 b 0
3 c 0
4 d 0
5 e 0
6 f 0
7 h 0
8 l 0
9 g 0要求 每次查询两行内容(只查询state = 0 的内容),并同时把被查询的内容的 state 修改为 1
1 a 0
2 b 0
3 c 0
4 d 0
5 e 0
6 f 0
7 h 0
8 l 0
9 g 0要求 每次查询两行内容(只查询state = 0 的内容),并同时把被查询的内容的 state 修改为 1
解决方案 »
- SQL外围应用配置器打不开,怎么解决?
- ASP页面无法打开求助!
- 求一句拍 SQL Server 2005 马屁的英语句子的翻译
- VS中SQLCLR数据库项目部署失败问题
- 给sql加密,我怎么加密都没有反应?
- 表中有500万条记录,要求随机选择1000条,使用order by newID,结果速度非常慢,要5分钟!请高手解决!100分,在线等
- 为什么拨掉网线后就连接不了本机数据库了?
- 这个问题怎么解决?select top ? * from xxx 里的?不可以用参数吗?
- 我在服务器级添加一个登录用户,不给任何服务器角色,使之成为A数据库的dbowner,所有数据库角色,为何不能检索A库中的表,竟无select等
- 有关oracle的特权和角色
- 求sql语句
- 有关于SQL的联合查询疑问,求助各位
是不是还要加个pre-condition: id列非空 ?
output inserted.*
where state=0
sql 2005的新语法,挺好的
set state=1
output inserted.id,inserted.username,inserted.[state] into @t
where state=0select * from @t
insert #tb select 1 ,'a', 0 union all
select 2 ,'b', 0 union all
select 3 ,'c', 0 union all
select 4 ,'d', 0 union all
select 5 ,'e', 0 union all
select 6 ,'f', 0 union all
select 7 ,'h', 0 union all
select 8 ,'l', 0 union all
select 9 ,'g', 0declare @t table(id int ,username varchar (10), [state] tinyint)update top (2) #tb
set state=1
output inserted.id,inserted.username,inserted.[state] into @t
where state=0select * from @t
(9 行受影响)(2 行受影响)
id username state
----------- ---------- -----
1 a 1
2 b 1(2 行受影响)