-> 我想编写一个存储过程,它从 2 个选择语句中输出列
-> 一个 select 语句的列将是第二个 select 语句的输入
create procedure sp_proc
@inputId int
As
Begin
Select t1.ticketId AS ticket,
t2.name AS NAME,
t3.status AS STATUS,
t2.id ID
from table1 t1
Inner JOIN table2 t2 ON t1.ticketId= t2.ticketId
INNER JOIN table3 t3 on t3.name = t2.name
WHERE t1.ticketId IS NOT NULL
AND t2.id = @inputId
Select t1.ticketId, t2.name , D.desc, t2.id
from table1 t1
Inner JOIN table2 t2 ON t1.ticketId= t2.ticketId
INNER JOIN( SELECt TOP 1 from table4 t4 ORDER BY t4.date where t4.ticketId = ticket)AS D
ON t4.ticketId = t2.ticketId
WHERE t4.ticketId =ticket
我想要ticket, NAME,STATUS, ID , desc
用户何时提供@inputId
proc