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
802 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 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