Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

how to put the result of a query in the subject line of the email using sp_send_dbmail in SQL 2005?

something like

you have "465" rows in this table

1 Answer

Relevance
  • 1 decade ago

    If you are merely plugging in the result of a count query, this would be relatively simple - just define a string variable and make its value the result of stringing the returned count with whatever constant text you want:

    someString = "You have " + sqlResult + " rows in this table."

    where sqlResult is the defined variable for capturing the result from your query. Then just use someString as one of the parms in sp_send_dbmail as usual.

Still have questions? Get your answers by asking now.