SQL Server Performance

what placeholder to use around @myVar?

Discussion in 'General Developer Questions' started by kingofSQL, Oct 1, 2005.

  1. kingofSQL New Member

    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?


    @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
  2. kingofSQL New Member

    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
  3. Madhivanan Moderator

    No other way without conversion


    Failing to plan is Planning to fail

Share This Page