sql server - stored proc from multiple select statements in Tsql -


-> want write stored proc outputs columns 2 select statements

->the columns 1 select statement inputs second select statement

create procedure sp_proc @inputid int  begin   select t1.ticketid ticket,  t2.name name, t3.status status,  t2.id id table1 t1 inner join table2 t2 on  t1.ticketid= t2.ticketid inner join table3 t3 on t3.name = t2.name t1.ticketid not null , t2.id = @inputid    select t1.ticketid, t2.name , d.desc, t2.id table1 t1 inner join table2 t2 on  t1.ticketid= t2.ticketid inner join( select top 1 table4 t4 order t4.date  t4.ticketid = ticket)as d on t4.ticketid = t2.ticketid t4.ticketid =ticket 

i want ticket, name,status, id , desc when user supplies @inputid proc

an inline scalar query work

create procedure sp_proc @inputid int   select t1.ticketid ticket,  t2.name name, t3.status status,  t2.id id, [desc] = (select top(1) [desc]           table4 t4           t4.ticketid = t1.ticketid           order t4.date) table1 t1 inner join table2 t2 on  t1.ticketid= t2.ticketid inner join table3 t3 on t3.name = t2.name t1.ticketid not null , t2.id = @inputid; go 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -