Data Types and Stored Procs

  • I am writing a SP to send out an email. I am using a cdonts mail SP I found on the internet. The maximum length of the body, so far has been varchar(8000). However, now that is starting to cut off the data at the end. Does anyone know of a bigger data type I can use to make sure all of the data gets sent in the email?

    Thanks,

    Michael

  • 8000 is the maximum of varchar data types as you obviously know.  A text field type does not have this limitation, but if your email stored procedure calls the xp_sendmail proc, the message parameter has an 8,000 character limitation. 

     

    Have you thought of creating some kind of reporting services solution instead?

     

    If the phone doesn't ring...It's me.

  • Not so fast there...

     

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_xp_aa-sz_6hbg.asp

     

    This example shows how to send a message longer than 7,990 characters. Because message is limited to the length of a varchar (less row overhead, as are all stored procedure parameters), this example writes the long message into a global temporary table consisting of a single text column. The contents of this temporary table are then sent in mail using the @query parameter.

    CREATE TABLE ##texttab (c1 text)INSERT ##texttab values ('Put your long message here.')DECLARE @cmd varchar(56)SET @cmd = 'SELECT c1 FROM ##texttab'EXEC master.dbo.xp_sendmail 'robertk',    @query = @cmd, @no_header= 'TRUE'DROP TABLE ##texttab

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply