NULL behavior in three valued logic
SQL uses three valued logic (true, false, or unknown). This is important when dealing with NULL as a query may not return the desired results. This MSDN article provides an excellent definition of...
View ArticleSorting software versions
There may be a time where a software version is stored as a string. In order to sort it, it will need to be broken up into its individual parts (major, minor, patch and build) and then sorted. Let’s...
View ArticleWhy can’t I use my aliased column in the WHERE clause?
A query will fail when a column is aliased and then referenced in the WHERE clause. SELECT col1, col2 AS c2 FROM tbl1 WHERE c2 BETWEEN 2 AND 6 This query will throw the error: Msg 207, Level 16, State…...
View ArticleImporting CSV with optional double quote text qualifier
In this post, I hope to show how to load in a CSV (comma-separated values) flat-file with an optional double quote (") text qualifier and a XML format file using BULK INSERT and OPENROWSET. The sample...
View Article