Published on

January 11, 2017

Beautify SQL Code with dbForge SQL Complete

When working with SQL code, it’s common for it to become disorganized and hard to read, especially in large projects or when multiple developers are involved. In this article, we will discuss how to keep your SQL code clean and well-formatted using dbForge SQL Complete.

One of the biggest challenges in code review is dealing with different coding styles used by individual developers. This can make the review process complicated and time-consuming. With dbForge SQL Complete, you can easily format your code to make it more readable and consistent throughout the file.

dbForge SQL Complete is a smart add-in for Microsoft Visual Studio and SSMS that provides excellent functionality for formatting SQL code. With just a simple key combination (Ctrl+K+D), you can quickly make your code properly formatted and easy to read.

Let’s take a look at an example of unformatted messy code taken from a production environment:

SELECT column1,column2,column3
FROM table1
WHERE condition1 AND condition2 OR condition3
GROUP BY column1,column2
HAVING condition4
ORDER BY column1 ASC,column2 DESC

As you can see, the code lacks proper indentations and spacing, and keywords are presented in different cases throughout the code. It’s difficult to understand and work with this code.

However, with dbForge SQL Complete, you can easily format the code to make it look clean and pretty:

SELECT column1, column2, column3
FROM table1
WHERE condition1 AND condition2 OR condition3
GROUP BY column1, column2
HAVING condition4
ORDER BY column1 ASC, column2 DESC

dbForge SQL Complete also allows you to customize formatting profiles according to your preferences. You can access the formatting options by going to the SQL Complete menu and clicking on Options. From there, you can choose from the built-in profiles or create your own custom profile.

For example, if you want to put each statement on a separate line, add a line break after the WHERE statement, and add a small indent to conditions, you can easily achieve this by customizing the formatting profile:

SELECT column1, column2, column3
FROM table1
WHERE condition1
    AND condition2
    OR condition3
GROUP BY column1, column2
HAVING condition4
ORDER BY column1 ASC, column2 DESC

Once you have customized the formatting profile, you can easily share it with your team members. This allows you to standardize the code appearance and make it easier for developers to read and edit the code.

In conclusion, dbForge SQL Complete is a powerful tool that helps you keep your SQL code properly formatted and readable. It offers features like code completion, code snippets, SQL refactoring, and more, which enhance your productivity and make SQL code writing a breeze.

Click to rate this post!
[Total: 0 Average: 0]

Let's work together

Send us a message or book free introductory meeting with us using button below.