Home Forums SQL Server 2005 T-SQL (SS2K5) ANYTHING THAT CAN HELP TRIM THE DATA FOR A GIVEN STRING... RE: ANYTHING THAT CAN HELP TRIM THE DATA FOR A GIVEN STRING...

  • This kind of thing can get ugly in a hurry. Stop and think about appearance of the text in a situation with multiple sentences, and you start to see where I'm going. If you decide that just one space after a sentence isn't sufficient white space, you have a very difficult problem to solve, and to be honest, just one space after a sentence and before another one is really trying on the eyes when one is trying to read.

    The reason it becomes difficult is because you then have to differentiate between a period used as the end of a sentence vs. a period used as I just did with the abbreviation of the word "versus". Same problem is even more trouble when you think about the inclusion of names like St. John, or anything containing an address, like "12345 Shoemaker Rd.". And then there are decimal numbers to contend with. Honestly, you need a VERY specific definition of EXACTLY what you expect in the output, because it doesn't take much for this kind of thing to become either a serious performance problem or a nearly completely impractical idea.

    On the positive side of things, one CAN examine the data and find the longest continuous string of spaces in existing data, and then determine the smallest power of 2 just greater than that number, and then use the power number as the number of REPLACEs that you do with one space replacing two.

    Steve

    (aka smunson)

    :-):-):-)

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)