My Blog List

hotinit.com. Powered by Blogger.

Search This Blog

Funtion to get Alphabet Parts of the Alphanumeric String

Friday, 19 August 2011

Alter function GetLetters(@string NVARCHAR(50))

RETURNS VARCHAR(20)

AS

BEGIN

DECLARE
@IncorrectCharLoc SMALLINT

SET @IncorrectCharLoc = PATINDEX('%[^A-Za-z]%', @string)

WHILE @IncorrectCharLoc > 0

BEGIN

SET
@string = STUFF(@string, @IncorrectCharLoc, 1, '')

SET @IncorrectCharLoc = PATINDEX('%[^A-Za-z]%', @string)

END

SET
@string = @string

RETURN @string



end

selectdbo.GetLetters('ABC_I+{D[4|:e;5,<.F>/?6')


output
ABCIDeF

No comments:

Post a Comment

 

Blogger news

Blogroll

Most Reading

8.6/10