use this function CREATE FUNCTION [dbo].[ufn_CountChar] ( @pInput VARCHAR(1000), @pSearchChar CHAR(1) )
RETURNS INT
BEGIN
DECLARE @vInputLength INT
DECLARE @vIndex INT
DECLARE @vCount INT
SET @vCount = 0
SET @vIndex = 1
SET @vInputLength = LEN(@pInput)
WHILE @vIndex <= @vInputLength
BEGIN
IF SUBSTRING(@pInput, @vIndex, 1) = @pSearchChar
SET @vCount = @vCount + 1
SET @vIndex = @vIndex + 1
END
RETURN @vCount
END
GO
SELECT TOP 1 *
from urTable
ORDER BY [dbo].[ufn_CountChar] (urColumn, '-' ) desc
Main Topics
Browse All Topics





by: chapmandewPosted on 2009-11-05 at 06:54:53ID: 25750063
pass your string to this function with a '-' as the delimiter
com.com/da tacenter/? p=375
http://blogs.techrepublic.