Helpful Information
Home
Categories
Contact us
Category: MS SQL Development
remove duplicate charatectes in a string
Hi
I would like to know how I can remove the duplicate characters in a string
eg abcdedgh@@@@@@@test.com
using a sql select
I want the results = abcdedgh@test.com
( ie removing the extra @ )
Thanks
Tissa
Something like this perhaps?
DECLARE @string CHARACTER VARYING(255)
SELECT @string = 'abcdedgh@@@@@@@test.com'
SELECT @string AS 'Before'
WHILE charindex('@@', @string) > 0
BEGIN
SELECT @string = REPLACE(@string, '@@', '@')
END
SELECT @string AS 'After'
This is the script I was looking for - your are a legend !
Thanks for your quick post - appreciate it
:)
privacy (GDPR)