December 7, 2010 at 12:14 pm
I'm using sp_send_dbmail to send the results of a query to my my users. No problems with that, but a little bit of a formatting issue. Not to be nitpicky, but the query result has 3 columns and the first column is WAY wider than the following two. Example below:
COLUMN1 COLUMN2 COLUMN3
The query result is in simple text format. Also, the query results for COLUMN1 are small - there is absolutely no need for COLUMN1 to be that large. Any body know how to shrink down the width of COLUMN1 so it's the same as the other 2 columns? Thanks in advance!
December 7, 2010 at 2:39 pm
In your query, CAST the first field as a certain length and that should reduce the width it allocates in the email.
December 7, 2010 at 2:50 pm
If you want to control the width of the data, then in the SELECT query that that sp_send_dbmail calls, cast the columns you are fetching to the desired width, (possibly renaming the column name if you are showing headers and want that name also to be a narrower width.) For example:
SELECT CAST(Column1 as CHAR(4)) as Col1, Column2, Column3 FROM x
December 7, 2010 at 4:00 pm
Thanks Andy!
December 7, 2010 at 4:01 pm
Thanks Greg! Works great.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply