Created
April 2, 2016 16:21
-
-
Save mvalipour/9ceb7db700b2c90eeff7366b734b7c93 to your computer and use it in GitHub Desktop.
Update SQL Statistics with Full Scan
This file contains hidden or 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 @sql nvarchar(MAX); | |
| SELECT @sql = (SELECT 'UPDATE STATISTICS [' + DB_NAME() + '].[' + rtrim(sc.name) + '].[' + rtrim(so.name) + '] WITH FULLSCAN, ALL;' + CHAR(13) + CHAR(10) | |
| from sys.sysobjects so | |
| join sys.schemas sc | |
| on so.uid = sc.schema_id | |
| where so.xtype = 'U' | |
| FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)'); | |
| PRINT @sql | |
| EXEC (@sql) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment