body longer than 8000 in sql sp_send_dbmail?

Posted on 2014-03-03
Medium Priority
Last Modified: 2014-03-03
Is there a way to send a may using sql if the body is html format long more than 8000 chars?
I have a store procedure that creates automatically the text and sends to operator.
Quite often the text is longer than 8000chars

Than you
Question by:Progold S.p.A.
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
  • 4
  • 2
  • 2
  • +1
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39899912
if you declare the variable as varchar(max), it shall work correctly.
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39899928
Are you using classic asp?  Which version of sql server?

Author Comment

by:Progold S.p.A.
ID: 39899944
It doesn't work with varchar(max)
I tried and the email has been sent truncated with 8153 chars
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


Author Comment

by:Progold S.p.A.
ID: 39899959
sql server 2008 R2
I'm not using asp but a sql job with a store procedure
LVL 52

Accepted Solution

Carl Tawn earned 2000 total points
ID: 39900034
The @body parameter for sp_senddb_mail is NVARCHAR(MAX), so there shouldn't be a limitation in the mail sending part itself - which would suggest the problem lies elsewhere.

Can you post the code you are using to generate the body of your message, and send it?
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39900041
I agree, it has to work, unless somewhere in the "middle" you use varchar/nvarchar without the MAX specification ...

Author Comment

by:Progold S.p.A.
ID: 39900054
thank you. it's working now
LVL 52

Expert Comment

by:Carl Tawn
ID: 39900057
Can you expand on what your problem was in the end?

If it was related to a variable somewhere then I think a point split may have been more appropriate option for closing the question.

Author Comment

by:Progold S.p.A.
ID: 39900070
I had a intermediate store procedure which launched sp_send_dbmail.
I deleted it and use directly sp_send_dbmail with the correct nvarchar(max)
Thank you

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

770 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