You’re going to run into situations where someone has made poor choices in naming objects, or maybe the business logic has changed and the object name no longer makes sense. Either way, easily and quickly taking care of renaming the objects within scripts can be a pain.

Let’s take this code as an example:

SQL Prompt renaming objects 1

The table variable @a is a poor choice, so I want to replace it. Yes, I can do a search and replace to try to find it and replace it within the code, but SQL Prompt offers an alternative that is both easier and, depending on if you want to review the code as you change it, faster.

I can highlight any use of the variable @a and press the function key F2. This then highlights every use of that variable:

SQL Prompt renaming objects 2

If I start typing, I can rename the object, quickly and easily, and it renames everywhere at the same time:

SQL Prompt renaming objects 3

If I hit the Enter key, that gets committed to the code. However, if I hit the escape key, ESC, the changes are removed from script and it reverts back to what it was originally.

That’s it – a quick tip to help you make your code cleaner and more readable in a couple of clicks with SQL Prompt.

Take a look at my video below, or browse the rest of the handy #SuperSQLTips videos from other Data Platform MVPs and SQL Server experts, helping you get the most out of SQL Prompt:

If you’re new to SQL Prompt check it out for yourself with a free 28-day trial and see how much more productive you can be writing code every day.

Like this? Share it with other SQL professionals using the social sharing buttons below – and don’t forget to give me a shoutout @GFritchey. Thanks for reading.

 

Tools in this post

SQL Prompt

Write, format, and refactor SQL effortlessly in SQL Server Management Studio and Visual Studio.

Find out more

Share this post.

Share on FacebookShare on Google+Share on LinkedInTweet about this on Twitter

Related posts

Also in Blog

Where's the Ops in DevOps? Part 3

In this three-part series, guest bloggers from DevOpsGuys look at the real role of Ops in DevOps. Where it changes, how it changes, and why Ops has an important part to play in the brave new world of ...

Also in Hub

The Louis Davidson custom style for SQL Prompt

My previous article in this series explained why it's important for a development team to adopt a common standard for formatting SQL code. It also gave a broad overview of the styles and actions withi...

Also in Product learning

How to implement a SQL formatting standard using SQL Prompt v8

With ten programmers working on the same project, how do you agree on a standard style for formatting SQL code, and then implement it consistently? One way is through draconian rules, meeting after me...

Also in Redgate products

Provisioning just got BIGGER with SQL Clone v2

Today, we launched SQL Clone v2, which removes the previous 2TB size limit and now supports cloning databases up to 64TB. In this article, I'll explain why I think this is big news for many organizati...

Also in SQL Prompt

How to style your SQL using SQL Prompt's new formatting options

The ability to customize and refine formatting options has long been a feature of SQL Prompt. In the eighth major update to the tool, we’ve introduced a brand new formatting engine that lets you man...

Also about SQL Prompt

How to implement a T-SQL code formatting standard using SQL Prompt

To what extent should a team attempt to impose a uniform SQL coding format? It can sometimes seem like a futile task. All programmers have a preferred formatting style, to which they profess an unwave...