Two ways to rename SQL Server database objects

From time to time, a database object may need to be renamed for various reasons. When that happens, native features for renaming SQL Server database objects can be very useful. But, there are big differences between just renaming SQL Server database objects in the SQL Server Management Studio and Safe renaming them with ApexSQL Refactor.

This article will explain the differences between renaming database objects with SSMS and the ApexSQL Refactor’s Safe rename feature.

April 27, 2017

How to format all SQL objects in your database

The Format SQL objects feature allows users formatting one or more database objects with the specified formatting profile, without having to script them first.

There are three ways to invoke the Format SQL objects feature:

January 25, 2016

How to refactor a SQL Server database by splitting a table

Depending on the environment, splitting a SQL table may have a positive impact on the overall database performance. For instance, in scenarios where a table contains some large but rarely used columns, moving them to a separate table will increase performance as the frequently used data will be stored in a much smaller table, and the rarely used data will be only looked up when required. The impact on performance caused by the occasional joining will be compensated just by having SQL Server look up the data that’s used more often in a table which requires less disk space leading thus to a decrease in I/O and potentially an increase in page cache hits.

March 17, 2015

How to clean up SQL database code by removing unused parameters

Finding parameters and SQL variables that are only defined in the existing SQL Server stored procedures and functions, but never actually used, is not a problem, but for maintaining complex code, with dozens of parameters and variables, a tool like ApexSQL Refactor can be used, which is a SQL Server Management Studio and Visual Studio add-in, and useful SQL query formatter.

March 9, 2015

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 it will be described how to apply database refactoring on a SQL Server database and replace a natural key with a surrogate key by using ApexSQL Refactor a 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.

February 27, 2015

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.

February 27, 2015

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.

February 27, 2015

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.

February 27, 2015

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 dependencies need to be kept and to maintain a 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, one particular refactor for safe parameter modification will be described.

February 27, 2015

How to format a SQL query to qualify object names explicitly

ApexSQL Refactor is a SQL Server Management Studio and Visual Studio add-in, which formats SQL query and refactors SQL code using 11 code refactors and more than 200 formatting options.

The Object name qualifying feature allows users to refactor a SQL script so that all object names are qualified. The feature can refactor object names by qualifying these in a way to add:

February 27, 2015

SQL database refactoring – Introduction


What is database refactoring?

Database refactoring is a change in a database schema with a goal to improve a database design and retain both informational and behavior semantics.

March 14, 2014

SQL database refactoring techniques – Rename method

Why rename?

Rename table, Rename column, and Rename view are structural refactoring. The main purpose to apply Rename column, Rename table, and Rename view are increasing readability, adopting database naming conventions, or clarifying the meaning of an object. In the case of renaming objects, a cost of refactoring both database and external applications that access the database vs. an impact of the achieved readability, should be considered.

February 18, 2014