Database, Programming, SQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2012, SQL Tips, Technology, Transact-SQL, tSQL

TSQL Query to Compare Row Counts of Tables in a Local and a Remote Database

This is a fun thought exercise…. in MS SQL Server, use a linked server to compare how many rows are in each table of a backup development server with how many rows are in the actual production server. This would be especially relevant if you just did a database backup from prod into development and now want to see a few hours later on what tables the most growth is happening on…

Continue reading “TSQL Query to Compare Row Counts of Tables in a Local and a Remote Database”
Database, Programming, Software, SQL, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2012, SQL Tips, Transact-SQL, tSQL

SQL Server Error: Fixing The Transaction Log for Database is Full Due to log_backup

T-SQL
T-SQL

If you are working with SQL Server, you may see an ominous sounding error: the transaction log for database {Your Database Name} is full due to log_backup Continue reading “SQL Server Error: Fixing The Transaction Log for Database is Full Due to log_backup”

Database, Programming, SQL, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2012, SQL Tips, Transact-SQL, tSQL

TSQL Search for the Last Record in a Group

In this article I’ll show how to get the most recent record for a group of records in a SQL Server table. There are a number of ways to do this including CTEs and nested subqueries. Since nested subqueries are the most widely supported across the different versions of SQL Server, I consider them the most robust/straightforward way to get the job done, so in this article I will show you how to solve this problem using a nested subquery in either your WHERE or your FROM clause.

At the end of this article I’ll give the full working example Pet shop table and query that you can copy and paste into a SQL Server Management Studio (SSMS) session to try out the code for yourself.

If you find this article useful, be sure to check out my other SQL Server related articles for more tips.

Continue reading “TSQL Search for the Last Record in a Group”