I have the following in a sp:
select @query_email= 'select column_1, column_2 from my_table where column_1='@parameter''
EXEC master.dbo.xp_sendmail @recipients = @email,
@query = @query_email
The @parameter is defined earlier (correctly and also the @email too).
How can I run the query in xp_sendmail and also pass a parameter from the sp into the query?