I needed a way to list the indexes for an entire database, but I was running into a problem using sys.indexes that I could only see the indexes for the current database. Below is the solution that I put together to list off of the indexes in the entire database. CREATE TABLE ##allindexes(databse_id INTEGER,table_id INTEGER,index_id INTEGER,table_name      VARCHAR(1024));EXECUTE Sp_msforeachdb’use [?];INSERT INTO ##AllIndexesselect DB_ID() as database_id, object_id as table_id, index_id, namefrom sys.indexeswhere name is not null’ SELECT *FROM   ##allindexes;DROP TABLE ##allindexes;

The following question came up when working on my CTE presentation for SQL Saturday. Does a query that JOINs a CTE to itself execute the CTE query once or twice? For instance:  ;WITH deptCTE(id, department, parent)    AS (SELECT id,department,parent FROM   Departments)SELECT q1.department,q2.department  FROM deptCTE q1 INNER JOIN deptCTE q2 ON q1.id = q2.parent WHERE q1.parent IS NULL;  The following execution plan is produced showing that the Departments table is hit twice with a table scan each time with the same cost. …

CTE Query Performance Read more »

by Steve Stedman and the Stedman Solutions Team Optimize For Ad-Hoc Workloads – Video Tip Tue, 27 Apr 2021 Learn how Optimize For Ad-Hoc Workloads can save some space in your plan cache. Transcription: Steve Stedman 0:09Hi, this is Steve Stedman and I’m here to talk about daily checkup or database health quick scan items that we come across Read more…​ …

April Blog Post Wrap-up Read more »

These are 5 questions asked after our February 2020 corruption presentation. Hope these answers help you as well. Transcription: 0:10Q: So our very first question is in regards to check DB when you’re when you’re mentioning people who are colorblind. He asks, “Can you use with no messages?” Steve Stedman 0:24A: Yes, absolutely. And you know, it’s check DB. And …

Questions Following Corruption Presentation – Video Read more »

The Stedman Solutions team shares ways to reduce the impact of server corruption. Transcription: Steve Stedman 0:10All right. Ways to reduce impact are backups, good backups, frequent backups, and off site backups with that, it’s not just SQL backups, but also virtual machine and system backups, not just backups, but backups that have been confirmed and tested. And tested recently. …

How to Reducing the Impact of Database Corruption – Video Tips Read more »

Learn how Optimize For Ad-Hoc Workloads can save some space in your plan cache. Transcription: Steve Stedman 0:09Hi, this is Steve Stedman and I’m here to talk about daily checkup or database health quick scan items that we come across occasionally. These are settings that we optimize or configure on the SQL Server in order to help with performance. Usually, …

Optimize For Ad-Hoc Workloads Read more »

Cost threshold for parallelism and the max degree of parallelism ( maxdop ) are 2 important setting for your SQL Server. Find out how to set these and what they should be set to. Transcription: Steve Stedman 0:09Hi, this is Steve Stedman and I’m here to talk about a couple of the daily checkup or database health quick scan items …

SQL Server Parallelism Settings – Video Tip Read more »

Join us May 11th @ 12 pm PST – Steve Stedman will teaching a FREE lesson on SQL Server Join Types. TSQL joins – what’s the difference, and how can you use joins correctly? Sometimes an inner join is the right join type to use, other times the left outer join, right outer join, full outer join, cross join or …

TSQL Basics: SQL Server Join Types Webinar Read more »