블로그 이미지
bedbmsguru

Notice

Recent Post

Recent Comment

Recent Trackback

Archive

calendar

1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
  • total
  • today
  • yesterday
2018. 10. 26. 21:30 SQL SERVER

SELECT t.name AS TableName, i.name AS IndexName , p.partition_number, e.name, f.name, f.type_desc, p.rows, rv.value, 
CASE WHEN f.boundary_value_on_right = 0 THEN 'LEFT' ELSE 'Right' END AS LeftRightBoundary,
CASE WHEN ISNULL(rv.value, rv2.value) IS NULL THEN 'N/A' 
ELSE
    CASE WHEN boundary_value_on_right = 0 AND rv2.value IS NULL THEN '>=' 
        WHEN boundary_value_on_right = 0 THEN '>' 
        ELSE '>=' 
    END + ' ' + ISNULL(CONVERT(varchar(50), rv2.value, 121), 'Min Value') + ' ' + 
        CASE boundary_value_on_right WHEN 1 THEN 'and <' 
                ELSE 'and <=' END 
        + ' ' + ISNULL(CONVERT(varchar(50), rv.value, 121), 'Max Value') 
END AS TextComparison
FROM sys.tables AS t  
JOIN sys.indexes AS i  
    ON t.object_id = i.object_id  
JOIN sys.partitions AS p  
    ON i.object_id = p.object_id AND i.index_id = p.index_id   
JOIN (select bb.name, aa.destination_id from sys.destination_data_spaces aa inner join sys.data_spaces bb ON aa.data_space_id=bb.data_space_id) E
ON p.partition_number = e.destination_id
JOIN  sys.partition_schemes AS s   
    ON i.data_space_id = s.data_space_id  
JOIN sys.partition_functions AS f   
    ON s.function_id = f.function_id
LEFT JOIN sys.partition_range_values AS r   
    ON f.function_id = r.function_id and r.boundary_id = p.partition_number  
LEFT JOIN sys.partition_range_values AS rv
    ON f.function_id = rv.function_id
    AND p.partition_number = rv.boundary_id     
LEFT JOIN sys.partition_range_values AS rv2
    ON f.function_id = rv2.function_id
    AND p.partition_number - 1= rv2.boundary_id
WHERE i.type <= 1 AND t.name = 'LOGIN_INFO_REPOSITORY'
ORDER BY t.name, p.partition_number;

'SQL SERVER' 카테고리의 다른 글

user가 가지고 있는 권한 확인  (0) 2018.10.26
Linked server List  (0) 2018.10.26
SSMS의 Tip  (0) 2018.10.26
Index REBUILD OR REORG 쿼리  (0) 2018.10.26
알아봐요 할 DMV  (0) 2018.09.19
posted by bedbmsguru