The first way that comes to mind is to do it indirectly by replacing the comma with an empty string and comparing the lengths
Declare @string varchar(1000)
Set @string = 'a,b,c,d'
select len(@string) - len(replace(@string, ',', ''))
More Related Contents:
- Update a table using JOIN in SQL Server?
- Comma separated results in SQL
- T-SQL stored procedure that accepts multiple Id values
- Understanding PIVOT function in T-SQL
- Calculate running total / running balance
- How do I escape a percentage sign in T-SQL?
- Using RegEx in SQL Server
- List of all index & index columns in SQL Server DB
- Why use a READ UNCOMMITTED isolation level?
- How much size “Null” value takes in SQL Server
- SQL Server: Isolation level leaks across pooled connections
- Create a view with ORDER BY clause
- INSERT INTO vs SELECT INTO
- How do I use the CONCAT function in SQL Server 2008 R2?
- Possible to store value of one select column and use it for the next one?
- How can sanitation that escapes single quotes be defeated by SQL injection in SQL Server?
- How do I exclude Weekend days in a SQL Server query?
- EXEC sp_executesql with multiple parameters
- Preserving ORDER BY in SELECT INTO
- Select / Insert version of an Upsert: is there a design pattern for high concurrency?
- Can you call a webservice from TSQL code?
- How to add custom attributes to SQL connection string?
- Multiple Column Pivot in T-SQL
- Joining multiple tables returns NULL value
- Which join syntax is better?
- Compute MD5 hash of a UTF8 string
- LPAD in SQL Server 2008
- How to check SQL Server Database compatibility after sp_dbcmptlevel is deprecated?
- How do I remove non-breaking spaces from a column in SQL server?
- What are row, page and table locks? And when they are acquired?