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)
 select help

Author  Topic 

DENIZ3E
Yak Posting Veteran

56 Posts

Posted - 2006-01-30 : 10:14:25
hý,

ID code
--- -----
1 '01.01.'
2 '01.'
3 '01.04.05..'


returns
-------
ID COUNT(.)=how many "." in the colomn
--- --------
1 2
2 1
3 4

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-01-30 : 10:28:53
Using String Functions as Charindex / substring u can write ur own function to give the No of specific characters in a string.

or use the Point 16 of the following link
http://weblogs.sqlteam.com/mladenp/archive/2005/08/01/7421.aspx

to write ur function

Then call that Function as

Select ID, MyFunc(code) from MyTbl
Go to Top of Page

VIG
Yak Posting Veteran

86 Posts

Posted - 2006-01-30 : 17:17:28
select id,len(s)-len(replace(s,'.',''))
from
(select 1 id , '01.01.' s union
select 2 ,'01.' union
select 3 ,'01.04.05..'
) a
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-31 : 01:28:14
VIG's is the effecient way to go

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -