Exploring Your SQL Server Databases with T-SQL Scott Swanberg August 1, 2015 Baton Rouge SQL Saturday
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
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
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
Scott Swanberg And I have a connection to Baton Rouge. 5 | 9/22/2018 5 | 9/22/2018 Scott Swanberg SQL Saturday
My oldest daughter lives in Baton Rouge. 9/22/2018 Scott Swanberg SQL Saturday
Scott Swanberg contact info Scott.Swanberg@AmbientConsulting.com ScottSwanberg@Comcast.net LinkedIn www.linkedin.com/in/scottswanberg Twitter as @WBLSwany 7 | 9/22/2018 Scott Swanberg SQL Saturday
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
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
1. Exploring your Servers Demo scripts #1 to #7 10 | 9/22/2018 Scott Swanberg SQL Saturday
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
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
2. Basic Database Exploration Demo scripts #8 to #22 13 | 9/22/2018 Scott Swanberg SQL Saturday
3. Exploring your Data Model in depth Data types Column Defaults Computed Columns Identity Columns 14 | 9/22/2018 Scott Swanberg SQL Saturday
3. Exploring your Data Model in depth Demo scripts #23 to #26 15 | 9/22/2018 Scott Swanberg SQL Saturday
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
4. Foreign Keys and Indexes Demo scripts #27 to #30 17 | 9/22/2018 Scott Swanberg SQL Saturday
5. Object Dependencies sp_msdependencies Query the system catalog views Using a Common Table Expression (CTE) 18 | 9/22/2018 Scott Swanberg SQL Saturday
5. Object Dependencies Demo script #31 to #38 19 | 9/22/2018 19 | 9/22/2018 Scott Swanberg SQL Saturday
Where to find my scripts Google/Bing: Scott Swanberg Simple Talk Google/Bing: Exploring Your SQL Server Databases with T-SQL www.simple-talk.com/author/scott-swanberg/ www.simple-talk.com/sql/database-administration/exploring-your-sql-server-databases-with-t-sql/ 20 | 9/22/2018 Scott Swanberg SQL Saturday
Downloads 9/22/2018 Scott Swanberg SQL Saturday
Minnesota SQL Server Connections. Jason Strate - Minnesota SQL Server MVP http://www.jasonstrate.com/ Dan English - Minnesota SQL Server MVP https://denglishbi.wordpress.com/ Tracy McKibben - Minnesota SQL Server Blogger http://realsqlguy.com/ Joe Sack - Minnesota SQL Server MVP http://www.pluralsight.com/author/joe-sack Scott Swanberg - Minnesota SQL Server simple talk author https://www.simple-talk.com/author/scott-swanberg/ https://www.simple-talk.com/sql/database-administration/exploring-your-sql-server-databases-with-t-sql/ 22 | 9/22/2018 Scott Swanberg SQL Saturday