更新表行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) endhttp://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) endTry 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更多推荐
发布评论