Author: Kevin

  • Making Numbers Look Better

    The last time we were together, we discussed Making Better Numbers. Hopefully, you took a few minutes to review some of the examples I provided, figure out which ones do and do not make sense to you, and try to figure out some examples on your own. If not, try doing that before reading any…

  • Making Better Numbers

    In our last post, we discussed fixing dates so that they’re more of what the users expect. In this post, I want to talk about changing numbers. First off, it’s actually a very common thing to change a number from one type to another. For example, I’m often asked to change a decimal into an…

  • Making A Better Date

    In the last few posts, we’ve discussed different ways of “prettifying” – yes, a very technical word – dates. And no, we’re not talking about the kind you can eat or go on. Nope, we’re talking about this kind of date: Let’s say you’re busy coding along and you come to the realization that you…

  • Prettifying A Whole Mess of Dates

    In our last time together, we were talking about Doing more when trying to Convert. One of the many things I mentioned was using the CONVERT function to change a date to always look a particular way – for example, MM-DD-YYYY or DD/MM/YYYY. Since the CONVERT function requires you to either look up each time…

  • Doing more when trying to Convert

    The last time we met, we discussed the glorious try_convert function and how it can save us from “not-so-datey” dates. Most of the time, at least in a business setting, we don’t want to display NULLs to our users, so in many cases, we’re asked to put a placeholder if there is a NULL. We…

  • Telling data to act like other data

    When messing with data, sometimes you want to change how SQL Server sees the data. For that, you would want to use the CONVERT command. There are many great reasons to do this and thankfully some of our datasets have some great possibilities that you can work with. For example, after looking at the Nirvana…

  • The End of the TOP

    After dealing with TOP and ROWCOUNT in SQL Server, there is one more way of getting a limited amount of data from a query that you should be aware of – OFFSET/FETCH. It can be a little bit more difficult to set up and work with but if you’re in need of the data a…

  • Not Quite To the Top

    After the past few blog posts, I’m sure you’re like “Sherpa! How many more things can we learn about the TOP Operator?” My friends, the answer is “Still more!” Today, let’s go over an option that can be used in conjunction with TOP. That option is SET ROWCOUNT (Number); This option has the potential to…

  • There Has to be Room at the TOP!

    In our continuing adventures with the TOP operator in SQL, we’ve seen it do a lot of things that probably aren’t obvious when you first think about using TOP – especially if you’ve been using SQL for a while. Let’s say that our wonderful Product team asks us to get the top 1 % of…

  • What to do with TOP when there are ties

    In the last few blog posts – see here and here – we’ve been discussing the usage of the TOP operator. The product team will often ask for the top 5 of something or even the top 10% of performers in a subregion. There’s an additional part to the TOP operator that you won’t see…