Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8821189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:47:26+00:00 2026-06-14T05:47:26+00:00

I use the @query perimeter in sp_send_dbmail to send out an e-mail with a

  • 0

I use the @query perimeter in sp_send_dbmail to send out an e-mail with a list of warnings (the warnings are returned by the @query perimeter). The @query perimeter is listed as text in the e-mail. All of the records returned from the @query perimeter and displayed in the e-mail has a line break between them. ie. If I have 4 records, I would have 8 lines because of line breaks.

How do I turn the line breaks off? I read the the msdn article for sp_send_dbmail, but it didn’t mention any attributes that could be changed that would affect the line breaks.

Code:

    BEGIN
    EXEC MSDB.DBO.sp_send_dbmail 
        @PROFILE_NAME = 'Alerts',
        @RECIPIENTS = @MAIL,
        @SUBJECT = @NEWSUBJECT,
        @BODY = @NEWBODY,
        @QUERY =
            'SET NOCOUNT ON
            DECLARE @HEXSTRING AS VARCHAR(100)
            SET @HEXSTRING = (SELECT HEXADECIMAL_STRING FROM mydb.dbo.statusupdates
                WHERE MACHINE_ID = ''1111'' AND DATEDIFF(MI, TIME_DATE_RECEIVED, GETDATE()) <= 60)
            SELECT [Warning_Description] FROM mydb.DBO.BINARYTOTABLE(mydb.DBO.HEXTOBINARY(@HEXSTRING)) AS ABB1
            JOIN mydb.DBO.WarningMessages  ON mydb.DBO.WarningMessages.[Bit_Offset] = ABB1.BITPLACE
            WHERE BITVALUE = 1 AND ALERT_LEVEL = ''WARNING''',
        @QUERY_RESULT_HEADER = 0,
        @ATTACH_QUERY_RESULT_AS_FILE = 0;
    END
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:47:27+00:00Added an answer on June 14, 2026 at 5:47 am

    I ended up putting everything into the @BODY parameter of SP_SEND_DBMAIL. Query results from a SELECT statement could be concatenated with regular text into a string and you can use HTML to format the resulting text.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use query string to access my pages. I try to make if anyone
I see how you can use query functions to apply different weights to different
I use a query to delete about 9,000,000 rows but no rows deleted what
I want to use a query like: sql(select name where id > 10 and
Can a select query use different indexes if a change the value of a
Maybe it's wrong but I always use this query for my app: cme_only =
I made query that accepts two parameters. Now I want to use that query
I face the following exception when i try to use parametrized query with informix
I am trying to create Linq Expression that I can use to query child
I have a boost::unordered_multimap< std::vector<int>, float> . The keys that I use to query

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.