sql server - SQL - Return Output To Stored Procedure -
i have stored procedure have created can enter lines table , subsequently return inserted.id can return id sql command sent input id table.
i have used output instead.id before , works fine when insert statement how same result stored procedure.
i have done following can't seem output correctly.
create procedure sp_xstream_send -- add parameters stored procedure here @dept varchar(30), @process varchar, @requestdt datetime, @requesttype varchar, @requestbranch int, @requestpolref varchar, @requestxml varchar, @returnid int output begin -- set nocount on added prevent result sets -- interfering select statements. set nocount on; declare @outputtbl table (id int) insert dbo.xstream_log ( department , process , requestdt , requesttype , requestbranch , requestpolicyref , requestxml ) output inserted.id @outputtbl(id) values ( @dept, @process, @requestdt, @requesttype, @requestbranch, @requestpolref, @requestxml ) select @returnid = id @outputtbl return end go
when exec wants me send @returnid don't want input it, want output of inserted id.
any help, cheers.
update
i executing stored procedure so:
declare @id int; exec dbo.sp_xstream_send @dept = 'it', -- varchar(1) @process = 'xstream test', -- varchar(1) @requestdt = '2016-05-09 09:28:38', -- datetime @requesttype = 'create-broomsrisk', -- varchar(1) @requestbranch = 0, -- int @requestpolref = 'poms01pc01', -- varchar(1) @requestxml = '<testxml></testxml>', -- varchar(1) @returnid = @id output;
i getting 'command(s) completed successfully' , not actual id.
Comments
Post a Comment