I haven't used T-SQL. Here is a forum that may help
T-SQL Programming Part 1 - Defining Variables, and IF...ELSE logic
.
I have used PL/SQL which looks similar. I don't like having processing logic embedded within database calls or vice-versa. Doing this imposes limits on the scope for reusability. Still try and follow the same indentation rules I gave but refactor the SQL into another method if possible.
So how could you re-write this code ?
Hmmmm. While this example doesn't look messy with simple select count(*) statements it soon will with more complicated SQL. I would standardise on putting SQL in new methods / files that are easily traceable in the Development environment.Indented SQL looks like spaghetti after a while ; so personally I'd avoid indenting heavily.
regards
[ November 09, 2003: Message edited by: HS Thomas ]