Created
June 24, 2017 18:29
-
-
Save akramarev/cfe70a7beba579fe2c7a284f636ff84c to your computer and use it in GitHub Desktop.
Update UDT MSSQL User Defined Types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment