Reading Time: 6 minutes Indexes are extremely important when it comes to writing queries that return data in an efficient way. We not only want to make sure our queries return exactly the information we need, but we also want that information to be returned to us quickly. In this brief tutorial, we’ll discuss the Continue Reading
Querying data
Don’t make this OUTER JOIN mistake!
Reading Time: 4 minutes The OUTER JOIN operations, such as LEFT JOIN and RIGHT JOIN, are very important to know when it comes to querying Microsoft SQL Server databases. There is one important factoid you should know if you are using an OUTER JOIN in combination with the IS NULL predicate. Let’s create a Continue Reading
How to remove trailing/leading whitespace in SQL
Reading Time: 2 minutes How do we remove whitespace from a character string in SQL Server? It’s easy, just use the LTRIM/RTRIM string manipulation function! Take the following silly example: We have a large amount of leading whitespace in our string. To remove that whitespace, we can put this string in the LTRIM system Continue Reading
SQL Server TRY_CONVERT: Explained with Examples
Reading Time: 2 minutes The SQL Server TRY_CONVERT system function is a great alternative to the standard CONVERT function. We use CONVERT and TRY_CONVERT to change an expression from one data type to another “on the fly“. This begs the question: What’s the difference? TRY_CONVERT will return NULL if the conversion fails. Here is Continue Reading
SQL Server CHOOSE: Explained
Reading Time: 3 minutes The SQL Server CHOOSE function is a simple decision structure you can use to simplify an otherwise complex expression. The syntax for CHOOSE is extremely simple: CHOOSE(<integer>, <expression1>, <expression2>,……<expressionN>) All you do it outline an integer as the first parameter, followed by a comma-separated list of expressions. The expressions can Continue Reading
SQL Server Ternary Operator: The IIF function
Reading Time: 2 minutes Believe it or not, SQL Server has a ternary operator like many other computer languages out there. Like other ternary operators, it can shorten the syntax of a very simple decision structure to just one line of code. The SQL Server ternary operator is the IIF function. Here is the Continue Reading
Dynamic SQL: Explained for Beginners
Reading Time: 6 minutes There may be times when you need to write a query and you need to make certain parts of that query dynamic, meaning the query might not be exactly the same every time you run it. SQL Server has a great tool we can use to create these dynamic queries. Continue Reading
The TOP 10 SQL Server String Functions You Should Know!
Reading Time: 8 minutes String manipulation is something you will likely find yourself doing at some point in your career as a database professional. Luckily, SQL Server has many great system functions we can use to make the task of string searching and manipulation very easy. In this week’s tutorial, we’ll cover the TOP Continue Reading
SQL Server TRUNCATE TABLE: Everything you need to know
Reading Time: 6 minutes The TRUNCATE TABLE statement is a simple statement that has a very singular purpose in Microsoft SQL Server. In this very brief tutorial, we’ll cover all the important information you need to know about the TRUNCATE TABLE statement. We’ll cover these topics: What is the SQL Server TRUNCATE TABLE statement? Continue Reading
SQL Server Logical Query Processing Order: Explained!
Reading Time: 3 minutes When executing a query, SQL Server will process the different clauses of that query in a very particular order. Other programming languages like C++ or C# will process code in a top-down manner. SQL Server does not work that way. Take a look at the following two tables, Products and Orders: Using Continue Reading