CREATE FUNCTION dbo.GetPasswordHash
(	
	@Password nvarchar(100)
)
RETURNS varchar(100)
AS
BEGIN
  IF NOT EXISTS(SELECT * FROM HotelSetup WHERE SearchKey='ComplexPasswordRules' AND KeyValue='1')
    SET @Password = LOWER(@Password)
  RETURN CONVERT(VARCHAR(MAX),HASHBYTES('SHA2_256', @Password),2)	
END
