Created
May 2, 2014 18:13
-
-
Save DerKnerd/427c9a1553ac6247232e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION [dbo].[IsValidURL] (@Url VARCHAR(200)) | |
RETURNS INT | |
AS | |
BEGIN | |
IF CHARINDEX('https://', @url) <> 1 AND CHARINDEX('http://', @url) <> 1 | |
BEGIN | |
RETURN 0; -- Not a valid | |
END | |
-- Get rid of the http:// stuff | |
SET @Url = REPLACE(@URL, 'https://', ''); | |
-- Get rid of slashes | |
SET @Url = REPLACE(@URL, '/', ''); | |
-- Now we need to check that we only have digits or numbers | |
IF (@Url LIKE '%[^a-z0-9]%.%[^a-z0-9]%.%[^a-z0-9]%') | |
BEGIN | |
RETURN 0; | |
END | |
-- It is a valid URL | |
RETURN 1; | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment