如何调用更新程序?

时间:2015-07-31 10:14:22

标签: sql sql-server sql-server-2008 tsql stored-procedures

create procedure colupdate (
    @firstname varchar(200),
    @status varchar(200)
)
as 
begin 
    select Firstname,Lastname,status from tbl_Students
    where Firstname=@Firstname
    update tbl_Students
    set status= @status
    where @firstname=Firstname 
end 

我称之为:

execute colupdate 'Vikek','deactivate'

现在我得到"零行更新"。

我该如何更新?

1 个答案:

答案 0 :(得分:0)

愿这个人帮你解决

create procedure colupdate (
          @firstname varchar(200),
          @status varchar(200)
)
as 
begin 
    IF EXISTS(select Firstname,Lastname,status from tbl_Students where Firstname=@Firstname)
        update tbl_Students set status= @status where Firstname=@Firstname Else
Print ' data not exist'
    end