THE SQL Server Blog Spot on the Web
Welcome to SQLblog.com - The SQL Server blog spot on the web
Browse by Tags
Set based logic
Set based calculation of products of several numbers.
You can use SUM to calculate the sum of several numbers, but you cannot directly use set-based logic to calculate a product. Yet there is a very simple trick – you can use EXP(SUM(LOG(…))) and get a product of several numbers without a loop. The trick was originally posted on newsgroups by Tom Cooper. For example, suppose that you have to ...
March 17, 2009
Defensive database programming: eliminating IF statements.
The following pattern is quite common in database programming: IF EXISTS(some query) BEGIN DO SOMETHING; END When such code runs in high concurrency situations, it may not work as expected. I will provide a repro when such logic fails 40% of the time. The following script provides a test table and attempts to ...
November 27, 2008
Brought to you by