Reading Time: 3 minutesThe CAST() system function is one of the most useful tools we have available to us in Microsoft SQL Server. We basically use it to convert a value from one data type to another on-the-fly. I was using CAST() in a query recently and encountered an interesting problem. If you Continue Reading
SQL Questions
LEFT JOIN and LEFT OUTER JOIN: What’s the difference?
Reading Time: 2 minutesThe JOIN operations can be a bit tricky in Microsoft SQL Server. If you are new to SQL Server, you might be trying to understand the different JOIN operations and how they work. You probably have some basic questions you’d like answered. When I was first starting out with SQL Continue Reading
Do you understand this rule about SQL Server aggregate functions?
Reading Time: 4 minutesAggregate functions in SQL Server are usually fairly straightforward tools. We normally use them in a GROUP BY clause to present meaningful aggregate information about our data. I recently came across an interesting problem at work dealing with aggregate functions that I thought would make a great tutorial. I hope Continue Reading
Stored Procedure Output Parameters: A Guide for Beginners
Reading Time: 3 minutesStored procedures are some of the most complex objects we have available to us in Microsoft SQL Server. There are many tips and tricks you need to know when creating and using them in your databases. In this very brief tutorial, we’ll talk about one of the more confusing things Continue Reading
How to check if a column exists in SQL Server
Reading Time: 2 minutesSometimes, you want to execute certain SQL code only if you know that a specific column exists within a table. There is an extremely simple way to check if a column exists within a table in SQL Server: Use the COL_LENGTH system function! The syntax of the COL_LENGTH system function Continue Reading
Don’t make this mistake when calling your SQL Stored Procedures!
Reading Time: 3 minutesStored Procedures are complicated beasts in Microsoft SQL Server. There are many quirks you should be aware of when creating and calling them. In this very brief tutorial, we’ll talk about one of those wacky rules. Take a look at the following Customers and ContactInfo tables: We have a stored Continue Reading
SQL Server IS NULL: Why can’t I just use “= NULL”?
Reading Time: 4 minutesThe IS NULL predicate is a very useful thing to know when it comes to querying data and working with columns containing NULL. In this very brief tutorial, we’ll talk about why you need to use IS NULL instead of something like “= NULL” when checking if a value contains Continue Reading
How to get the data type of a return value in SQL Server
Reading Time: 3 minutesSometimes when writing T-SQL code (or code in any other language), it can be useful to know the data type of a value returned from an object. I was working on a tutorial recently where I wanted to show you the data type that was returned by an operation, but Continue Reading
How to create a table variable in SQL Server
Reading Time: 4 minutesIn this very brief tutorial, we’ll discuss how you can create a table variable in Microsoft SQL Server. Knowing how to create a SQL Server table variable can be very useful when querying data in a database. It is very simple, and there are only a few rules you need Continue Reading
What’s the difference between VARCHAR and NVARCHAR? Answered!
Reading Time: 3 minutesThere are four character string data types in Microsoft SQL Server. They are: CHAR NCHAR VARCHAR NVARCHAR You should definitely choose the best character string data type to suit your needs. But you might look at VARCHAR and NVARCHAR and wonder, what’s the difference? Well, in this very brief tutorial Continue Reading