﻿
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date, ,>
-- Description:	<Description, ,>
-- =============================================
CREATE FUNCTION [dbo].[fis_admin_getUserName]
(
	@name_enc varbinary(260)
	,@firstname_enc varbinary(260)
	,@title_enc varbinary(50)
)
RETURNS nvarchar(255)
AS
BEGIN
	DECLARE @Username nvarchar(255);

	SET @Username = CAST(	
											ISNULL(CASE WHEN @title_enc is null THEN '' ELSE CAST(DECRYPTBYKEY(@title_enc) as varchar(50)) + ' ' END,'')
											+ ISNULL(CASE WHEN @firstname_enc is null THEN '' ELSE CAST(DECRYPTBYKEY(@firstname_enc) as nvarchar(100)) + ' ' END,'')
											+ ISNULL(CASE WHEN @name_enc is null THEN '' ELSE CAST(DECRYPTBYKEY(@name_enc ) as nvarchar(100)) END, '')
									as nvarchar(255))


	RETURN @username;

END