Forum Moderators: open

Message Too Old, No Replies

How do I display the first 30 characters from a database memo field?

         

stredovek

8:23 pm on Mar 30, 2003 (gmt 0)



I can display all data in memo field in browser. But I want display just part of information.How?

txbakers

10:22 pm on Mar 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi and welcome to the Webmaster World forums!

For something like this I would create a new variable and assign the db value to that.

Then, you have a bunch of choices.

You could run a simple loop building the new variable up to 30 characters.

You could also do a Substring command to extract the first 30 characters.

It's not difficult.

jimmykav

8:32 am on Mar 31, 2003 (gmt 0)

10+ Year Member



use the Left() function for the left most chars in a string or the Mid() to get a sub section of the string or the Right() function for the rightmost xx chars.

duckhunter

5:16 am on Apr 4, 2003 (gmt 0)

10+ Year Member



Since it's a memo/text field you may have to convert it to a VarChar before performing left/mid/right.

Select convert(varchar(3),myfield) from ....

macrost

8:00 pm on Apr 4, 2003 (gmt 0)

10+ Year Member



I have had no problems with this:
Left(index(3)), however, I do replaces special char's with their respective hex equivalents.
Mac
<added>Also, using the Left or Right does count spaces too, so if you want the first 30 chars, you will have to account for that too.</added>