If we are having a database with masking columns(Dynamic Data Masking) and not sure about how to get all the masking columns information as a ALTER TABLE script, we can use below script for the same.
SELECT 'ALTER TABLE ' + SCHEMA_NAME(t.schema_id) + '.' + object_name(c.object_id) + ' ALTER COLUMN ' + c.name + ' ' + UPPER(tp.name) +
CASE WHEN tp.name IN ('varchar', 'char', 'varbinary', 'binary', 'text')
THEN '(' + CASE WHEN c.max_length = -1 THEN 'MAX' ELSE CAST(c.max_length AS VARCHAR(5)) END + ')'
WHEN tp.name IN ('nvarchar', 'nchar', 'ntext')
THEN '(' + CASE WHEN c.max_length = -1 THEN 'MAX' ELSE CAST(c.max_length / 2 AS VARCHAR(5)) END + ')'
WHEN tp.name IN ('datetime2', 'time2', 'datetimeoffset')
THEN '(' + CAST(c.scale AS VARCHAR(5)) + ')'
WHEN tp.name = 'decimal'
THEN '(' + CAST(c.[precision] AS VARCHAR(5)) + ',' + CAST(c.scale AS VARCHAR(5)) + ')'
ELSE ''
END + ' MASKED WITH
(FUNCTION='''+ c.masking_function COLLATE SQL_Latin1_General_CP1_CI_AS + ''')'+ CASE c.is_nullable WHEN 1 THEN ' NULL;' ELSE ' NOT NULL;' END
FROM sys.masked_columns as c
JOIN sys.tables AS t
ON c.object_id = t.object_id
JOIN sys.types as tp
on c.user_type_id = tp.user_type_id