SQL (Structured Query Language) is a standardised programming language used for managing relational databases and performing various operations on the data in them. So then, SQL databases – and the SQL code used to manage them – have become central to business operations.
All is well in SQL land so far then.
Yes but there are multiple styles for writing SQL code — and this means it can be difficult for companies to ensure consistency, particularly in collaborative DevOps environments.
Could the answer lie in automation? Specifically… automation to provide formatting.
Redgate Software’s SQL Prompt introduces a new automatic SQL code formatting option for this exact purpose.
Developers write in their own style, click a button in SQL Prompt and it automatically reformats their work to match the chosen company style. This means developers can code in their own way, while the company gets the benefits of standardisation and speed when it comes to managing and updating SQL code.
Developers can copy and paste code into an online coding engine on the Redgate website and try out the feature for themselves.
IntelliSense-style code completion
According to Redgate, “SQL Prompt is already the industry standard tool for writing, formatting and refactoring SQL Code in both SQL Server Management Studio (SSMS) and Visual Studio (VS). Using IntelliSense-style code completion, it strips away the repetition of coding, allows users to share frequently used snippets of SQL, and dramatically reduces the time required to write SQL.”
The new formatting engine in SQL Prompt v8 lets users create, share and save multiple code formatting styles, switch between them and try out new styles created by others in either SSMS or VS.
“This may not sound important but it’s a huge step,” says Grant Fritchey, Microsoft Data Platform MVP. “As companies move towards a DevOps style of working, we’re seeing the responsibility for developing databases using SQL code spread across teams and between teams. Now, rather than having the code written in a myriad of different ways, it can all be formatted in one style in one click. That makes sharing it, rewriting it, and developing it further incredibly simple.”
Opinions vary wildly on capitalisation, how objects are referenced, spacing and aligning, text coloring, and even commas and semi-colons. This in turn leads to database developers and Database Administrators (DBAs) having many different coding rules and styles. As a direct consequence, developers often have to work with code that – for them – is difficult to read and understand, which slows work down and can introduce errors into the code.
Jamie Wallis, Redgate product marketing manager sums up by saying that, with the new tools, while developers can still argue about the best way of writing SQL, they can now format it in one click to their preferred style, work on it… and then return it to the original style if needed.
Wallis nicely concludes, the arguments will probably continue, but the delays with working with SQL won’t.