A community member called Tom Cooper helped me with code to remove https:// from fields.
I was wondering if someone could help me build on the code to remove some forward slash characters from an http address.
For example, some fields may include a forward slash as follows www.parliament.uk/lords or www.intermed.de/ see image
I would like some help modifying the code below such that www.parliament.uk/lords returns www.parliament.uk and www.intermed.de/ returns www.intermed.de
SELECT DISTINCT
homepage_url
,SubString(websiteurl,
Case When CharIndex('://', websiteurl) = 0 Then 1 Else CharIndex('://', websiteurl)+ 3 End, Len(websiteurl)) as websiteurl
FROM dbo.account
INNER JOIN dbo.CRM2CBURL_Lookup L
ON Id = [Key]
INNER JOIN dbo.organizations
ON CB_URL_KEY = cb_url
You don't have to worry too much about the joins. I just need the code to remove the forward slash (and anything after the forward slash)
Sample Data
CREATE TABLE #tmpTable (
homepage_url nvarchar(150),
websiteurl varchar(100))
INSERT #tmpTable VALUES
(N'http://www.opisnet.com','www.opisnet.com'),
(N'http://www.ebookers.com','www.ebookers.com'),
(N'http://navico.com','navico.com'),
(N'https://zeb-consulting.com','www.zeb.de'),
(N'http://www.hobbycraft.co.uk','www.hobbycraft.co.uk'),
(N'http://www.parliament.uk/lords','www.parliament.uk/lords'),
(N'https://www.intermed.de/','www.intermed.de/'),
(N'http://www.iac.com','www.iac.com'),
(N'https://www.esteve.es','www.esteve.com/'),
(N'http://www.kornferry.com/','www.kornferry.com')
SELECT * FROM #tmpTable