Category: SQLBasics
-
Analogous Strings and Validation Thereof
One of the many things that you’ll need to do when working with strings is to compare them. In a perfect world – and we all know that we don’t live in one of those – we would just have to do the simplest of comparison tools – check if they’re equal. In this comparison,…
-
Getting Strings to Work Like You Think They Would
When we start playing with strings, one of the first functions we work with is the “LIKE” operator. It’s fairly easy to grasp and easy to remember how to deal with. Thus why we’re going to go over it today because there are various possibilities with it. The first, and arguably, what you do most…
-
Looking for Strings A Different Way
Last time, we learned about CHARINDEX and all of the fun that it can do to make dealing with strings within strings a bit easier. This time, I want to talk about another function that does kind of the same thing but slightly differently. The function I’m talking about is PATINDEX. When you think about…
-
Matching Strings within One Big String
Continuing on with our series from last time – see here if you somehow missed it – let’s have some more fun with the different functions we can use with strings. This time, let’s focus on looking for different items we can use to find a string within a string. One of my favorite functions…
-
Making Letters Do What Want
In our databases, we’ll find all kinds of string data. Sometimes, you’ll find a reason to work with alphanumeric data individually in different ways. Let’s go through an example that I worked with recently that is not quite the Norm. The business unit I work with wanted to categorize a specific group of people into…
-
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…