Created
May 26, 2011 06:34
-
-
Save erraggy/992647 to your computer and use it in GitHub Desktop.
Scalar function to convert a post title into a URL slug
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].[make_slug] | |
( | |
@post_title nvarchar(256) | |
) | |
RETURNS nvarchar(500) | |
AS | |
BEGIN | |
-- Declare the return variable here | |
DECLARE @slug nvarchar(500) | |
DECLARE @clean_title nvarchar(500) | |
SET @clean_title = LOWER(dbo.deDupeSpaces(dbo.removePunctuation(@post_title))) | |
SET @slug = REPLACE(@clean_title, ' ', '-') | |
RETURN @slug | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment