I need to pass a variable to the query parameter of xp_sendmail. What place holders do I use to put a variable inside of this text string? EXEC master.dbo.xp_sendmail @recipients = 'email@emailaddress.com', @Subject = 'The Subject', @Message = 'The Message', @query = 'exec sp_MyProc '+ @myVar+' ', -- this is passing @myVar as a literal @no_header= 'false', @width = 160, @attach_results = 'false' as always thank you all for your help!! it's all good
I figured it out. DECLARE @MYVar numeric(9) SET @MYVar = 10 SELECT 'the number '+cast(@MYVar as varchar(10))+' is my variable' Anyone have another way let me know. it's all good