cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best practise for limiting text results?

MCMartin
Participant
3,071

What is the best practise for limiting text results to a certain number of chars?

e.g. Select left(name,20) from table

Accepted Solutions (0)

Answers (1)

Answers (1)

glenn_barber
Participant

The above works but is fairly primitive as it chops words. The more elegant way to do that is to search backwards from the end of the desired truncation length and look for white space or punctuation and replace it with ellipsis (...) For larger text fields we sometimes supply the character count in parenthesis with the ellipsis.

VolkerBarth
Contributor
0 Kudos

Ah, "more elegant" will combine nicely with "regex" to search for whitespace, punctuation and the like...

I guess that will have a BreckRant® started:)


@Glenn: Don't get me wrong, I agree on your user-friendly approach - I just thought about how to solve that within SA, and read Breck's comments...

glenn_barber
Participant

I think we have some SA code we use for this - I'll try to post it later. THis is a very common requirement in reports when there can be a lot of text.

thomas_duemesnil
Participant

Would be great if you can come up with something

Breck_Carter
Participant
0 Kudos

Here's what happens when *I* promise something in advance of delivering...

  • Promise code sample that I "know" I have.

  • Search fruitlessly for code sample that is lost, or perhaps once thought of but never actually written (I'm old, forgetful, etc).

  • Write code sample from scratch, test, etcetera, finally deliver it.

  • Rush to catch up with the work I was supposed to be doing.

Which is why I stopped promising stuff 🙂

alt text

VolkerBarth
Contributor
0 Kudos

Well, "I'll try to post it later" is not a real promise, I'd say - unless for folks with a very strong sense of duty...:)

Breck_Carter
Participant

I was not criticising, I was sharing advice... it's the reason I no longer say "this is the first article in a series" unless the whole series has been written... it's a jinx thing 🙂