Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DECLARE @str NVARCHAR(MAX) SELECT @str = N''
SELECT @str = @str + 'exec sp_refreshsqlmodule '''
+ SCHEMA_NAME([schema_id]) + '.' + OBJECT_NAME([object_id])
+ '''' + CHAR(13) + CHAR(10)
FROM sys.objects o
WHERE [type] IN ('FN', 'IF', 'P', 'TF', 'V')
AND is_ms_shipped = 0
AND NOT EXISTS (SELECT 1 FROM sys.sql_modules m
WHERE m.[object_id] = o.[object_id]
AND m.[definition] like '%WITH SCHEMABINDING%')
ORDER BY OBJECT_NAME([object_id])
PRINT @Str
EXEC sp_executesql @str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment