Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 COUNT

Author  Topic 

DENIZ3E
Yak Posting Veteran

56 Posts

Posted - 2005-04-18 : 17:46:36
hi
how do I do?
how many "," in the sentences?


examples: "SEA,APPLE,TEA"

COUNT THE "," =3

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-04-18 : 17:52:32
Can you explain what you are looking for, because "SEA,APPLE,TEA" only has two commas.

quote:
Originally posted by DENIZ3E

hi
how do I do?
how many "," in the sentences?


examples: "SEA,APPLE,TEA"

COUNT THE "," =3



CODO ERGO SUM
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2005-04-18 : 20:40:14
select len(rtrim(MyColumn)) - len(replace(rtrim(MyColumn), ',', ''))
from MyTable

HTH

=================================================================
Every act of conscious learning requires the willingness to suffer an injury to one's self-esteem. That is why young children, before they are aware of their own self-importance, learn so easily; and why older persons, especially if vain or important, cannot learn at all. -Thomas Szasz, author, professor of psychiatry (1920- )
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-04-18 : 20:52:58
quote:
Originally posted by Michael Valentine Jones

Can you explain what you are looking for, because "SEA,APPLE,TEA" only has two commas.

quote:
Originally posted by DENIZ3E

hi
how do I do?
how many "," in the sentences?


examples: "SEA,APPLE,TEA"

COUNT THE "," =3



CODO ERGO SUM



Come on, Michael, that's why it's a difficult problem to solve! Anyone can write a routine that returns the ACTUAL number of commas in a string !

- Jeff
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-04-18 : 21:12:44
"There...are...4...lights..." or is that reference too vague?

Be One with the Optimizer
TG
Go to Top of Page

DENIZ3E
Yak Posting Veteran

56 Posts

Posted - 2005-04-19 : 01:51:03
very thanks.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-04-24 : 01:07:12
quote:
Originally posted by TG

"There...are...4...lights..." or is that reference too vague?

Be One with the Optimizer
TG

Star Trek, The Next Generation, lifted that torture from 1984. In 1984, Winston Smith was a lot less heroic than Picard.


NINETEEN EIGHTY-FOUR
by George Orwell
Chapter 20

...
" Just now I held up the fingers of my hand to you. You saw five fingers. Do you remember that ? "

" Yes. "

O'Brien held up the fingers of his left hand, with the thumb concealed.

" There are five fingers there. Do you see five fingers ? "

" Yes."

And he did see them, for a fleeting instant, before the scenery of his mind changed. He saw five fingers, and there was no deformity. Then everything was normal again, and the old fear, the hatred, and the bewilderment came crowding back again. But there had been a moment - he did not know how long, thirty seconds, perhaps - of luminous certainty, when each new suggestion of O'Brien's had filled up a patch of emptiness and become absolute truth, and when two and two could have been three as easily as five, if that were what was needed. It had faded but before O'Brien had dropped his hand; but though he could not recapture it, he could remember it, as one remembers a vivid experience at some period of one's life when one was in effect a different person.

" You see now ", said O'Brien, " that it is at any rate possible."

" Yes ", said Winston.
...


CODO ERGO SUM
Go to Top of Page
   

- Advertisement -