It's 2020 and MSSQL still can't cast or convert from/to user-defined types
Come on, Microsoft - this should be as simple as using the metadata from sys.types. Look, even I can do it:
declare @SystemTypeId tinyint,
select @SystemTypeId = systemtypeid, @MaxLength = maxlength from sys.types where name = 'youruserdefinedtype_name';
declare @TypeFullName sysname = type_name(@SystemTypeId) + (case
when @SystemTypeId in (167, 175) then '(' + cast(@MaxLength as varchar) + ')'
when @SystemTypeId in (239, 231) then '(' + cast((@MaxLength / 2) as varchar) + ')'
exec('select cast(somethingtobe_cast as ' + @TypeFullName + ');');
The above is ugly and hacky and obviously sub-optimal but I'm sure you guys have the smarts to make it better. So please, apply those smarts.
edit: GitHub Gist since this horrible UserVoice platform doesn't support code formatting: https://gist.github.com/IanKemp/f63730ab735cf7f8fe5ce14a344ba742