Tag: SQL Prompt

  • Format a Partial Script with #SQLPrompt

    SQL Prompt is amazing and it’s my favorite tool. It’s actually what many people want first from Redgate because it makes coding much easier. One of the most used features is the reformat feature (CTRL+K,Y), since formatting really matters to developers.

    One of the neat features of SQL Prompt is that you can format just a portionof your script. That means if you’re working on a large script and want to reformat just a part of it, you can.

    Here’s how:

    • Highlight the code
    • Hit CTRL+K,Y

    promptformat

  • Reaching the Refactoring Redoubt with #SQLPrompt

    I enjoy themes, and when I ran across the SQL Prompt Treasure Island, I had to take a few minutes and go through it. I wrote about Code Snippet Cove first, and this post finishes my movement around the map. The other items I’ve read about are:

    Refactoring is Hard

    One of the things that I struggle with, and I think many others do as well, is refactoring. Not that refactoring or changing code is hard, but remembering to get all the various places changed can be a challenge. It seems that any refactoring might change an item in three or four places, but then forget one more, which leads to bugs and embarrassment.

    Fortunately, SQL Prompt has a few things to help. Smart Rename is one of these, which will let you know about all of the dependencies and places where code will change. This makes quick work of renames, which is something I’ve appreciate in other languages, but not T-SQL before this.

    Note that renaming objects is still disruptive and can break connected applications, so this still should be undertaken with care, and in synchronization with renaming the objects in application code.

    There are also the renaming of variables, which can be helpful when you realize that your short or obscure names aren’t helpful to others on your team.

    Perhaps my favorite refactoring feature is the Encapsulate as New Stored Procedure. I think more people should be using stored procedures, and while we might experiment and develop code as a batch or query, we want to move this to a stored procedure. This feature makes this simple for developers, and it’s one you should ensure they know how to use.

    There are other items in the treasure map, many of which are useful, but you’ll want to practice with them and decide which ones are most useful and helpful in your daily work.

    If you haven’t tried SQL Prompt, download an eval today and give it a go. I bet you will love it and ask for your own copy.

  • Relaxing on the Tab Management Terraces with #SQLPrompt

    I enjoy themes, and when I ran across the SQL Prompt Treasure Island, I had to take a few minutes and go through it. I’ve written about a few of the other items on the map:

    Tabs, Tabs, Tabs

    If you’re like me, you have a lot of tabs open in SSMS all the time. In fact, sometimes I think I have far too many open at one time. Likely that’s a sign of some distraction and too little focus, but it’s a habit that goes back through decades of SQL work for me.

    I used to love isql/w, as a very stable editor for my work. When Enterprise Manager came, I still often used isqlw. SSMS came along, I wasn’t thrilled at all, as it was a big, heavyweight tool. I’ve grown to like it and I feel comfortable, but I still have crashes at times.

    That’s where tab management comes in. SQL Prompt reopens my tabs, which I greatly appreciate, especially as I don’t always remember to save some random code I’m testing. Usually lots of development stuff is in a database, but having the tabs open automatically is a life saver.

    I don’t often use the Tab History item, but it is handy. I ought to use it more, because it is a good way to look back through work I’ve been doing and sometimes find a piece of code that I’m searching for.

    The coloring is great, especially as I work on a lot of different databases. Many times the color fades into the background, so it doesn’t necessarily help me with not working on the right instance/database, but when I wonder if I’m on a dev or test system, coloring is really helpful. Plus it looks great in demos and keeps the audience focused.

    SQL Prompt has lots of great features, many of which I’ve written about. After formatting and intellisense, this is the thing that I use most often.

    Give SQL Prompt a try. You’ll love the way it helps you write code.

  • Watching the Sands of Suggestion in #SQLPrompt

    I enjoy themes, and when I ran across the SQL Prompt Treasure Island, I had to take a few minutes and go through it. I wrote about Code Snippet Code recently, and this post continues to move across the map.

    Incredible Suggestions

    The first thing that most people notice after they install SQL Prompt is the suggestions that pop up as you type SQL code. This was one of the first things that captivated my interest after I started using the product. Seeing lists of tables, of columns, of valid syntax, pop up as I type is so useful that I struggle when I don’t get the suggestion box. By default, this appears quickly, and one of my customizations is that I have slowed it slightly so that quick typos don’t pop the box if I get rid of them immediately.

    However, as the Treasure Map shows, it’s not just suggestions, but also the fact that I can hover over a suggestion and get more data, like the code that defines a table, view, or procedure. This is especially handy when using views, as I’ll look to see if I’m starting to nest views in queries.

    I do find that CTRL+Shift+D is one of the shortcuts that I often need. I may create a table or run some code in another tab, and I don’t get refreshed suggestions automatically. There is an experimental feature to auto refresh suggestions, but this means more polling of the database, and I try to avoid adding more load to processes that are running. The shortcut works well for me.

    The Dependencies Tip

    SQL Prompt has lots of features, and plenty that I don’t use. A few I don’t use because I don’t know about them. The dependencies tip is one of these. I didn’t know about it until I read the Treasure Map post, but now I think that’s a really cool features. If I’m looking to alter my schema, one of the important things to know is what dependencies I have. Certainly I could use SQL Search, but being able to quickly decide what objects I need to consider, or where I need to make other changes, is great.

    The Treasure Map describes this, but I had to experiment a bit to understand how this works. I’ve added a short animation to show this.

    dependencies

    Now that I know this, I’ll get the list, copy it, and use it as a TODO list of things to alter in this same commit. I’ll also know where to test changes before I actually commit this code to a shared repo where others will see it.

    There are plenty of other small features in this list, and you ought to experiment with these if you write a lot of T-SQL. You’ll find them to be helpful and handy.