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
796 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
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Query - which index being used? 2 48
SQL Agent Timeout 5 48
Updating statistics with error notification email in SQL server 4 75
Replace Dates in query 14 21
by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 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

19 Experts available now in Live!

Get 1:1 Help Now