Truncating HTML.

  • I've an odd problem truncating HTML.

    It's taken from as NTEXT which I'm then attempting to truncate by replacing the field in a Derived Column

    (DT_WSTR,32000)EmailBody

    Which keeps it as an NTEXT field. This generally works, but hasn't for a handful of cases, where the length of the field afterwards appears to be twice that of what I've suggested (ie 64000) - which is too big.

    Any ideas?

    Stephen.

  • Replacing a field doesn't actually do the conversion.

    You need to create a new column and add the expression (DT_WSTR,32000)EmailBody there.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Tried that!

    That's a problem in itself, as it'll then try to conform it to WSTR which is only 4000 characters long.

    Still thanks for the reply 🙂

    It does look as if it's truncating some records, but not others. Could this relate to how many lines of text it'd translate to?

    Stephen.

  • edit: never mind, you cannot specify a length for DT_NTEXT.

    What is the datatype of the destination?

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Can't stick a number in the DT_NEXT command unfortunately.

  • Rich Text format 32768chars.

    I'm trying the following based on your idea.

    1. Create a dummy ntext field earlier in the process

    2. Truncate the field into the dummy field

    3. Load from the dummy field.

    Stephen.

  • nope - didn't work - same error.

  • What should work:

    Read the column into a script component as a transformation. In the .NET script, cast the DT_NTEXT (which is a BLOB column) to a string. Apply the substring function to truncate the string. Recast it to a BLOB and output it.

    I have code at work that's similar to this. I'll see if I can track it down tomorrow.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 8 posts - 1 through 7 (of 7 total)

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