Archived Forum Post

Index of archived forum posts

Question:

SQL Server local variable size limitation.

Sep 23 '13 at 10:12

I am using SQL Server 2012 Web edition, and I am trying to read a POP3 mailbox from T-SQL, but I seem to be limited to 8000 bytes for the body of the email. If the email is > 8000 bytes I get nothing. I think at this point I would be happy with even the first 8000 bytes!

I have tried using VARCHAR(MAX) for the Body var, but that does not seem to work either.

All of your sample code seems to leave out the “Body” property entirely.


Answer

Local variables in SQL are limited in the number of bytes they can contain. Use a temp table to get long string results:

    -- Fetch a longer property string into a temp table:
    DECLARE @tmp TABLE (emailBody ntext)
    INSERT INTO @tmp EXEC sp_OAGetProperty @email, 'Body'