|
Each contribution is licensed to you under a License Agreement by its owner, not Microsoft. Microsoft does not guarantee the contribution or purport to grant rights to it.
|
Categories |
Create/Truncate an Indexstats Table(Microsoft)
Script Code
VBScript
if exists (select 1 from sysobjects where id=object_id(N'[dbo].[init_indexstats]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop proc dbo.init_indexstats go CREATE proc dbo.init_indexstats as set nocount on if not exists (select 1 from dbo.sysobjects where id=object_id(N'[dbo].[indexstats]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) create table dbo.indexstats ( database_id smallint NOT NULL ,object_id int NOT NULL ,index_id int NOT NULL ,partition_number int NOT NULL ,leaf_insert_count bigint NOT NULL ,leaf_delete_count bigint NOT NULL ,leaf_update_count bigint NOT NULL ,leaf_ghost_count bigint NOT NULL ,nonleaf_insert_count bigint NOT NULL ,nonleaf_delete_count bigint NOT NULL ,nonleaf_update_count bigint NOT NULL ,leaf_allocation_count bigint NOT NULL ,nonleaf_allocation_count bigint NOT NULL ,leaf_page_merge_count bigint NOT NULL ,nonleaf_page_merge_count bigint NOT NULL ,range_scan_count bigint NOT NULL ,singleton_lookup_count bigint NOT NULL ,forwarded_fetch_count bigint NOT NULL ,lob_fetch_in_pages bigint NOT NULL ,lob_fetch_in_bytes bigint NOT NULL ,lob_orphan_create_count bigint NOT NULL ,lob_orphan_insert_count bigint NOT NULL ,row_overflow_fetch_in_pages bigint NOT NULL ,row_overflow_fetch_in_bytes bigint NOT NULL ,column_value_push_off_row_count bigint NOT NULL ,column_value_pull_in_row_count bigint NOT NULL ,row_lock_count bigint NOT NULL ,row_lock_wait_count bigint NOT NULL ,row_lock_wait_in_ms bigint NOT NULL ,page_lock_count bigint NOT NULL ,page_lock_wait_count bigint NOT NULL ,page_lock_wait_in_ms bigint NOT NULL ,index_lock_promotion_attempt_count bigint NOT NULL ,index_lock_promotion_count bigint NOT NULL ,page_latch_wait_count bigint NOT NULL ,page_latch_wait_in_ms bigint NOT NULL ,page_io_latch_wait_count bigint NOT NULL ,page_io_latch_wait_in_ms bigint NOT NULL ,now datetime default getdate()) else truncate table dbo.indexstats go exec dbo.init_indexstats
Platforms
For online peer support, join
The Official Scripting Guys Forum!
To provide feedback or report bugs in sample scripts, please start a new discussion on the Discussions tab for this script.
Disclaimer
The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.
Be the first to create a discussion.
|