Dave Brookes sent me some T-SQL from a system he inherited. It got me thinking ... why didn't I think of this before? Thinking back, all of the systems I developed have had lots and lots of subroutines and functions, each one doing it's own discrete task. What a mess! Looks like Dave's colleague is way ahead of me ... 

CREATE PROCEDURE spCustomerList2
(
  @name     varchar(50),
  @option   varchar(1)
) AS
-- SQL ommited to avoid boredom

IF @option = '1' 
-- Returns Customer Summary info where @name actually contains the customer name


IF @option = '2' -- Returns Customer Name and Location where @name contains the contract number IF @option = '3' -- Returns Customer Name where @name contains a group number IF @option = '5' -- Returns Customer Group where @name conatins the RegionId IF @option = '6' -- Returns Customer Name where @name contains the CustomerId IF @option = '7' -- Returns all Region records IF @option = '8' -- Returns Group info where @name contains GroupId IF @option = 'B' -- Returns a single record from a table with only 1 record!! IF @option = 'Z' -- Returns all Period & Date records IF @option = 'C' -- Returns Region record where @name contains the RegionId IF @option = '9' -- Returns Customer Record where @name contains the customer name.

As you may or may not have noticed, the site was acting a bit strange earlier today (especially the RSS feed). This was a result of switching from .TEXT (blogging software) to Community Server (messageboard software). As you may tell, we're back on .TEXT now, as the transition didn't go over so well. Hopefully within a few days we'll be back on Community Server with much longer RSS feeds!

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!