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
792 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 5

Accepted Solution

by:
robertg34 earned 500 total points
Comment Utility
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
Comment Utility
>>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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
>>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
Comment Utility
I reread that and I do believe it will work with attachments as well.  
0
 
LVL 2

Author Comment

by:Eric3141
Comment Utility
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
Comment Utility
Robert,

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

Eric
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now