[英]update a column of a table row sql
http://upload7.ir/images/38494239720146662835.png
在这张图片中,我想通过查询读取第一行并将HASDATA更改为1或true(对于第一行),但是所有行中的所有hasdata都更改为true。
这是我的存储过程代码:
ALTER procedure [dbo].[selecfirstvalue] (@ParentId int,@CrawlerCheck bigint)
as
select CatId, Title, ParentId, Url, CrawlerCheck from TBLCrowler
update TBLCrowler set ParentId=@ParentId , CrawlerCheck=@CrawlerCheck , HasData=1 where CatId=CatId
end
这是我的C#代码:
IDataReader get = ClassBase.EReader("selecfirstvalue", System.Data.CommandType.StoredProcedure, new SqlParameter[]
{
new SqlParameter("@ParentId",ParentId),
new SqlParameter("@CrawlerCheck",CrawlerCheck)
});
为什么是第一行呢? 您如何确定第一行? 如果基于最小CatId val,请在
update TBLCrowler set ParentId=@ParentId , CrawlerCheck=@CrawlerCheck , HasData=1
where CatId=(Select min(CatId) from TBLCrowler)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.