i trying store query result , store in @parameter, use in insert query. new sp , dont know if doing right or if possible.
create proc [dbo].[sptrans] @queue int, @parameter int = (select top 1 ticketnumber + 1 tbldata queueid = @queue) begin insert tbldata (queueid,parameter) values (@queue,@parameter) end
why not move sub query procedure this:
create proc [dbo].[sptrans] @queue int begin declare @parameter int select top 1 @parameter = ticketnumber + 1 tbldata queueid = @queue; insert tbldata (queueid,parameter) values (@queue,@parameter); end
if need optionally pass @parameter in this:
create proc [dbo].[sptrans] @queue int , @parameter int begin if @parameter = 0 select top 1 @parameter = ticketnumber + 1 tbldata queueid = @queue; insert tbldata (queueid,parameter) values (@queue,@parameter); end
Comments
Post a Comment