Skip to content

Instantly share code, notes, and snippets.

@erraggy
Created May 26, 2011 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save erraggy/992654 to your computer and use it in GitHub Desktop.
Save erraggy/992654 to your computer and use it in GitHub Desktop.
Scalar function to format the post date and slug into the post URL
CREATE FUNCTION [dbo].[old_url]
(
@post_date datetime,
@post_title nvarchar(256)
)
RETURNS nvarchar(500)
AS
BEGIN
-- Declare the return variable here
DECLARE @url nvarchar(500)
DECLARE @y_m_d nvarchar(10)
DECLARE @clean_title nvarchar(500)
SET @y_m_d = CONVERT(nvarchar, @post_date, 111)
SET @url = '/archive/' + @y_m_d + '/' + + dbo.make_slug(@post_title) + '.aspx'
RETURN @url
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment