更新表行sql 3的列(update a column of a table row sql 3)

编程入门 行业动态 更新时间:2024-10-27 02:29:00
更新表行sql 3的列(update a column of a table row sql 3)

http://upload7.ir/images/38494239720146662835.png

在这张图片中,我想通过查询读取第一行并将HASDATA更改为1或true(对于第一行),但所有行中的所有hasdata都更改为true。

我使用了这段代码并且它可以工作,但是当这段代码在一段时间内运行时,查询仍然在同一行上运行。 当代码在while环中运行时,我想在下一行运行查询。

这是我的存储过程代码:

ALTER procedure [dbo].[selecfirstvalue] (@ParentId int,@CrawlerCheck bigint) as update TBLCrowler set ParentId=@ParentId , CrawlerCheck=@CrawlerCheck , HasData=1 where CatId=(Select min(CatId) from TBLCrowler) end

http://upload7.ir/images/38494239720146662835.png

In this picture I want to read the first line by a query and change the HASDATA to the 1 or true(for first line) but all the hasdata in all lines changes to true.

I used this code and it works, but when this code run in a while ring query still working on the same line. I want to run query in the next line when code is runing in a while ring.

Here is my stored procedure code:

ALTER procedure [dbo].[selecfirstvalue] (@ParentId int,@CrawlerCheck bigint) as update TBLCrowler set ParentId=@ParentId , CrawlerCheck=@CrawlerCheck , HasData=1 where CatId=(Select min(CatId) from TBLCrowler) end

最满意答案

尝试这个:

ALTER procedure [dbo].[selecfirstvalue] (@ParentId int,@CrawlerCheck bigint) as update TBLCrowler set ParentId=@ParentId , CrawlerCheck=@CrawlerCheck , HasData=1 where CatId=(Select min(CatId) from TBLCrowler where HasData=0) end

Try this:

ALTER procedure [dbo].[selecfirstvalue] (@ParentId int,@CrawlerCheck bigint) as update TBLCrowler set ParentId=@ParentId , CrawlerCheck=@CrawlerCheck , HasData=1 where CatId=(Select min(CatId) from TBLCrowler where HasData=0) end

更多推荐

本文发布于:2023-08-04 03:02:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1408786.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:update   sql   column   row   table

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!