SQL Server Find the number specified in the string of characters appearing

 

To find the location of a specified character appears in a string, the method is relatively simple, use len () function and replace () function can be combined.

SELECT TOP 200 approveInfo approveInfo2, LEN(approveInfo)-LEN(REPLACE(approveInfo,';','')) AS appLen, * FROM dbo.Log_Year
WHERE ISNULL(approveInfo,'')<>'' ORDER BY appLen DESC

 

Principle: minus the length of the string; string length replace 'the =; the number of occurrences of 

Sql symbol lookup present embodiment; the number of occurrences, as shown below:

 

 

Guess you like

Origin www.cnblogs.com/furenjian/p/12084728.html