Solved

DB Mail -- query pulls data from column of TEXT datatype but does not get all of the data

Posted on 2011-02-13
7
801 Views
Last Modified: 2012-05-11
I have a table that has a column (named 'synopsis') that is of datatype TEXT.

When I run the code below it does generate an e-mail and it does have an attachment.  The attachment drops a lot of the data that is in the synopsis column.

Instead of "Select synopsis..." I have also tried "Select convert(varchar(max), synopsis)...
and gotten the same results.

Lastly, I created a temp table with a column of varchar(max) and put the data into that table and selected from it instead -- and got the same results.

Ideas?


      
EXEC msdb.dbo.sp_send_dbmail 
	@profile_name = 'KSP DB Mail',
    @recipients   = 'eric.myers@ky.gov',
    @importance   = 'High',
    @subject      = 'Post 1 Caselog db - Nibrs Nightly Data Errors ',
    @body         = 'We had a problem',
	@query        = 'Select synopsis from db_server.my_db.dbo.my_table',
    @attach_query_result_as_file = 1

Open in new window

0
Comment
Question by:Eric3141
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 5

Accepted Solution

by:
robertg34 earned 500 total points
ID: 34885225
By default the dbmail file attachment is limited to 1mb in size:
http://msdn.microsoft.com/en-us/library/ms190307.aspx

You can try the query_no_truncate option to return the results in the body of the message.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 34885274
>>You can try the query_no_truncate option to return the results in the body of the message.<<
Good one.

0
 
LVL 2

Author Comment

by:Eric3141
ID: 34908520
Robert,

Home sick today so can't try this -- will tomorrow at work.  

If I use the option you specify can it work with an e-mail attachment from the query?  When I try that the results seem to be truncated at only a few hundred characters when there are a few thousand in the value in the cell.

0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 34909553
>>When I try that the results seem to be truncated at only a few hundred characters when there are a few thousand in the value in the cell.<<
You really need to read the article from the link posted, otherwise you would know that it is in fact 256 characters.

0
 
LVL 5

Expert Comment

by:robertg34
ID: 34910516
I reread that and I do believe it will work with attachments as well.  
0
 
LVL 2

Author Comment

by:Eric3141
ID: 34955277
ACPerkins said:
">>When I try that the results seem to be truncated at only a few hundred characters when there are a few thousand in the value in the cell.<<
You really need to read the article from the link posted, otherwise you would know that it is in fact 256 characters.
"

I was referring to whether or not it would work with the results as an attachment.  Robert had indicated using the results in the message body and the article posted did not specify.  Given that Robert seems to have experience trying this (and since I would be away from my work PC for a while) I asked if he knew.
0
 
LVL 2

Author Comment

by:Eric3141
ID: 34955411
Robert,

It worked great!  Thank-you so much.  This helps me solve a long standing problem here at worik.

Eric
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question