I don't know what I am doing wrong here. In books online I shows you a limmited example of how to use a variable but nothing that uses them in a query. My query is below.
alter procedure usp_email
declare @username nvarchar(50)
select @Username = db..users."name" from db..users
where db..users."name" = 'value'
if (@username = 'value')begin
EXEC master.dbo.xp_sendmail 'email@example.com',
@Query = @username, 'select db..users."name" from db..users where db..users."name" = @username;'
The error I get is:
Server: Msg 119, Level 15, State 1, Procedure usp_email, Line 9
Must pass parameter number 3 and subsequent parameters as '@name = value'. After the form '@name = value' has been used, all subsequent parameters must be passed in the form '@name = value'.
can anyone give me any hints to what I am doing wrong? Or if I can even do this in this way.