Skip to content

Instantly share code, notes, and snippets.

@ArCiGo
Last active May 20, 2019 01:05
Show Gist options
  • Save ArCiGo/e8b0328765f9859afdc2efc4eb468e15 to your computer and use it in GitHub Desktop.
Save ArCiGo/e8b0328765f9859afdc2efc4eb468e15 to your computer and use it in GitHub Desktop.
IF EXISTS(SELECT 1 FROM sys.objects WHERE name = 'StripWWWandCom')
DROP PROC StripWWWandCom
GO
CREATE FUNCTION StripWWWandCom(
@pInput VARCHAR(250)
)
RETURNS VARCHAR(250)
AS
BEGIN
DECLARE @WORK VARCHAR(250)
SET @WORK = @pInput
SET @WORK = REPLACE(@WORK, 'www.', '')
SET @WORK = REPLACE(@WORK, '.com', '')
RETURN @WORK
END
DECLARE @vWebSite VARCHAR(MAX)
SET @vWebSite = 'www.google.com'
SELECT dbo.StripWWWandCom(@vWebSite)
/** Output **/
---------------------------------------
google
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment