Predicate ordering is not guaranteed

A typical programmer may expect that the predicates are always evaluated in the order that they are specified, but this is not true in database systems. For example, for the following clause,  where col11 = 5 and convert(int, col2) = 100 programmers may think col11 = 5 is always evaluated first, but this is not…

2

An article on FOR XML in Microsoft SQL Server 2000 and 2005

I just posted an article What does server side FOR XML return? (http://blogs.msdn.com/sqlprogrammability/articles/576095.aspx) which gives some details of the design and performance characteristics of various FOR XML flavors.   I also added links to XML whitepapers and publications on the design of XML features in Microsoft SQL Server 2005 to the links section of the…

0

What does server side FOR XML return?

XML publishing functionality exposed as “FOR XML” in Microsoft SQL Server 2000 evolved quite a bit in SQL Server 2005. So, I thought I would document the matrix of what FOR XML results in. This article should help understand some performance characteristics and limitations of FOR XML as well as the difference between the following…

1

Sorting undefined characters in Unicode and/or Windows collation

When comparing two Unicode strings in non-binary collations, SQL Server uses a library that is essentially same as the Windows API CompareStringW. It defines a weight for each recognized character, and then use the weights to compare characters. However, not all code points are defined in the sorting library. They may be undefined because:  …

1

Multiplication and Division with Numerics

It can be surprising to see certain results when doing numeric arithmetic: declare @num1 numeric(38,10)declare @num2 numeric(38,10)set @num1 = .0000006set @num2 = 1.0select cast( @num1 * @num2 as numeric(38,10)) Yields:             .0000010000 Instead of:      .0000006000 Why? Well, Books Online (see Precision, Scale, and Length) dictates the following rule for numeric arithmetics: Operation Result precision Result scale * e1…

1