Azure-Sql-Db

SSMS Tips and Tricks 2-1: Environment fonts

I’ve been very lucky over the years because I haven’t needed to wear glasses. Every now and then I purchase a pair because I thought it might help with reading. Once I get them though, I find them more inconvenient than helpful and stop using them. I’ve am long-sighted in one eye and short-sighted in the other. That’s turned out to be a really useful thing in day to day life.

2025-06-02

SQL Interview: 52 Deleting duplicated rows

This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.

Section: Administrator Level: Medium

Question:

You have an ETL process that loads employee details into a table named Staging.Employees. The table has the following columns:

  • EmployeeID (int)
  • FullName (nvarchar(100))
  • LoginName (varchar(100))

The table is a heap and has no primary key.

2025-06-01

SSMS Tips and Tricks 1-12: Custom report creation

The built-in reports in SQL Server Management Studio are great but you can add your own as well. SQL Server 2005 and later have an option for Custom Reports. Let’s create a report that shows the use of deprecated data types. We’ll use a stored procedure from our free SDU Tools to do that. In SQL Server Data Tools, create a new Report Server project.

Give the project an appropriate name and location, then click Create.

2025-05-31

SSMS Tips and Tricks 1-11: Built-in standard reports

SQL Server Management Studio provides a large amount of information about databases by letting the user navigate around Object Explorer and view the properties of objects.

What I’m often surprized by though, is the number of users who haven’t ever explored the reports that are available. In another section, we’ll look at creating custom reports, but there is a wonderful set of built-in standard reports that you should explore. For example, if I right-click the WideWorldImporters database, I can see these reports:

2025-05-29

SQL Interview: 51 Truncating datetime values to the minute

This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.

Section: Developer Level: Medium

Question:

You are creating a view in a SQL Server based data warehouse.

You need to query transactions that include a TransactionDateTime column which uses the DateTime data type. The query is as follows:

2025-05-28

SSMS Tips and Tricks 1-10: Dependency Tracking

In early versions of SQL Server, the only way to try to track dependencies between tables, procedures, functions, etc. was to use the sp_depends stored procedure.

And everyone thought it lied.

The real problem was that it didn’t understand partial dependencies and deferred resolution of objects. For example, it got confused if you created a procedure that mentioned a table, then later created the table.

SQL Server 2012 introduced far superior dependency views, and SQL Server Management Studio (SSMS) shows dependencies using those views under the covers.

2025-05-27

SSMS Tips and Tricks 1-9: Turn off option to prevent saving changes that require table recreation

I don’t use the table designer in SQL Server Management Studio. Sorry, but I just don’t like it, or the options that it chooses for me. I’d rather use T-SQL every time, but I’m also the first to admit that there are plenty of people who would use that designer.

And when they do, many run into an error that says:

Saving changes is not permitted. The changes that you have made require the following tables to be dropped and re-created. You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created.

2025-05-25

SQL Interview: 50 Using WHERE vs HAVING

This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.

Section: Developer Level: Intro

Question:

You need to filter rows being returned by a query.

When should you use a HAVING clause rather than a WHERE clause?

Answer:

A WHERE clause is used to filter the rows from the source (usually a table).

2025-05-24

SSMS Tips and Tricks 1-8: Generate insert scripts that script data

Over the years, I’ve had a surprising number of questions on how to output all the data in a table as a series of INSERT statements. SQL Server Management Studio has had the ability to do this for a long time. Here’s an example.

In Object Explorer, I’ve expanded the WideWorldImporters database, then expanded Tables. Where people come unstuck is they right-click the table, and look at the scripting options:

2025-05-23

SSMS Tips and Tricks 1-7: Navigate as you type in sorted Object Explorer Details pane

I’ve mentioned a number of times how useful I think the Object Explorer Details panel is in SQL Server Management Studio.

One option in that panel that might not be so obvious is the sorted navigation. Here’s an example.

I’ve opened the WideWorldImporters database in Object Explorer, and clicked on the Tables node:

I then hit F7 to open the Object Explorer Details pane and clicked the Name heading to sort the table list. I like it ascending so you might need to click it twice:

2025-05-21