Sunday, March 25, 2012

count characters

I have a table with varchar values
What's the easiest way to find out how many comma's I have in the value?
Thanks
-------
TABLE 1:
col1
test,one,two,three
a,b,c,d,e,f,g
a
-------Hi

NoOfCommas = Len(MyCol) - Len(Replace(MyCol, ',',''))

HTH|||looks great!
thankssql

No comments:

Post a Comment