Ran across an interesting approach to generating insert statements for SQL Server 2005 (and other variants). If uses a less well known function called master.dbo.fn_varbintohexstr. The approach that was taken was to use the fn_varbintohexstr function to encode the data so you did not need to use cursors or any fancy parsing to handle unicode and quotes in the generated … Read More
Calculating Age in T-SQL
Here’s a decent article on calculating the age of a person (or anything else) written by Lynn Pettis. Discusses some pitfalls with leap years.
Using and Managing SQL Server Aliases
I know that not many people I have met in my SQL Server experience have used SQL Aliases. In many ways it is one of the most useful features of SQL Server. Roman Rehak wrote a great article about SQL Server Aliases. You have to be registered to see the full article, but some of the highlights are discussed below. … Read More
Pivots with Dynamic Columns in SQL Server 2005
Found a great article at www.simple-talk.com which described how to create pivot queries with dynamic column names. It seems simple at first until you try to adjust your columns manually and then discover that you really need to implement some special code to accomplish the task. The article Pivots with Dynamic Columns in SQL Server 2005 provides just the right information to … Read More