How to create a select, and then an update stored procedure in SQL Server 2012 -
i'm trying create stored procedure runs select query , pulls id (variable) , update query id. appreciated.
this have:
create procedure dbo.lead_usp_getlead @leadid int output select top 1 leadid, leadinitials, leadfirstname, leadsurname, leadhometelephonenumber, leadworktelephonenumber, leadcellularnumber, leademailaddress, islocked, uploadeddate dbo.lead islocked = 'false' order uploadeddate; update dbo.lead set islocked = 'true' leadid = @leadid declare @leadid int exec dbo.lead_usp_getlead @leadid;
you can combine them. no need 2 queries:
with toupdate ( select top 1 l.* dbo.lead l l.islocked = 'false' order l.uploadeddate ) update toupdate set islocked = 'true';
Comments
Post a Comment