Manipulating Text Variables

  • Vasant Raj

    SSCommitted

    Points: 1835

    Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/rVasant/manipulatingtextvariables.asp

  • Sean McDaniel

    SSC Rookie

    Points: 26

    Awesome article! However you mention nothing about speed. Is this method faster than doing an update to a single row? Can you elaborate more on the pros and cons of using this method? Almost sounds too good to be true.

    Thanks!

  • Martin Vrieze

    SSCrazy

    Points: 2760

    I am using text variable manipulation to construct customized plain text and HTML email messages for hundreds of thousands of customers...no two email messages are the same...each email message has a completely different product mix.

    Through the use of a forward-read-only cursors, the entire mail-merge process of 35kilobyte-50kilobyte sized email messages can be completed in well under 3 hours.

    Text data manipulation on a SQL Server platform is very, very fast and requires no additional software to be used.  I've built other solutions but none have come close to matching the mail-merging speed of performing text data manipulation on the SQL Server box itself.

    Text data manipulation is a skill very much worth learning.

     

  • David Catherman

    SSC Veteran

    Points: 281

    Good article but it does not discuss the real problem with Text fields.  I have a problem passing XML data from a Text field in a table to the sp_XML_preparedocument function.  There is no way I can find to take the data out of the field and pass it to the function.

    The only solution I have found is as the following link:

    http://www.awprofessional.com/articles/article.asp?p=102307&seqNum=16&rl=1

    where Ken Henderson provides a sample chapter of his book.  His method is to dynamically break the long text into 4k chunks and then append them all together when calling the xml function.  This is a good idea and has merit as a work around, but I have not gotten it to work yet.

    If anyone else has any ideas, please let me know.

    DCatherman at cmisolutions dot com

  • jrh_1999

    Grasshopper

    Points: 17

    What is the best way to pass text information to a stored procedure?  I don't think you can use the "text" type as a sp parameter.  Right now I am using a varchar(5000) but that limits the size of the file I can save.

    Joel

  • David Catherman

    SSC Veteran

    Points: 281

    Joel,

     

    you can use Text as a parameter type (as noted in the article), but you are limited on how you process the information in the SP.

    Dave

  • Yelena Varshal

    SSC-Dedicated

    Points: 34207

    This article is great!

    Text columns is not as rare as you think. I did not work yet with a piece of SW without Text data. ALL CRMs, Tracking Systems, everything that have notes or history to enter have Text data field, everything that have Description have Text data field, now we mentioned XML storage, you name it...

    I really appreciate any guidance on working with Text data.

    Regards,Yelena Varsha

  • John R. Hanson

    SSC-Addicted

    Points: 438

    It is very nice to have a concise overview of text functions and handling. Well done!

    There is a serious concideration with regards to triggers, however, since Text columns cannot be included.

    an error "Cannot use text, ntext, or image columns in the 'inserted' and 'deleted' tables." will occur.

    If anybody has ideas for Archival functions using Triggers, let me know.

     

    Cheers,

    John R. Hanson

  • SQLior

    SSC-Addicted

    Points: 447

    Be aware that in future versions of SS, the TEXT data type will be REMOVED! see BOL topic "Using text and image Data" http://msdn2.microsoft.com/en-us/library/ms189574(SQL.90).aspx

    Microsoft has introduced a new data type option called (MAX) to the varchar and binary types. It is an enhanced version of the text types and can do a lot more. If you upgraded to SS2005 then it is very recommended that you start using this option if you use large data. To find out more see the SS BOL topic "Using Large-Value Data Types" http://msdn2.microsoft.com/en-us/library/ms178158.aspx

    As an example, consider the previous user's comment re triggers. Now, it is possible to use large data inside triggers using this new data type. There is a lot more info in BOL (search for varchar(max) ).

Viewing 9 posts - 1 through 9 (of 9 total)

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