Common Table Expressions are a great way to simplify complex derived table queries. If it makes sense to break out one derived table or subquery into a CTE, it can make sense to do multiple CTE’s. To use multiple CTE’s in a single query you just need to: Finish the first CTE Add a comma Declare the name and optional …

Multiple CTE’s in a single Query Read more »

In preparation for an upcoming SQL Saturday presentation I have created another report to add to the FREE SQL Server Health reports project. The new Index Statistics Report is the 8th report in the series, intended to give DBA’s and database developers access to the information they need to analyze the health of their database.   Here is a screen …

Index Statistics Report added to the FREE SQL Server Health Reports Read more »

Normally by blog/website is focused only on SQL Server topics, but this just jumped out at me and I have to share it.   The holiday shopping season is here again, and so are the scammers.  Here is a copy of an email message that I received today, wanting a few simple things like name, age, eye color, home city, …

It is sad when Santa Claus wants to break into your bank account. Read more »

In preparation for an upcoming SQL Saturday presentation I have created another report to add to the FREE SQL Server Health reports project. This report has been replaced with the Backup Report in the Database Health Project. The Backup Set Report has been added to the SQL Health Reports.  The Backup Set Report  is the 7th report to be added to the Database …

Backup Set Report added to FREE Server Health Reports Read more »

In preparation for a SQL Saturday presentation I have created another report to add to the FREE SQL Server Health reports project.   The Database Size Report has been added to the SQL Health Reports.  The Database Size Report  is the 6th report to be added to the Database Health Reports package. The Database Health reports package is a FREE …

Database Size report added to SQL Health Reports Read more »

I submitted another abstract for SQL Saturday titled TSQL Basics – SQL Server Join Types. Focusing on inner join, left outer join, right outer join, full outer join, cross join and self join. This is for the SQL Saturday in Vancouver BC sessions. That makes three sessions for Vancouver now. I still need to figure out the selection process to …

SQL Server Join Types – inner join, left outer join, right outer join, full outer join, cross join and self join Read more »

Here is a script that I created to get the size of all of the databases on one SQL Server. Generally I stay away from temp tables, especially global temp tables, but I didn’t see a good way to do this without them. CREATE TABLE ##alldatabasesizes   (      dbname    VARCHAR(1024),      type_desc VARCHAR(1024),      name      VARCHAR(1024),      size      INTEGER   ); EXECUTE Sp_msforeachdb ‘INSERT INTO ##AllDatabaseSizes  SELECT db_name() as dbName, type_desc,  name, size FROM [?].sys.database_files’ SELECT * FROM   ##alldatabasesizes; DROP TABLE ##alldatabasesizes

Working on a new report for the SQL Server Health reports, I needed to display the amount of free disk space on a SQL Server. EXEC MASTER..Xp_fixeddrives; Which was useful if I just wanted to look, but I needed to use the results in a query, and I didn’t want to put the results into a temp table, so here is …

Determining free disk space with TSQL Read more »