Create a gist now

Instantly share code, notes, and snippets.

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