Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何从表中选择前100行,并将所有选定行的列值更新为“inprogress”_Sql - Fatal编程技术网

Sql 如何从表中选择前100行,并将所有选定行的列值更新为“inprogress”

Sql 如何从表中选择前100行,并将所有选定行的列值更新为“inprogress”,sql,Sql,如何从表中选择前100行,并将所有选定行的列值更新为“进行中”。此外,我还需要在单个select查询中获取所有这些项 SELECT TOP 100 [column 1],[column 2],[column 3] FROM table name where column 3 = 'Null'; update top (100) table name set column 3= 'in progress' where column 3= ''; …我使用了这个select查

如何从表中选择前100行,并将所有选定行的列值更新为“进行中”。此外,我还需要在单个select查询中获取所有这些项

SELECT TOP 100 [column 1],[column 2],[column 3] 
FROM table name  
where column 3 = 'Null';

update top (100) table name 
     set column 3= 'in progress' 
where column 3= '';

…我使用了这个select查询。

我不确定您使用的是哪种sql,但您可以将这些项放入临时表中,并以这种方式进行更新

select top 100 * into #table1 from table2 where 1=1

UPDATE #table1 set x = x
临时表将保持有效,直到sql窗口关闭


谢谢

您使用可更新的cte:

with u_cte as (
     select col3, row_number() over (order by ?) as seq
     from table t
     where col3 is null
)
update u_cte 
       set col3 = 'in progress'
where seq <= 100;

??使用指定列顺序的列来代替排序列

用您正在使用的数据库标记您的问题。还有,你的问题不清楚。您正在查找更新查询还是选择查询?如果两者都有,那么问题就太广泛了……前100行——你需要提供一个标准来决定这意味着什么。请更新您的问题。从[temp].[dbo].[abc]中选择前100名[column1]、[column2]、[column3],其中column3='Null';更新前100名[temp].[dbo].[abc]设置column3='inprogress',其中column3=;