I have this script that sends an email:
USE msdb
EXEC sp_send_dbmail
@profile_name = 'Mail list',
@recipients = 'bob.jones@company.com',
@subject = 'query results',
@body = 'Result from SELECT appended below.',
@execute_query_database = 'DB',
@query = 'exec usp_DisplayData'
The issue is that many of the columns (or their alias) are incredibly long, so the query result in the email will look something like this:
SDMI POS Sales Name SDMI POS Purchases
------------------- ------------------
1 Joe 3
Without html, is there a way that that I can wrap the text in the columns so it will look something like this in the email?
SDMI POS Name SDMI POS
Sales Purchases
--------- ---- ---------
1 Joe 3
usp_DisplayData
is a simple query, looks something like this:
Create procedure usp_usp_DisplayData
as
select
cast(sales as varchar(16)) as 'SDMI POS Sales',
Name,
cast(purch as varchar(16)) as 'SDMI POS Purchases',
from Sales