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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Count the number of entries seperated by a comma

Author  Topic 

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-03-06 : 13:29:35
hello, how do i Count the number of entries seperated by a comma if i have certain number of records inserted into my database

e.g.

how do i count


hello,hello,hello, hello

1. I would like to know how many hello the user has posted after each comma

2. The lenght of each entry with the LEN function
thanks

nr
SQLTeam MVY

12543 Posts

Posted - 2005-03-06 : 14:53:23
select len(fld) - len(replace(fld,',','') + 1
fromtbl

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-03-06 : 14:54:11
1) easy:

Declare @str varchar(100)
Set @str = 'hello,hello,hello, hello'
Select len(@str) - len(replace(@str,',',''))


2) you will have to split up the string into each part. search here for split & csv... plenty of examples.

Corey

"If the only tool you have is a hammer, the whole world looks like a nail." - Mark Twain
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-03-06 : 14:59:00
What amazes me about this forum is not just the answers i get, ...

,... but the speed. do u guys live online ???

:-) Thanks a lot
Afrika
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2005-03-06 : 15:09:15
You mean I have a life?


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-03-06 : 15:15:06
Yes Sir
thank U

:-)
Go to Top of Page

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2005-03-06 : 15:16:05
Afrika,

One of your country men owes me $4.5 million dollars. :-)

DavidM

A front-end is something that tries to violate a back-end.
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-03-06 : 16:37:18
DavidM
how did this happen ?
Go to Top of Page

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2005-03-06 : 16:49:50
Afrika, I am just kidding of course..

There is a famous internet email scam from Nigeria...[url]http://tinyurl.com/qiu[/url]

DavidM

A front-end is something that tries to violate a back-end.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2005-03-06 : 17:08:21
This always amazes me
According to the FBI's 2001 Internet Fraud Report (PDF), about 2,600 people in the United States reported problems last year with the 419 scam, and of that number, 16 claimed financial losses totaling $345,000.
Taiwo said he knows the amount of successful scams is much higher, a contention that the FBI's documentation supports. According to FBI statistics, only one in every 10 successful fraud crimes are reported to authorities.

Didn't know the bit about what happens when the victim goes to Nigeria.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-03-07 : 14:32:02
BUILD STRENGTH IN A MAN/NATION....
...and you would NEVER NOTICE his weakness.

hi nr, who is Taiwo?

I dont understand, WHY LOOK TO THE NEGATIVE side of a country. If i were to point out the negative sides to every country, especially its history and past. It could breed bad blood.

I am of them that are positive, and will continue to be so irrespective. I recall reading my first book on ASP programming by WROX, and the author likened the internet to the days of old British highway robbers, dick turpin or so.

Also, i wonder how a country rich in diamonds is a war for years, and how the natives could purchase the latest and most suphisticated weaponry, and can use them well, when they do not manufacture them in africa. Guess who might be fuelling the war ??? :-(

I could go on an on, but no point. There is more to the light than darkness.

I luv this forum and thats all to it. Lets build the strength of a man, and you would never notice his weakness.

see my post here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=45775
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2005-03-07 : 19:59:01
>> hi nr, who is Taiwo?
Dunno - it's from the link that byrmol posted.
I have a bit of sympathy for people that get caught by these scams but can't help feeling that it's their own fault (greed?).
Also if the figures are to be believed it can't be limitted to Nigeria - others will have jumped on the bandwagon.

By the way - if anyone can help I have access to the sqlteam advertising revenue account, amounting to several millions of dollars, but cannot utilise these funds due to the US and UK tax laws. If anyone has a non-uk/US account and would be willing to move these funds myself and Graz would be willing to offer 20% commision for this service. These funds are desperately needed to finsnce a much needed operation for my dear old mother who would be very grateful and probably when recovered show her appreciation by sending some of her famous home made spotted dick (and a can of Birds custard powder).

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-03-07 : 20:22:59
Nigel, I don't have a clue what Birds custard poweder is and I'm horrified that the words grandmother and spotted dick would be used in the same sentence but you make them both sound so good. Forget the 20% commision, I'll do almost anything for that care package!

Be One with the Optimizer
TG
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-03-08 : 04:02:24
quote:
QUOTE FROM nr

I have a bit of sympathy for people that get caught by these scams but can't help feeling that it's their own fault (greed?).
Also if the figures are to be believed it can't be limitted to Nigeria - others will have jumped on the bandwagon


now we are talking...

90% of scam mails come from the USA and Russia, so statistics say, and 2ndly internet penetration in Africa, esp Nigeria is very low. So why is it called 419 when it comes to Nigeria and "PHISING" when it comes to the USA and other countries ?

I am a NIgerian, and not so because i chose 2b, but b'cos of the design of the "Mastermind of creation", So i would do my best towards humanity and life. Knowing that one day, all this woudl pass away.

nr, i do have a UK bank and could help with your project, If you would give me that 20% commision. I think i have a total of #20UK pounds sterling in my account, woudl this be of any help esp : for the custards

:-)

Afrika
Go to Top of Page
   

- Advertisement -