One SSMS Trick That Will Make You a Faster Query Builder

"17/365: i could be your magician" by Jin is licensed under CC BY 2.0

Watch this week's video on YouTube

Here's the scenario: you copy and paste some code into a query you are building. A few minutes later you need that same snippet again, but you've already copied and pasted something else onto the clipboard.

The next five minutes of your life are spent searching across the twenty query editor tabs you have open looking for that original piece of code.

Sound familiar?

THERE'S A BETTER WAY!

Copying and pasting is a feature that's available in nearly every text editor ("nearly" — anyone remember the days before iOS had a clipboard?).

However, SQL Server Management Studio goes above and beyond the regular copy and paste feature set — it has a clipboard ring.

What's a clipboard ring you ask?

ec575-1vgzb1j34ahgunbqofrgora

The clipboard ring let's you cycle through the last 20 things you copied onto your clipboard when you go to paste in SSMS. It can be accessed in the Edit menu (like in the screenshot above) or by using the keyboard shortcut CTRL + SHIFT + V.

Let's say you have the following queries:

----------------- Query 1 --------------------------
SELECT FruitId FROM dbo.Fruits WHERE Name = 'Apple'
----------------- Query 2 --------------------------
SELECT FruitId FROM dbo.Fruits WHERE Name = 'Banana'
----------------- Query 3 --------------------------
SELECT FruitId FROM dbo.Fruits WHERE Name = 'Orange'

And let's pretend you want to copy all of the fruit names into the IN statement of this query:

SELECT FruitId FROM dbo.Fruit WHERE Name IN ()

Instead of copying and pasting each fruit separately, you can batch your copies together and then paste them from the clipboard ring into your IN statement at the same time:

5c701-19e4bf0fjmtpji4ky8bz-mq

Use this trick the next time you need to find that snippet of code you used right before heading off to lunch and I guarantee you will be saving yourself tons of time.

Epic Life Quests

ff87c-0a7-0aztlscfuxve_

It is easy to get caught up in the daily details of life and not take the time to reflect on longer term goals and accomplishments.

Inspired by Brent Ozar and Steve Kamb, these Epic Life Quests are intended to help me reflect on my accomplishments and help me stay focused on the things that are important.

Each level contains five achievements and once all are completed I can "level up" to the next five. Follow along and let me know if you create any epic life quests of your own.

Level 2 (currently working on)

  • Blog weekly for 6 months straight — Last year I began blogging more than any previous year, but I didn't always stick to a schedule. My biggest problem was I didn't know what I wanted to write about so choosing topics was difficult and frustrating. After looking back at what posts were the most well-received, I've decided to focus the first half of 2017 to mostly technical and professional development type topics.
  • Speak at a technical conference — I've been presenting technical content in small user group type settings for years but this year I want to try my hand at some larger audiences. Completed January 2017 at the GroupBy conference.
  • Vacation in Hawaii — Our vacations in 2016 focused on places we could reach by car so that we could save some money for a larger trip. This will be the bigger trip. After visiting Hawaii, I will have visited 36 states + Washington D.C (airports don't count!).
  • Work on mental mindfulness— practice meditation to improve focus, patience, manage stress, be happier. I want to average at least 5 days/week for 3 months to reach this goal.
  • Always be reading at least one book — Although I read 40+ books in 2016, there were stretches of weeks at a time where I was not reading anything. For 6 months I don't want to go more than 3 days without having picked a book to have available to read.

Level 1 Quests (completed before 2017)

Here are some of my achievements before I started this page on January 1, 2017.

  • Set up an environment for programming regularly at home — completed 2016
  • Start using GitHubt for my coding projects — completed 2016
  • Built a hardware project that gets regular use (not just proof of concept) — completed 2016
  • Buy a house — completed 2015
  • Get into backpacking — completed 2015
  • Take a car trip in Europe with Renee — completed 2015
  • Learn to read books for pleasure — completed 2014