How to refactor a SQL Server database table to add a surrogate key

Choosing a primary key is one of the most important steps in a database design. There are two types of a primary key – a natural key and a surrogate key.

In this article we will describe how to apply database refactoring on a SQL Server database and replace a natural key with a surrogate key by using ApexSQL Refactor a free SQL Server Management Studio and a Visual Studio add-in that provides numerous features for refactoring of SQL code and uses one of fastest SQL formatters.

SQL query basics – How to improve readability by formatting commas, spacing and alignment

The previous article covered SQL query readability basics such as capitalization strategies and their implementation in SQL formatter by ApexSQL. This time, commas, spacing, and aligning will be detailed. One of the quickest ways to wreak havoc among developers is to start a discussion about how commas should be treated within the code, particularly in a SELECT list. Let’s look at how commas can be treated in ApexSQL Refactor.

SQL query basics – How to improve readability by formatting capitalization and object naming

Many development teams spend an inordinate amount of time arguing over styling and formatting preferences. Although these preferences are often subjective, at the end the code should be consistent. Since styling comes up frequently during code reviews, it is a good idea to have a strategy in place for dealing with it. This article series will address several SQL readability strategies as well as provide examples that demonstrate different ways you can format T-SQL in ApexSQL Refactor. Let’s begin with capitalization and object naming.

Replacing one-to-many relationships with association tables automatically– Part 1

The Replace one-to-many relationship feature in ApexSQL Refactor, an SSMS/VS add-in, will isolate the relationship between two tables and add a separate association table.

A one-to-many relationship is one of the most common relationship types in relational databases. It is a principle of database design, implicitly created and enforced by the use of relationships between tables, especially the relationship between a primary key and a foreign key.

How to safely modify SQL stored procedure and SQL function parameters

Modifying parameters of a SQL function or a stored procedure is not a simple task if we want to keep dependencies and maintain database integrity. ApexSQL Refactor is a SQL Server Management Studio and Visual Studio add-in for SQL formatting with a collection of useful code refactors. In this article, we will describe one particular refactor for safe parameter modification.