CREATE FUNCTION [dbo].[fn_text_masking]
(
@in_input VARCHAR(MAX),
@in_mask_len INT
)
RETURNS VARCHAR(MAX)
AS
BEGIN
DECLARE @mask_text VARCHAR(MAX), @mask_char VARCHAR(20)
SET @mask_char = 'XXXXXXXXXXXXXXXXXXXX'
SELECT @mask_text = REPLACE(@in_input, SUBSTRING(@in_input, 1, LEN(@in_input) - @in_mask_len),
SUBSTRING(@mask_char, 1, LEN(@in_input) - @in_mask_len))
RETURN @mask_text
END
------------------------------------------------
SELECT dbo.fn_text_masking('123456789',4)
(
@in_input VARCHAR(MAX),
@in_mask_len INT
)
RETURNS VARCHAR(MAX)
AS
BEGIN
DECLARE @mask_text VARCHAR(MAX), @mask_char VARCHAR(20)
SET @mask_char = 'XXXXXXXXXXXXXXXXXXXX'
SELECT @mask_text = REPLACE(@in_input, SUBSTRING(@in_input, 1, LEN(@in_input) - @in_mask_len),
SUBSTRING(@mask_char, 1, LEN(@in_input) - @in_mask_len))
RETURN @mask_text
END
------------------------------------------------
SELECT dbo.fn_text_masking('123456789',4)
No comments:
Post a Comment