Tuesday 21 March 2017

Check Duplicates URL present in a same row with the delimiter of "|" :

;with cte
as
(
SELECT ID,URL, SUBSTRING(URL, 1, CASE CHARINDEX('|', URL)
            WHEN 0
                THEN LEN(URL)
            ELSE CHARINDEX('|', URL) - 1
            END) AS FirstPart
    ,SUBSTRING(URl, CASE CHARINDEX('|', URL)
            WHEN 0
                THEN LEN(URL) + 1
            ELSE CHARINDEX('|', URl) + 1
            END,10000) AS LastPart
FROM #Temp
)
select * from cte where FirstPart=LastPart
Output:

No comments:

Post a Comment