DECLARE @ObjectName sysname = 'VIEW_NAME’; DECLARE @ObjectSchema sysname = 'dbo’; DECLARE @WithFullscan BIT = 1; DECLARE @ExecuteUpdateStatistics BIT = 1; —————CODE SET NOCOUNT ON; IF NOT EXISTS ( SELECT * FROM sys.objects WHERE name = @ObjectName AND schema_id = SCHEMA_ID(@ObjectSchema) AND type = 'V’ ) THROW 50000, 'Obiekt nie istniejeCzytaj dalej / Read more
Tag: statystyki
Statystyki do aktualizacji
SELECT [sch].[name] + ’.’ + [so].[name] AS [TableName] , [ss].[name] AS [Statistic] , [sp].[last_updated] AS [StatsLastUpdated] , [sp].[rows] AS [RowsInTable] , [sp].[rows_sampled] AS [RowsSampled] , [sp].[modification_counter] AS [RowModifications] FROM [sys].[stats] [ss] JOIN [sys].[objects] [so] ON [ss].[object_id] = [so].[object_id] JOIN [sys].[schemas] [sch] ON [so].[schema_id] = [sch].[schema_id] OUTER APPLY [sys].[dm_db_stats_properties]( [so].[object_id] ,Czytaj dalej / Read more
Statystyki filestats – io na serwerze
USE master go SET NOCOUNT ON DECLARE @crDate DateTime; DECLARE @hours DECIMAL(18,3), @Days int; DECLARE @FinalHours int, @FinalMinutes int, @FinalSeconds int, @total_seconds int; — Determine uptime by checking Tempdb creation datetime: SELECT top 1 @crdate=create_date FROM sys.databases WHERE NAME=’tempdb’ SELECT @hours = DATEDIFF(ss,@crDate,GETDATE())/CAST(60 AS Decimal)/CAST(60 AS Decimal); PRINT 'SQL ServerCzytaj dalej / Read more