sql server - display multiple output parameters in T-SQL stored procedure -


i want display 2 tables of 1 column each output in stored procedure

defined

create procedure p1         @name     varchar(20) output,         @company  varchar(20) output  begin       select @name = t1.name table1 t1;        select @company = t2.company table2;   end 

executed

declare @name varchar(20), @company varchar(20)  exec dbo.p1 @name = @name, @company = @company  select @name 'name', @company 'company' 

however, displays single row . doing wrong?

if want display values 1 column, 2 rows - use union:

select @name 'name' union select @company 

note both values display under same column name 'name'

if want display strings 'name' , 'company' have assure order of rows column:

select 'name' info, 0 sort union select @name, 1 union select 'company', 2 union select @company, 3 order sort 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -