Controlling The Flow – Part 4

I am going to continue my articles (tidbits) on controlling the execution flow of statements in a Transaction SQL (T-SQL) program. Every program has to be deterministic on what step to execute next. Otherwise, the computer would be clueless on what to do next. The only exception to this rule is error handling. A runtime error may cause the program to branch to a error handler and exit the program. Today, I want to talk about how to use the GOTO statement. I never use this statement during my coding…

Controlling The Flow – Part 3

I am going to continue my articles (tidbits) on controlling the execution flow of statements in a Transaction SQL (T-SQL) program. Every program has to be deterministic on what step to execute next. Otherwise, the computer would be clueless on what to do next. The only exception to this rule is error handling. A runtime error may cause the program to branch to a error handler and exit the program. Today, I want to talk about how to use the BREAK and CONTINUE statements. I hardly ever use these statements…

Controlling The Flow – Part 2

I am going to continue my articles (tidbits) on controlling the execution flow of statements in a Transaction SQL (T-SQL) program. Every program has to be deterministic on what step to execute next. Otherwise, the computer would be clueless on what to do next. The only exception to this rule is error handling. A runtime error may cause the program to branch to a error handler and exit the program. Today, I want to talk about waiting a time period before executing a statement. The WAITFOR statement was introduced in…

Controlling The Flow – Part 1

I am going to write a few articles (tidbits) on controlling the execution flow of statements in a Transaction SQL (T-SQL) program. Every program has to be deterministic on what step to execute next. Otherwise, the computer would be clueless on what to do next. The only exception to this rule is error handling. A runtime error may cause the program to branch to a error handler and exit the program. Today, I want to talk about looping for repetition, statement blocks, and conditional execution. Some programming languages support the…

Using Variables

I am going to talk about Transaction SQL variables. Any stored program that does complex business processing will use one of more of variables to craft an algorithm. During my college days, I had to take a couple physics classes. Newton’s second law states that force is equal to mass times acceleration. The comic strip on the left shows how variables in the fourth picture can be used as place holders in a complex equation. This concept is key for crafting very complex programs. The DECLARE keyword is used in…

Logical Functions – IIF()

I am going continuing my short articles or tidbits on Transaction SQL logical functions. These functions were introduced with the SQL Server 2012 release. Both functions have their origins from Visual Basic for Applications (VBA) framework. I think of these function as decision trees. Especially when they are nested to several levels. If you have a kid like I do, you might find the decision tree for dropped food funny. Please see image to left. I will be exploring the IIF function today. The example below uses the RAND function,…

Logical Functions – CHOOSE()

I am going write a couple of tidbits on Transaction SQL logical functions. These functions were introduced with the SQL Server 2012 release. Both functions have their origins from Visual Basic for Applications (VBA) framework. I think of these function as decision trees. Especially when they are nested to several levels. If you have a kid like I do, you might find the decision tree for dropped food funny. Please see image to left. I will be exploring the CHOOSE function today. If you grew up like I did, you…

Pragmatic Works – Performance Tuning

I had the opportunity last week to attend the SQL Server Performance Tuning Workshop by Pragmatic Works Learning Center. I definitely recommend this workshop. This is the second class I have taken at the Microsoft New England Research and Development Center located in Cambridge, MA. It is conveniently located right off the Kendall station stop on the Massachusetts Transit Bay Authority (MBTA) Red Line. The main instructor for the class was Bradley Ball aka SQLBalls. He was a very likable speaker possessing good presentation skills as well as a wealth…