Birmingham User Groups

Birmingham is blessed with a wide variety of user groups. I’m doing a brief presentation today at our internal company user group. Do you have a lot of developers that work for your company? Maybe you should start your own user group. It’s a great place to meet with other developers in your organization, make new friends, and learn a few new techniques. But enough on that, here’s a list of just a few of the user groups in this area. The last link goes to the TechBirmingham site which has a comprehensive list of user groups in the Birmingham area.

Steel City SQL – SQL Server User Group

Birmingham Software Developers Association

Birmingham .Net User Group (BUG.NET)

Internet Professional Society of Alabama (IPSA)

Birmingham UX Group (User Experience)

SOA Society (Service Oriented Architecture)

Birmingham Microsoft Management Users Group

RubyHam – Birmingham Ruby Users Group

TechBirmingham Listing of Technology User Groups

Upcoming Events

Just thought I’d fill you in on some of the upcoming user events in the Birmingham area. February is shaping up to be an active month for tech in Birmingham! Follow the links for more info on any of these events you are interested in.

VS2008 Seminar / Geek Dinner – Feb 4, 2008 – Doug Turnure and Chad Brooks will be doing a VS2008 seminar in Jackson MS, then a Geek Dinner in Hattiesburg MS.

BSDA – Feb 7, 2008 6:30 pm – Doug Turnure of Microsoft will be speaking on Visual Studio 2008. Geek dinner afterward!

Microsoft TS2 Event – Feb 7, 2008 1:00 pm – Event showcasing Windows Server 2008 and SQL Server 2008.

IPSA – Feb 8, 2008 11:30am – Jere Chandler will be speaking on Simplicity in Design.

Huntsville User Group – Feb 12, 2008 – 6:00 pm – Yours truly will be giving the presentation on SQL Server 2005 Full Text Searching

TechMixer Expo – Feb 12, 2008 5:30 pm – Birmingham’s Tech Event – TechMixer Expo is back! Come mingle with IT’s Finest.

Steel City SQL Group Meeting – Feb 19, 2008 – Join the group for it’s first program meeting of the year

Alabama Code Camp – Feb 23, 2008 – This time Huntsville will play host city to the Alabama Code Camp. Registration is now open!

Getting Table Space Usage in SQL Server 2005

I had the need to determine how much space was being used by each of my tables in a certain schema. I found various solutions on the web, most of which involved the built in system stored procedure sp_spaceused. However none of them produced the output quite like I wanted it. Most worked on a single table, or else produced the output in multiple returns. So I did what comes naturally and cobbled together my own solution.It’s fairly straight forward. I create a temp table to hold the output, then create a cursor to cycle through all the table names in the schema set in the variable @schemaname. I set it to the most common one, dbo, but you may wish to change it. Next I cycle through each of the tables using a cursor and for each one call the sp_spaceused and insert the output as a new row in my temp table. Finally I select the results back to the user and drop the temp table to clean up.

You may note I check to see if the temp table exists as the very first thing, then if it is I drop it. Then as the last step I drop it. Call it paranoid programming, if something crashes part way through the routine I wanted the code to be “self repairing”, i.e. I didn’t want to have to remember to run the drop table statement just to start the procedure all over.

Also, you may have read somewhere that cursors in SQL Server are “evil”. Well, as a general rule you should avoid them in favor of set based coding. However there are times, such as this when I need to call a stored procedure for each row in the cursor, that a cursor will solve the issue nicely. Additionally this isn’t code I’m going to be running 500 times a day on a production server, but instead just occasionally as a system monitor type of utility.

You may notice that most of the columns are all returned as strings (varchars). That’s because the stored procedure returns them in that way. I may go back later and modify this to convert them to numbers so I can do some math, but we’ll see if that need arises.

Here’s the code, use it and abuse it, modify it and enjoy it!


**    File: “GetTableSpaceUseage.sql”

**    Name: Get Table Space Useage for a specific schema

**    Auth: Robert C. Cain

**    Date: 01/27/2008


**    Desc: Calls the sp_spaceused proc for each table in a schema and returns

**        the Table Name, Number of Rows, and space used for each table.


**    Called by:

**     n/a – As needed


**    Input Parameters:

**     In the code check the value of @schemaname, if you need it for a

**     schema other than dbo be sure to change it.


**    Output Parameters:

**     NA



**        Change History


**    Date:            Author:                Description:

**    ——–        ——–            —————————————





/* Drop the temp table if it’s there from a previous run                     */


if object_id(N‘tempdb..[#TableSizes]’) is not null

  drop table #TableSizes ;




/* Create the temp table                                                     */


create table #TableSizes


    [Table Name] nvarchar(128)   /* Name of the table */

  , [Number of Rows] char(11)    /* Number of rows existing in the table. */

  , [Reserved Space] varchar(18) /* Reserved space for table. */

  , [Data Space] varchar(18)    /* Amount of space used by data in table. */

  , [Index Size] varchar(18)    /* Amount of space used by indexes in table. */

  , [Unused Space] varchar(18)   /* Amount of space reserved but not used. */

  ) ;




/* Load the temp table                                                        */


declare @schemaname varchar(256) ;

— Make sure to set next line to the Schema name you want!

set @schemaname = ‘dbo’ ;


— Create a cursor to cycle through the names of each table in the schema

declare curSchemaTable cursor

  for select + ‘.’ +

      from    sys.objects

            , sys.schemas

      where   object_id > 100

              and = @schemaname

              /* For a specific table uncomment next line and supply name */

            –and = ‘specific-table-name-here’    

              and type_desc = ‘USER_TABLE’

              and sys.objects.schema_id = sys.schemas.schema_id ;


open curSchemaTable ;

declare @name varchar(256) ;  /* This holds the name of the current table*/


— Now loop thru the cursor, calling the sp_spaceused for each table

fetch curSchemaTable into @name ;

while ( @@FETCH_STATUS = 0 )


    insert into #TableSizes

            exec sp_spaceused @objname = @name ;       

    fetch curSchemaTable into @name ;   



— Important to both close and deallocate!

close curSchemaTable ;     

deallocate curSchemaTable ;



/* Feed the results back                                                     */


select [Table Name]

      , [Number of Rows]

      , [Reserved Space]

      , [Data Space]

      , [Index Size]

      , [Unused Space]

from    [#TableSizes]

order by [Table Name] ;



/* Remove the temp table                                                     */


drop table #TableSizes ;

Visual Studio 2008 Loadfest – Birmingham

On Thursday night, January 24th 2008 the BUG.NET group in conjunction with Microsoft is sponsoring a Visual Studio 2008 Loadfest. Bring your laptop or desktop and lets load VS 2008 on it! The first 75 people to register will get a free copy of VS2008. In addition there will be some fun and games, there will be several XBox 360’s and huge TVs to play games on. (Sorry, no give aways of the XBoxes or TVs, but you still get to have fun with them.)

The event will begin at 6:30 pm across from the New Horizons training center,  and will last about 2 hours. (See the link below for more details and directions).

To attend and get your free copy of VS2008 you must register! Go to

No cost, but like I said you must register. See you there!

Feng Shui and the Art of Development

I’m not a big proponent of Feng Shui. For those unfamiliar with it, Feng Shui is a Chinese philosophy that essentially says that the placement of your furniture can have a big affect on your health and prosperity. Like a lot of things, something that starts off as a good idea seems to me to be carried too far. I do however firmly believe that your physical environment can have a dramatic effect on your mental environment. I saw a blog posting by Scott Hanselman describing his new home office layout. It was then that I realized something important: my own home office no longer worked for me.

I’ve been in my house eight years now. Like a lot of folks, I accumulate a lot of things related to my work / hobby. Books, computers, CDs/DVDs, and gadgets galore. It probably doesn’t help that my home office is also my ham radio “shack”, the place that contains all my radios, books and associated gear. For some time now I’ve been pretty unhappy with my basement office, having problems concentrating, etc. It had even gotten to the point where I had no place to even lay a book and reference it while working. After reading Scott’s post I immediately realized what my problem was: my environment.

Unfortunately December and early January were a bit hectic, what with my wife’s health problems and work, I haven’t had much spare time. Well, this weekend good luck finally arrived. My wife is healing very nicely and is much more self sufficient. We had snow, which made going out impractical, so it was the perfect opportunity. I pulled nearly everything out of my office, placed a lot of my “junk” into storage and relaid out the tables I use for working.

I’m typing now from my reconstructed office. A lot of the spare parts I had accumulated are gone, boxed up and placed in the storage area under the stairs. A lot of old catalogs and magazines hit the trash, many of the books I seldom reference were moved to another area of the house that had space. I now have plenty of space for my computer and can finally have all three monitors laid out side by side. I have a workspace now, somewhere to put the book I’m using for learning or reference. In addition, the moving of old books gave me space to put away my new books. I was able to do a little shuffling so the books I currently reference the most were on the lower shelf within arm’s reach, instead of piled on the floor.

Once again my office feels like a safe place to learn. When it comes to your office, whether it be your desk at your employer or your desk at home, don’t overlook your environment. Everyone has their own style. Look around your office right now. Is it comfortable? Quiet? Can you think effectively? Are the tools you need close at hand? If you answered any of these “no”, then start thinking about what you can do to make your home office a refuge, a safe place to work and learn. Then go do it.

Arcane Fun Fridays – Broadcast your Podcast

A little fun tip for today’s post. As long time readers know I love podcasts. They are a great way to capitalize on time, learning while doing other activities. As I was puttering around the house, I wished I had an easy way to listen to my podcasts without having to use my headphones, and also be portable. Then it occurred to me, I did.

When I drive back and forth to work, I use a cassette adapter to plug into my cheapy mp3 player into the my old car’s stereo and listen to my podcasts. Sometimes I travel on business, and these days it’s seldom I get a rental car with a cassette, so I picked up an inexpensive radio transmitter, similar to this one but a heck of a lot cheaper. Well, being an amateur radio operator (often called “ham radio”) I have a wide variety of power supplies lying around. I dug into my box and found one kind of like this. I mated them up, found an unused frequency, and plugged the other end of the transmitter into the speaker jack of my computer and boom I was listening to my podcasts through my various radios. Very nice, and I can see a lot of use.

I was pleased too with the range, I can hear it all over my house and even into my yard a bit. I could probably get a bit more range moving it out of my office basement.

One last hint for today, next time you go to various stores keep an eye out for a “clearance” area. They are usually tucked away in the back corner of the store, often near the restrooms. I know I’ve seen them in Staples, Radio Shack, Office Max and Office Depot to name a few. You can get some really good deals, for example I picked up my transmitter for 10 dollars, marked down from the original 49 bucks. Also check out sites like woot for “deal of the day” specials.

Life in Tinkie Land

My wife wrote a rather long post over on her blog, She detailed her hospital stay from her point of view. I thought the whole thing was rather surreal, although I did think it extremely cool the hospital had free wi-fi. Let me keep myself occupied with my laptop while she slept.

I know I sound like one of those typical husbands when I say this, but I never quite realized how much she dealt with on a daily basis until I tried to do it for her, and hold down my regular job, not to mention taking care of a wife recovering from surgery. Fortunately my work was very nice and let me telecommute last week which made life a bit easier for all of us.

I should probably try and draw some sort of metaphysical parallel between  the whole event and software development, but frankly I’m just glad she’s on the mend and doing much better.

SOA Society Meeting

Just thought I’d let you know of more doings in Birmingham. The SOA Society will hold it’s first meeting of 2008 next Tuesday, the 22nd. SOA stands for Service Oriented Architecture, a methodology for integrating IT and Business. That’s a pretty broad simplification, to learn more about SOA you’ll just have to come to the meetings!

See the Society’s website at for more info.

VS 2008 Technical Overview

Just thought I’d pass along an upcoming event, on Thursday January 17th 2008 Doug Turnure will be presenting a technical overview of Visual Studio 2008 at the IPSA (Internet Professional Society of Alabama). Doug’s will be talking about new features and designers in VS2008, LINQ, and will even be giving away a couple of copies of VS2008. RSVP ahead of time at the IPSA site, especially if you want to purchase a lunch.


Where’s Waldo?

I have been a bit absent of late with the blogging. I just thought I’d take a second to explain. Last week my beloved wife had some pretty serious abdominal surgery. She’s going to be fine, but for a bit I’ll be playing both Mommy and Daddy, taking care of the kids, doing housework, etc. Thus my spare time for blogging, learning new technology and other geeky pursuits is quite limited.

I did have one pleasant surprise, during the three day hospital stay (yes I stayed with her) I found the hospital had free public wi-fi. When she was napping I was able to get out my laptop and handle a few work items, and communicate to the extended family about her condition. It was a nice “extra” that made the stay that much better.

It got me to thinking, there are a lot of places I go that it would be nice to have that free wi-fi access. Anywhere that you spend a lot of time, or need to do some sort of research. Around here I know several restaurants and coffee shops with it, as well as all the public libraries. There should be more though. One bookstore chain has wi-fi, but charges for it, another doesn’t have it at all. I mean, come on wi-fi doesn’t cost that much, and I would certainly be paying for it through my store purchases.

Doctors offices are another place I wish I had it, often you can spend hours waiting on a doctor. Sure would be nice to be able to check e-mail and let the office know “I’ll be here a little longer…”

What other public locations can you think of that you’d love to have some wi-fi in?

Does MacGyver Dream of Mark Miller?

For Christmas this year my family gave me a copy of MacGyver, Season 1 and 2 on DVD. My wife’s side of the family gave me a gift card which I used to get seasons 3 & 4. I’m a long time MacGyver fan, but my wife had only seen one or two episodes and my kids had never seen it at all, so we’ve been having a lot of fun watching. My favorite part of the series was the voice-overs, where you’d hear MacGyver’s voice as he explained what he was doing. It always started with some odd thought or story that led you through the thought process of how he came to the conclusion to build whatever wacky life saving device he was constructing.

I’ve come to realize in some ways these blog entries are sort of like the MacGyver voice-overs, my inner thoughts being created for you on the web. So I hope you’ll bear with me a few minutes while I relate a rather bizarre dream I had last night.

In my dream I’m standing on stage, in front of a fully loaded computer. It has all the bells and whistles, VS2008, SQL Server, and so on. On the other side of the stage, Mark Miller is there, in front of a similar computer. For those unfamiliar with Miller, he’s the genius behind CodeRush and RefactorPro, tools to help you write code faster. Some time back, when the product was first released Miller used to challenge the audience to beat him in a code writing contest. His machine had CodeRush, and he would use chopsticks to write code, his competitor could use their fingers but did not have CodeRush on their machine. Of course Mark always won.

So sure enough, in my dream there’s Miller, chopsticks in hand ready to go, and I’m the guy going up against him. Our task is to take data from table A1, create a mirror table and name it table A2, and then move all million rows from A1 into A2. As you might guess, in my dream, I win. How?

Well I didn’t write a program. Instead I first jumped into SQL Server Management Studio (SSMS) and used its script generating capability to produce a create table script. Make a quick search and replace and boom I’ve got table A2 created. I then jump over to the Business Intelligence Developer Studio (BIDS) to create a SQL Server Integration Services (SSIS) package to do the data move. (Yes, I probably could have used the script generation of SSMS again to generate an Insert script, but I was showing off.) In about three to four minutes I had accomplished the task and moved all the data while Miller was pecking away at computer with his chopsticks.

I didn’t win because I’m a hot shot coder who is smarter than my competitor. Miller is a (some say mad) genius who can run circles around me in the coding world. As I told the folks in my dream, and I’m telling you now sometimes the best solution to a programming challenge isn’t to program at all! If you read yesterday’s post, Straining at Gnats, you may recall I said “…take some time. Push back from your computer and think for a moment. Think what the true outcome of your application is supposed to be. Not “what will the program do” but “what will the program do for the user???” Think about how best to achieve the user’s goals.

When you are thinking about solutions, take a minute to look outside of your favorite programming language. Is it possible to achieve the goal without writing any code at all? What tool or tools do you have in your tool box that you can combine to get the job done? Here’s a great example that happened to me just before I took off on my holiday vacation.

As I’ve mentioned before at work we have a Business Intelligence (BI) app I work as the lead on, it imports data to a SQL Server 2005 warehouse via SSIS then uses SQL Server Reporting Services (SSRS) to generate reports. The data is imported from a work order management system we bought many years ago. We also have some engineers who have a tiny little Microsoft Access database. This database has a primary key column; we’ll call it a part number for purposes of this example. There are three more columns, some data they need to know for each part but are not found in our big system. They’d like to add this data to the reports our BI app generates. Two last pieces of information, they only update this data once per quarter. Maybe. The last few years they have only done 3 updates a year. Second, the big system I mentioned is due to be replaced sometime in the next two years with a new system that will have their three fields.

A lot of solutions presented themselves to me. Write an ASP.Net app, with a SQL Server back end then use SSIS to move the data. Elegant, but a lot of work, very time consuming for a developer, especially for something that can go away in the near future. Write an SSIS package to pull data from Access? Risky, since we had no control over the Access database. A user could rename columns or move the database all together, in either case trashing the SSIS. Several other automation solutions were considered and rejected, before the final solution presented itself: not to automate at all.

Once per quarter I’ll simply have the engineers send me their Access database. Microsoft Access has a nice upsizing wizard that will move the table to SQL Server, I’ll use that to push the data onto the SQL Server Express that runs on my workstation. I’ll then use the script generating capability of SSMS to make an Insert script for the data. Add a truncate statement to the top to remove the old data and send it to the DBA to run. When I ran through it the first time my total time invested was less than ten minutes. In a worst case scenario I spend 40 minutes a year updating the data so it’s available for reporting. That’s far, far less time that I would have spent on any other solution.

The next time you have a coding challenge, take a moment to “think like MacGyver”. Look at all the tools you have lying around your PC and see what sort of solutions you can come up with. Once you are willing to step outside the comfort zone of your favorite coding language, you may be able to come up with some creative, MacGyver like solutions to your user’s problems.


PS – If you missed the announcement while on vacation, DevExpress just released CodeRush / RefactorPro 3.0. More than 150 refactorings and lots of new CodeRush features! Update yours today.