DECLARE @Name NVARCHAR(776) = NULL;
EXEC sys.sp_rename 'dbo.MyUDT', 'zMyUDT';
GO
CREATE TYPE [dbo].[MyUDT] AS TABLE
(
[HierarchyId] [int] NOT NULL
)
GO
DECLARE REF_CURSOR CURSOR FOR
SELECT referencing_schema_name + '.' + referencing_entity_name
FROM sys.dm_sql_referencing_entities('dbo.MyUDT', 'TYPE');
OPEN REF_CURSOR;
FETCH NEXT FROM REF_CURSOR INTO @Name;
WHILE (@@FETCH_STATUS = 0)
BEGIN
EXEC sys.sp_refreshsqlmodule @name = @Name;
print @Name
FETCH NEXT FROM REF_CURSOR INTO @Name;
END;
CLOSE REF_CURSOR;
DEALLOCATE REF_CURSOR;
GO
DROP TYPE dbo.zMyUDT;