In SQL Server, you can convert any lowercase string to uppercase by using the UPPER()
function.
To use it, simply pass the string as an argument when calling the function.
In SQL Server, you can convert any lowercase string to uppercase by using the UPPER()
function.
To use it, simply pass the string as an argument when calling the function.
In SQL Server, you can convert any uppercase string to lowercase by using the LOWER()
function.
Simply provide the string as an argument when you call the function, and it will be returned in lowercase form.
If you ever find yourself wanting only the first part of a string, or the last part of it, this article might help.
This article is specific to SQL Server, but the functionality is pretty common across most/all database management systems, not to mention most programming languages.
When working with SQL Server, you can use theT-SQL LEFT()
and RIGHT()
functions to return any given number of characters from the left or right of a string.
Starting from SQL Server 2008, the REVERSE()
function can be used to reverse the order of a string. That is, it returns the characters in the string in reverse order.
Here’s the syntax:
REVERSE ( string_expression )
Where string_expression
is an expression of a string or binary data type. It can be a constant, variable, or column of either character or binary data.
When working with databases and the associated data, sometimes you need to insert a space when joining two strings together, or sometimes you need to replace a character with a space.
And then sometimes you need to insert multiple spaces. Here are 3 ways to return a string of multiple spaces in SQL Server using T-SQL.
In SQL Server, the TRIM()
function is commonly used to remove leading and trailing whitespace from a string. But did you know that you can also remove other characters from the start/end of a string? It doesn’t have to be whitespace.
TRIM()
is a T-SQL function that specifically removes the space character char(32)
or other specified characters from the start or end of a string.
In SQL Server, you can use the TRIM()
function to remove leading and trailing whitespace from a string.
TRIM()
is a T-SQL function that removes the space character char(32)
or other specified characters from the start or end of a string.
In SQL Server, we can use the RTRIM()
function to remove trailing blanks from a given string. Trailing blanks are white spaces, tabs, etc that come at the end of the string.
Leading whitespace is a common issue when working with data. A leading whitespace is a space at the start of a string. In most cases, we don’t want any leading whitespace, and we will want to remove it before the data goes any further (whether that means being stored in the database, displayed to the user, or whatever).
Fortunately, SQL Server provides us with the LTRIM()
function that allows us to remove leading blanks from a given string.
This article presents two ways to select rows based on a list of IDs (or other values) in SQL Server. This can be useful in scenarios where you have a comma-separated list of IDs, and you want to query your database for rows that match those IDs.
Say you have the following list of IDs:
1,4,6,8
And so you now want to query a table for records that have any of those values (i.e. either 1, 4, 6 or 8) in its ID column.
Here are two ways to go about that.