Counting number of text lines in a character string

Analytics

Counting number of text lines in a character string

Hi, I have got a character string with muliple lines (user presses carriage return). I need to count the number of lines (number of times carraige return) is entered. Does anyone know how to do it.
2 REPLIES
rgs
Enthusiast

Re: Counting number of text lines in a character string

You should be able to use a recursive query to do the job. Look at this post:

http://www.teradata.com/teradataforum/Topic11452-9-1.aspx

In that example the separator was a ‘,’. You can change that to your line separator character.

If you just want the count then just change the last line of the query from:

select subpart from temp_table;

to

select count(subpart) from temp_table;

good luck.
Enthusiast

Re: Counting number of text lines in a character string

The link provided seems no more active..I would be glad if you can provide us the new link or post the example here..

Thanks,
Ayush