Download presentation
Presentation is loading. Please wait.
Published bySugiarto Cahyadi Modified over 6 years ago
1
Exploring Your SQL Server Databases with T-SQL
Scott Swanberg August 1, 2015 Baton Rouge SQL Saturday
2
Track: SQL DBA Foundations
I'm often asked to analyze performance issues on a SQL Server instances with which I'm unfamiliar. It can be a daunting task. Let's face it, most of the time companies do not have good documentation about their databases. Or if they do, it is outdated, or it takes a few days to locate and retrieve it. 2 | 9/22/2018 Scott Swanberg SQL Saturday
3
Track: SQL DBA Foundations
I will share a set of basic scripts that I've developed, over the years, which mine the metadata in the various system functions, stored procedures, tables, catalog views, and dynamic management views, Together, they reveal all the secrets of the databases on the instance, their size, file locations, and their design, including columns, data types, defaults, foreign keys and indexes. You will walk away with about 40 scripts to reverse engineer a database. 3 | 9/22/2018 Scott Swanberg SQL Saturday
4
Scott Swanberg I’m from Minnesota, you betcha.
I started working with SQL Server with the initial release of SQL Server 6.5. I attended PASS Summit in Seattle 2010 & 2011 I’m a Sr. SQL Server DBA and performance tuning consultant, for Ambient Consulting in Minneapolis First time SQL Saturday Speaker 4 | 9/22/2018 Scott Swanberg SQL Saturday
5
Scott Swanberg And I have a connection to Baton Rouge. 5 | 9/22/2018
5 | 9/22/2018 Scott Swanberg SQL Saturday
6
My oldest daughter lives in Baton Rouge.
9/22/2018 Scott Swanberg SQL Saturday
7
Scott Swanberg contact info LinkedIn Twitter 7 | 9/22/2018 Scott Swanberg SQL Saturday
8
Exploring Your SQL Server in 5 topics
Exploring your Server Basic Database Exploration Exploring your Data Model in depth Foreign Keys and Indexes Object Dependencies 8 | 9/22/2018 Scott Swanberg SQL Saturday
9
1. Exploring your Servers
Basic Server Information Linked Servers List All Databases Last Database Backup Active User Connections by Database 9 | 9/22/2018 Scott Swanberg SQL Saturday
10
1. Exploring your Servers
Demo scripts #1 to #7 10 | 9/22/2018 Scott Swanberg SQL Saturday
11
2. Basic Database Exploration
Database File Location Row Counts for all Tables sp_msforeachbd and sp_msforeachtable Heaps Views Synonyms Stored Procedures Functions Triggers Check Constraints Sys.objects 11 | 9/22/2018 Scott Swanberg SQL Saturday
12
Sys.objects sys.objects.type AF = Aggregate function (CLR)
P = SQL Stored Procedure TA = Assembly (CLR) DML trigger C = CHECK constraint PC = Assembly (CLR) stored-procedure TF = SQL table-valued-function D = DEFAULT (constraint or stand-alone) PG = Plan guide TR = SQL DML trigger F = FOREIGN KEY constraint PK = PRIMARY KEY constraint TT = Table type FN = SQL scalar function R = Rule (old-style, stand-alone) U = Table (user-defined) FS = Assembly (CLR) scalar-function RF = Replication-filter-procedure UQ = UNIQUE constraint FT = Assembly (CLR) table-valued function S = System base table V = View IF = SQL inline table-valued function SN = Synonym X = Extended stored procedure IT = Internal table SQ = Service queue
13
2. Basic Database Exploration
Demo scripts #8 to #22 13 | 9/22/2018 Scott Swanberg SQL Saturday
14
3. Exploring your Data Model in depth
Data types Column Defaults Computed Columns Identity Columns 14 | 9/22/2018 Scott Swanberg SQL Saturday
15
3. Exploring your Data Model in depth
Demo scripts #23 to #26 15 | 9/22/2018 Scott Swanberg SQL Saturday
16
4. Foreign Keys and Indexes
What indexes exist Which indexes are missing Foreign Keys Missing indexes that support Foreign Keys 16 | 9/22/2018 Scott Swanberg SQL Saturday
17
4. Foreign Keys and Indexes
Demo scripts #27 to #30 17 | 9/22/2018 Scott Swanberg SQL Saturday
18
5. Object Dependencies sp_msdependencies
Query the system catalog views Using a Common Table Expression (CTE) 18 | 9/22/2018 Scott Swanberg SQL Saturday
19
5. Object Dependencies Demo script #31 to #38 19 | 9/22/2018
19 | 9/22/2018 Scott Swanberg SQL Saturday
20
Where to find my scripts
Google/Bing: Scott Swanberg Simple Talk Google/Bing: Exploring Your SQL Server Databases with T-SQL 20 | 9/22/2018 Scott Swanberg SQL Saturday
21
Downloads 9/22/2018 Scott Swanberg SQL Saturday
22
Minnesota SQL Server Connections.
Jason Strate - Minnesota SQL Server MVP Dan English - Minnesota SQL Server MVP Tracy McKibben - Minnesota SQL Server Blogger Joe Sack - Minnesota SQL Server MVP Scott Swanberg - Minnesota SQL Server simple talk author 22 | 9/22/2018 Scott Swanberg SQL Saturday
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.