Remove invalid data from the column

  • I have the following data in one of the department field in a table:

    {\rtf1\ansi\...\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}} \viewkind4\fs17 Electronics Department\par \par }

    How do I get just the "Electronics Department" value from the above column, please advice.

    Thanks!!

  • What *exactly* are you trying to pull out of this string? Do all records have the same format?

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • No it's not the same values, one has the follow:

    {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\fswiss\fprq2\fcharset128 Arial Unicode MS;}{\f2\fnil\fcharset0 Microsoft Sans Serif;}} {\colortbl ;\red0\green0\blue255;} \viewkind4\uc1\pard\sb100\sa100\cf1\b\f0\fs20 Mechanical \b0\f1\par \f0\fs18\line Department \par \par NEW Department \pard\cf0\f2\fs17\par }

    FRom above I need Mechanical Depratment NEW department.

    Actually the data type is text for this column, I am not sure how this invalid data is present in this column, now I am trying to extract only valid data. Thanks!

  • Looking at your two examples I see no pattern at all. In order to have SQL do this for you there has to be something VERY regular you can point the code to look for. If you can find a pattern, code to look for that. Maybe the length of the words without the characters is a start. Good luck!

  • Mh, I agree with evaleah, in that I don't really see any pattern, but maybe there is one there. In any event, there was a guy a couple weeks ago wanting to replace a value in an XML string. I never heard back from him, but you could try messing around with my solution for him. Of course, I realized, after I spent an hour doing that, he could just have tried REPLACE, but it was more for the fun of it.

    http://www.sqlservercentral.com/Forums/Topic539366-169-1.aspx

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

Viewing 5 posts - 1 through 4 (of 4 total)

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