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 http://steelcitysql.org/default.aspx

Birmingham Software Developers Association http://www.bsda.info/

Birmingham .Net User Group (BUG.NET) http://www.bugdotnet.com/

Internet Professional Society of Alabama (IPSA) http://ipsaonline.org/

Birmingham UX Group (User Experience) http://groups.google.com/group/bhamux?hl=en

SOA Society (Service Oriented Architecture) http://soasociety.com/

Birmingham Microsoft Management Users Group http://www.myitforum.com/groups/group81/

RubyHam – Birmingham Ruby Users Group http://tech.groups.yahoo.com/group/rubyham/

TechBirmingham Listing of Technology User Groups http://techbirmingham.com/default.aspx?id=117&linkAction=showcat&catid=1&cat=Technology%20Association%20/%20User%20Group

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 ;

go

 

/*—————————————————————————-*/

/* 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. */

  ) ;

go

 

/*—————————————————————————-*/

/* 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 sys.schemas.name + ‘.’ + sys.objects.name

      from    sys.objects

            , sys.schemas

      where   object_id > 100

              and sys.schemas.name = @schemaname

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

            –and sys.objects.name = ‘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 )

  begin    

    insert into #TableSizes

            exec sp_spaceused @objname = @name ;       

    fetch curSchemaTable into @name ;   

  end

 

– 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

https://www.clicktoattend.com/invitation.aspx?code=124185

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, southerntinkerbelle.com. 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.

Follow

Get every new post delivered to your Inbox.

Join 101 other followers