Skip to content

Instantly share code, notes, and snippets.

@KyleMit
Last active August 29, 2015 14:01
Show Gist options
  • Save KyleMit/a94288a339ade6529a65 to your computer and use it in GitHub Desktop.
Save KyleMit/a94288a339ade6529a65 to your computer and use it in GitHub Desktop.
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