Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE FUNCTION [dbo].[UDF_GenerateSlug]
- (
- @str VARCHAR(100)
- )
- RETURNS VARCHAR(100)
- AS
- BEGIN
- DECLARE @IncorrectCharLoc SMALLINT
- SET @str = LOWER(@str)
- SET @IncorrectCharLoc = PATINDEX('%[^0-9a-z ]%',@str)
- WHILE @IncorrectCharLoc > 0
- BEGIN
- SET @str = STUFF(@str,@incorrectCharLoc,1,'')
- SET @IncorrectCharLoc = PATINDEX('%[^0-9a-z ]%',@str)
- END
- SET @str = REPLACE(@str,' ','-')
- RETURN @str
- END
Advertisement
Add Comment
Please, Sign In to add comment