Thursday, April 16, 2020

T-SQL Script to manipulate string

DECLARE @aux varchar(1000) = '#234xp*to_3Kumar...?'
SELECT REPLACE(REPLACE(SUBSTRING(@aux, PATINDEX('%[A-Z]%', @aux), LEN(@aux)),'...','.'),'..','.')
SELECT SUBSTRING(@aux, PATINDEX('%[A-Z,%,*,~,!,@,$,%,^,&,*,(,),?,/,>,<,-,_]%', @aux), LEN(@aux))
REPLACE(REPLACE(SUBSTRING(@str, PATINDEX('%[A-Z]%', @str), LEN(@str)),'...','.'),'..','.')

No comments: