Most of us have used the REPLACE function several times in our daily lives. This function, as you may remember, takes one string and replaces it with another, as seen below: Please don’t do this change in Production There is another function within SQL Server that many people think does the same thing, but with…… Continue reading Doing Something with the REPLACE function
Author: Kevin
Unicode Data and Keeping DBAs Happy
In our last session together, one of the many items we talked about was the fact that I asked that you use the DATALENGTH function instead of the LEN function because you could be using UNICODE data. The LEN function is used in SQL to find out – surprise, surprise – the length of a…… Continue reading Unicode Data and Keeping DBAs Happy
Padding Data In Multiple Ways
One of the many fun things we’re asked to do as a person who works with data is that we’re asked to do some manipulation of data – especially when we’re asked to pad data with 0’s to make a string longer that is numerical. For example, I’ve been asked many times to provide data…… Continue reading Padding Data In Multiple Ways
Checking Against Multiple Fields The Easy Way
A lot of times, you’re asked to find where two different tables have the same data. Thankfully, this is a fairly normal ask. Sometimes, though, you’re asked to see if they have the same data in 20 – 30 fields! I don’t know about y’all, but I definitely don’t want to have to type in…… Continue reading Checking Against Multiple Fields The Easy Way
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. Checking if equal…… Continue reading Analogous Strings and Validation Thereof
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…… Continue reading Getting Strings to Work Like You Think They Would
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…… Continue reading Looking for Strings A Different Way
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…… Continue reading Matching Strings within One Big String
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. Norm! The business unit I work with wanted to categorize a specific group of people…… Continue reading Making Letters Do What Want
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…… Continue reading Making Numbers Look Better