An enhance script to check partition tables under all schemas in sqlserver

Simple step for EMC NW & NMM

(1) disable WINDOWS UAC (reboot)
(2) SET windows domain user AS sysadmin
(3) modify hosts
(4) install software (NW , NMM) (reboot)
(5) CONFIG NWDROP VIEW [partition_show]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE view [partition_show]
as
SELECT distinct OBJECT_NAME(T2.object_id) TABLE_NAME
,T1.partition_number
,T4.name as "function_name"
,T3.name as "schema_name"
,T7.name File_group_name
,T1.rows
,CASE boundary_value_on_right
WHEN 1 THEN ‘less than‘
ELSE ‘less than or equal to ‘ END as ‘comparision‘
--,CONVERT(varchar(100), T5.value, 112) value
,T5.value
FROM sys.partitions T1
INNER JOIN sys.indexes T2
ON T1.object_id = T2.object_id
INNER JOIN sys.partition_schemes T3
ON T2.data_space_id = T3.data_space_id
INNER JOIN sys.partition_functions T4
ON T3.function_id = T4.function_id
LEFT JOIN sys.partition_range_values T5
ON T4.function_id = T5.function_id
AND T1.partition_number = T5.boundary_id
INNER JOIN sys.destination_data_spaces T6
ON T6.partition_scheme_id = T3.data_space_id
AND T6.destination_id = T1.partition_number
INNER JOIN sys.filegroups T7
ON T6.data_space_id = T7.data_space_id
where T2.object_id in (select t.object_id from sys.tables as t inner join sys.indexes as i on t.object_id=i.object_id and i.type in (0,1) inner join sys.partition_schemes ps on i.data_space_id=ps.data_space_id)
AND T1.index_id<=1

-----------------------------------------------------------------------------------------------------------------------------
Difference
------------------------------------------------------------------------------------------------------------------------------
original part:
select OBJECT_ID(t.name) from sys.tables as t inner join sys.indexes as i on t.object_id=i.object_id and i.type in (0,1) inner join sys.partition_schemes ps on i.data_space_id=ps.data_space_id
new part
select t.object_id from sys.tables as t inner join sys.indexes as i on t.object_id=i.object_id and i.type in (0,1) inner join sys.partition_schemes ps on i.data_space_id=ps.data_space_id

原文地址:https://www.cnblogs.com/partition-liu/p/12318364.html

时间: 2024-10-29 20:55:59

An enhance script to check partition tables under all schemas in sqlserver的相关文章

Android MMC/EMMC/MTD Partition Layout

Android devices have a couple of partitions to store different data. The common ones are the recovery, boot, system, data and cache partitions. Almost every device has it’s own unique layout even though they come from the same manufacturer. I have se

Mysql Partition 理论知识总结

简述: 本文内容主要 Giuseppe Maxia 曾在Mysql Conference & Expo 2010发表关于 <Mysql Partition in Mysql 5.1 & 5.5>  经由整理后的内容,原文在下面的Presentation URL,本文用于自身学习 .我自身关于分区与未分区的测试,打算发表于另一篇博文.Giuseppe Maxia Bloghttp://datacharmer.blogspot.com/http://datacharmer.com/

课上练习 script

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Typ

GUID Partition Table (GPT)

https://en.wikipedia.org/wiki/GUID_Partition_Table https://zh.wikipedia.org/wiki/全局唯一标识分区表 GUID Partition Table (GPT) is a standard for the layout of the partition table on a physical storage device, such as a hard disk drive or solid-state drive, us

SQL Server -&gt;&gt; 生成时间类型的Partition Function和Partition Scheme代码

有时工作中要建个分区函数,可是像日期这种分区函数要是搞个几百个的值那不是要搞死我.于是写了点代码自动生成一个从1990年开始的按月的分区函数和对应的分区主题 USE [TestDB] GO DECLARE @STR NVARCHAR(MAX) SET @STR = 'CREATE PARTITION FUNCTION [PF_RangeByMonth_FromYear1990](DATETIME) AS RANGE LEFT FOR VALUES (' DECLARE @STR2 NVARCHA

【转载】实战mysql分区(PARTITION)

转载地址:http://lobert.iteye.com/blog/1955841 前些天拿到一个表,将近有4000w数据,没有任何索引,主键.(建这表的绝对是个人才) 这是一个日志表,记录了游戏中物品的产出与消耗,原先有一个后台对这个表进行统计.....(这要用超级计算机才能统计得出来吧),只能帮前人填坑了.... 数据太大,决定用分区来重构. 如果你发现是empty,说明你的mysql版本不够,分区至少要5.1 下面针对业务查询,决定用时间来做range分区(还有list,hash等类型),

Using the Windows Scheduler to run a SharePoint PowerShell Backup Script

Problem SharePoint administrators need to run regular backups using PowerShell, the STSADM tool or in Central Administration. There is no "built in" way to automate these backups. Wouldn't it be great to devise a method to automated these jobs?

实战mysql分区(PARTITION)

http://lobert.iteye.com/blog/1955841 前些天拿到一个表,将近有4000w数据,没有任何索引,主键.(建这表的绝对是个人才) 这是一个日志表,记录了游戏中物品的产出与消耗,原先有一个后台对这个表进行统计.....(这要用超级计算机才能统计得出来吧),只能帮前人填坑了.... 数据太大,决定用分区来重构. 如果你发现是empty,说明你的mysql版本不够,分区至少要5.1 下面针对业务查询,决定用时间来做range分区(还有list,hash等类型),一个月一个

AMS 启动出错: Waiting for another script to finish...

situation:ams streams 文件夹过大, 删除后,重启 ams, 重启失败, amscore 称为defunct process, 无法停止, ps auxww|grep ams,  kill 相关 process, 之后重启总是提示: Waiting for another script to finish... google之后发现 can no more start or stop FMS3 server, it says : Waiting for another scr