假定有一个表A中有一字段 flag
如何写一个存储过程,读取表中的某一条记录时,同时更新 flag中的值??
如何写一个存储过程,读取表中的某一条记录时,同时更新 flag中的值??
解决方案 »
- 又来发帖了,熟悉发送smtp邮件
- 怎么样把文本框里面的值添加到ListBox里面
- asp.net分页控件
- 请问Page.LoadControl("abc.ascx"); 这个Page.LoadControl具体在做什么动作?我知道是加载控件,不过这个加载具体是怎么个过程?
- dropdownlist 刷新后,每次选择后,总是选第一项。
- 邮件发送失败 SmtpMail.Send(myMail) 出错
- dellhost 里CPU 100% 怎么解决啊,各位帮帮忙啊,very急!
- update 问题
- 为何vs2008内置的webserver可以实现 IIS下却不可以?
- 通过using Excel导出Excel文件,服务器产生很多Excel进程
- dropdownList选值为空???
- 【求助-标题长,详情见源码】如何AjaxControlToolkit中的TabContainer遍历页面中的控件,得到CHECKBOX控件
@XTBH int,@flag varchar(10)
as
update A set flag=@flag where XTBH=@XTBH
select * from A where XTBH=@XTBH
这样做吧
CREATE proc sp_Update
@XTBH int,@flag varchar(10)
as
update A set flag=@flag where XTBH=@XTBH
select * from A where XTBH=@XTBH
go
exec sp_Update
@XTBH int,@flag varchar(10)
as
update A set flag=@flag where XTBH=@XTBH
select * from A where XTBH=@XTBH
[/Quote]
存储过程绝对可以实现的create proc find
@id int,--假设这里是查询的条件,当然最好是主键
@content varchar(50) --要更新的结果
as
select * from table_name where 主键=@id
update table_name set flag=@content where 主键=@id
我想楼主应该是想先查询,然后更新吧。
create procedure search
@id int,
@falgvalue int
as
select * from tb1 where id=@id
update tb1 set flag=@falgvalue where id=@idgoexec search 1,2godrop procedure searchgo
不用传递参数的更改.比如:select top 1 from A
然后把这条记录中的flag字段更新,不知道这条记录的ID
select * from tb1 where ....
update tb1 set flag=@falgvalue where ...
普通的条件查询直接将update与select 的where条件统一一下就可以了
如果像你说的top这样的你可以这样update tb1 set flag=XXX whre tb1.id in (select top 1 id from tb1)
这样进行更新