ALTER FUNCTION [dbo].[fn_genMd5]
(
@p_in VARCHAR(512)
)
RETURNS varchar(32)
AS
BEGIN
-- Declare the return variable here
DECLARE @p_out VARCHAR(32)
-- Add the T-SQL statements to compute the return value here
SELECT @p_out=substring(sys.fn_sqlvarbasetostr(HashBytes('MD5',@p_in)),3,32)
-- Return the result of the function
RETURN @p_out
END