2021年1月20日星期三

How to store results of select that returns multiple values in T-SQL?

I wrote a stored procedure in T-SQL that collects data and sends email. I'm facing a problem sending multiple results. Below you can see part of the stored procedure:

select o.Product   from vw_order o   where o.order_id = '7002'  

Output:

tea  coffee  water  

When I try to send this result to the email stored procedure, I can only send the last value

declare @content nvarchar(max)  declare @tid int    select @tid = '7002'    select @content = o.Product    from vw_order o   where @tid = o.order_id    exec sp_food_mailer @content  

Output:

water  

How can I send these all results to the email stored procedure? Do you have any idea ?

https://stackoverflow.com/questions/65775854/how-to-store-results-of-select-that-returns-multiple-values-in-t-sql January 18, 2021 at 09:55PM

没有评论:

发表评论