NVARCHAR UDFs

This section provides a list of NVARCHAR UDFs for both, protect and unprotect operations.

pty_unicodevarcharins

This UDF protects the NVARCHAR data using the Unicode Gen2, and FPE data elements.

Note: This UDF does not support masking.

Signature:

pty_unicodevarcharins(data NVARCHAR(4000), dataelement VARCHAR(64))

Parameters:

NameTypeDescription
dataNVARCHAR(4000)Specifies the data to protect.
dataelementVARCHAR(64)Specifies the name of the data element.

Returns:
This UDF returns the protected value as the NVARCHAR(4000) datatype.

Attention: If the user does not have access to the data in the policy, this UDF returns ‘NULL’.

Exception:
If a data element or a security operation is configured in the policy and the user does not have access, then the function will terminate with an appropriate error message.

Example for Unicode Gen2:

Note: Unicode Gen2 data elements support newly introduced SLT_X_1 tokenizer from Protection Methods Reference along with the existing SLT_1_3 tokenizer. For more information, refer to section Unicode Gen2 in the Protection Methods Reference

select <database_name>.dbo.pty_unicodevarcharins(N'¢€ÃÂÃÄÅÊËÌÃÃŽÃÃÑÒÓÃÃ','TE_UG2_SLT13_L2R2_UTF16LE_Latin1_Supplement_ASTYES');
select <database_name>.dbo.pty_unicodevarcharins(N'▒','TE_UG2_SLTX1_L2R2_N_IPA_Greek_Coptic_UTF16LE');

Example for Unicode FPE:

select <database_name>.dbo.pty_unicodevarcharins('Protegrityl23','FPE_Alpha_Numeric_ASCII_Minlen2_ID_CC_L0R0_ASTNE');

pty_unicodevarcharsel

This UDF unprotects the protected NVARCHAR data using the Unicode Gen2, and FPE data elements.

Note: This UDF does not support masking.

Signature:

pty_unicodevarcharsel (data NVARCHAR(4000), DataElement VARCHAR(64))

Parameters:

NameTypeDescription
dataNVARCHAR(4000)Specifies the data to unprotect.
dataelementVARCHAR(64)Specifies the name of the data element.

Returns:
This UDF returns the unprotected value as the NVARCHAR(4000) datatype.
This UDF returns the protected value, if the option is configured in policy and the user does not have access to the data.

Attention: If the user does not have access to the data in the policy, this UDF returns ‘NULL’.

Exception:
If a data element or a security operation is configured in the policy and the user does not have access, then the function will terminate with an appropriate error message.

Example for Unicode Gen2:

Note: Unicode Gen2 data elements supports newly introduced SLT_X_1 tokenizer from Protection Methods Reference along with existing SLT_1_3 tokenizer. For more information, refer to the section Unicode Gen2 in the Protection Methods Reference

select 
<database_name>.dbo.pty_unicodevarcharsel(<database_name>.dbo.pty_unicodevarcharins(N'¢€ÃÂÃÄÅ
ÊËÌÃÃŽÃÃÑÒÓÃÃ,'TE_UG2_SLT13_L2R2_UTF16LE_Latin1_Supplement_ASTYES'),'TE_UG2_SLT13_L2R2_UTF16LE_Latin1_Supplement_ASTYES');
select 
<database_name>.dbo.pty_unicodevarcharsel(<database_name>.dbo.pty_unicodevarcharins(N'▒',
'TE_UG2_SLTX1_L2R2_N_IPA_Greek_Coptic_UTF16LE'),'TE_UG2_SLTX1_L2R2_N_IPA_Greek_Coptic_UT
F16LE');

Example for Unicode FPE:

select
<database_name>.dbo.pty_unicodevarcharsel('Protegrityl23','FPE_Alpha_Numeric_ASCII_Minlen2_ID_CC_L0R0_ASTNE');

Last modified : May 21, 2026