T-SQL Explode

July 6th, 2010 joe No comments

A feature I have used with much joy in PHP is the explode() function, which creates an array populated by a single parameter containing comma-separated values (CSV).  I recently had a desire to use the same approach in SQL Server programming (T-SQL) and push a set of CSV parameters into a temp table.  A slightly modified version of the function found here now allows me to do so!

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
/* select * from explode(’1,2,3′) */
CREATE FUNCTION [dbo].[explode] (
@CSVString VARCHAR(8000))
RETURNS @temptable TABLE (item VARCHAR(8000))
AS
BEGIN

  • DECLARE @pos INT;
    DECLARE @slice VARCHAR(8000);
    DECLARE @Delimiter CHAR(1);
    SELECT @pos = 1;
    SELECT @Delimiter = ‘,’;
    IF LEN(@CSVString) < 1 OR @CSVString IS NULL RETURN;
    WHILE @pos!= 0
    BEGIN

    • SET @pos = CHARINDEX(@Delimiter,@CSVString);
      IF @pos != 0
      SET @slice = LEFT(@CSVString, @pos – 1);
      ELSE
      SET @slice = @CSVString;

      IF( LEN(@slice) > 0)
      INSERT INTO @temptable(item) VALUES (@slice);
      SET @CSVString = RIGHT(@CSVString, LEN(@CSVString) – @pos);
      IF LEN(@CSVString) = 0 BREAK;

    END

RETURN
END

Categories: Code Tags:

New Hampshire??

April 24th, 2010 joe 4 comments

It always irks me when a blog post breaks an era of silence with an apology and ill-thought-through promise (“Sorry I haven’t posted in awhile, I will do much better starting today!”) so rather than admit to either, despite the appropriateness, I’ll just jump into some things that have been going on lately.

Julie, the kids, and myself, are at the end of day 2 of an extended weekend stay at a little place up in New Hampshire (think What About Bob) provided by my employer.  It’s not your typical “camping” experience – unless your camping experience involves flat screen tvs, a library of blu-ray movies, cable, wi-fi internet, and every possible kitchen and household appliance imaginable. However, many of these amenities make the trip much more endurable with 2 little ones. Some redeeming moments include an early-morning walk to the local beach to let the kids play in the water, a relaxing afternoon (where both Amelia and our friend Amara napped until past 4!), mountain biking down to the local grocery store for supplies (and adventure), and an evening of sitting around a campfire with marshmallow-sticks in hand and enjoyable discussion in the air.

This brief interruption into the well-structured machine of life has come at a great time. The kids are actually doing really well (even sleeping in the same room together!) and we get to just enjoy a few low-intensity days.

Categories: Family Tags:

Donahue Family Reunion

May 24th, 2009 joe No comments

IMG_5441Sara and Adam are visiting from England for a couple weeks, so we had the opportunity for a “Donahue Family Reunion.”  We all met down at Thornton’s for breakfast, along with my father-in-law, Amelia, and our friend’s daughter Alisha.  While there I happened across the most amazing corned beef hash I’ve ever had in my life.

We headed over to the house to pick up a desk for my office at the church.  It is a fantastic desk!  Thanks Mom!

We also all went out to Build-A-Bear at the mall.  Alisha got a Panda Bear named Ashley, and Amelia got a dog named Bear.   Sara picked out an outfit for it with — you guessed it — a sheep.

We don’t get the chance to all spend time together too often, so it was really good.  Tomorrow Julie, the kids, and myself will go down to South Portland for some Memorial Day grilling!

Categories: Daily Grind, Family Tags:

District Assembly 2009

May 14th, 2009 joe 1 comment

District Assembly 2009
This week is Maine District Assembly for the Church of the Nazarene down in South Portland.  It runs Wednesday through Saturday, and is an opportunity for all the pastors, leadership, and anyone else who has interest to gather together for a time of prayer, worship, fellowship, reports, and voting.  While it is certainly not a non-stop roller coasting of excitement… it has been a really encouraging and enjoyable time together.

I’ve had the good fortune to be invited to play music with the worship team(s), and have been switching between drums and acoustic guitar as necessary.  There have been some technical difficulties (my guitar was not heard through the sound system tonight) but it’s probably better that way.  It has been a meaningful time for me as I have played a lot of music in different groups over the last 10+ years, but have not had the chance to play with a good group of musicians in awhile.  These guys are excellent, and its just plain fun.

South Portland is also my home church, where I grew up and first discovered the love of Jesus, first discovered the joy of Christian fellowship, and first entered into Christian service.  I have run into many people who have been old teachers or friends and it was really meaningful to have their support tonight as I received my first district license.

Although not an extremely huge accomplishment in and of itself, there have been some challenges along the way that have made it a time of personal and professional validation for me.  To receive a district license, the only real requirement (or so I thought) was to hold a local minister’s license for one year.  I first received a local license from Southwood in Kansas City, where I expected to get my district license after one year.  Just after one year had passed (and before the Kansas City District Assembly) we were invited to return to Maine as an Associate Pastor.  We returned, and I immediately attended an interview with a district board (credentials, maybe?) where I was informed that I would not be recommended for my district license, as Maine required a class in Nazarene Polity.  Despite a four-year education at a Nazarene college, and 50% of an M. Div degree over three years at Seminary, I had never taken this particular class — so I would need to wait one more year.  At the District Assembly a couple months later, I was not recognized as one of the new incoming pastors on the district, presumably for this reason.  In the Fall of 2008 I completed this course at Seminary.

Which brings me to today — almost three years since I first recieved my local license, I was called up to receive my first district license.  Despite some adversity, which invariably brings with it the existential questions and doubt and the opportunity to give up, I was recognized as a new Pastor on the district.

It’s been a good couple days, and we have a couple days left.  I’ve “moved in” with my parents who are within walking distance of the church, leaving Julie and the kids so I don’t have to drive up late at night and drive down again the next morning.  She came down this evening, and I even got to hold Oodrew for a little bit.  Julie — you are so wonderful “for letting me play with the boys” (Roger Buzby’s words) and supporting me during this time.  I just hope you know how much I love you, and would not be who I am without you.

One more week until our 4 year anniversary :o )

Categories: Daily Grind Tags:

A Funeral Prayer

May 9th, 2009 joe No comments

n149000695_30516853_4311848

Today we held the funeral service for Julie’s Grandmother up in Strong, ME. I had the opportunity to participate and say a closing prayer, from which I have included an excerpt below.

What shall we say to a God who provides what we cannot provide for ourselves?

Your word reminds us that you stand at the door of our hearts and knock. You call out to us in the midst of the chaos and grief in our lives. To all who have accepted your love, we eagerly anticipate the day when we shall stand at your door, O God, and hear you beckon, “Well done, my good and faithful servant.”

To the God who provides what we cannot provide for ourselves, we say “Thank You.”

There is something about “Thankfulness” that continues to be something I draw from and meditate on almost daily. Ever since digging into Eucharistic thought and significance at Seminary (or perhaps simply as I “grow up” and experience more heartache and loss in life), I am finding that the very core of my faith and life is living out a response of thankfulness to the goodness and grace of God. Each day, each meal, each conversation is an opportunity to Remember and lift the chalice of Eucharist (figuratively speaking) for a life that abundantly exceeds anything I could have cobbled together on my own.

Thanks be to God!

Categories: Daily Grind, Theology Tags:

And… we’re back!

May 7th, 2009 joe 2 comments

Got my website back up-and-running today after a brief hiatus.

A couple of recent items:

* Spring is here. As evidenced by this really cool picture of Amelia.

* I submitted my final paper for Joshua.  I start my summer SME next week.

* Last week I got to play guitar and rock out with Roger Buzby. Next week we will play a few sets for District Assembly in South Portland.

Categories: Daily Grind Tags:

What Joe Needs

March 9th, 2009 joe No comments

1. Do a web search for “[your name] needs” including the quote marks.
2. Write down your favorite results.
3. Tag 10 friends.

1. Joe needs some sleep
2. Joe needs to learn how to write proper
3. Joe needs a prayer
4. Joe needs a blog
5. Joe needs to come to Jesus
6. Joe needs to stop it already
7. Joe needs to seriously consider a career change
8. Joe needs your support
9. Joe needs an attitude adjustment
10. Joe needs to keep quiet

Categories: Uncategorized Tags:

Meet Andrew.

March 2nd, 2009 joe No comments

Although I usually refrain from writing about “family” stuff (at least since Julie launched her own independent, competing blog!) it would be appropriate to write a little note about our newest addition – Andrew James Donahue.

Andrew was born in Portland, ME last Monday at 6:30pm, weighing in at 9lbs, 7oz.  We ended up doing a repeat c-section after 20 hours of in-hospital labor, and stayed there until Thursday.  He was born with low blood sugar (not unusual for bigger babies) so they  immediately fed him formula – and they needed to prick his foot to test again before each feeding for the first couple days.  He is now doing great, and Julie is recovering really well also (although she can’t drive anywhere for 4 – 6 weeks while she recuperates).

Amelia is having a rough time adjusting, but she has also had to deal with being away from us for the whole week (she stayed with Julie’s parents) and is teething again — she is drooling, has a runny nose, eats her fingers, and spends 90% of the days in tears.

For more pics, check out Facebook or Flickr.

Categories: Uncategorized Tags:

Completion.

February 1st, 2009 joe 1 comment

Every night I pick up my to-do list, mourn how nothing on it is fixed or completed, and begin to add even more items to it.  It has become more and more diffcult to end each day with a profound sense of “incomplete” in my life – nothing getting finished, while more and more things require attention.

Today brought with it the completion of several outstanding items.

1. Bottle Drive.

We had a bottle drive for our teens.  While not technically an unresolved task-list item, it was an event that feels remarkably successful, and there is a certain amount of dread and fear that accompanies even the smallest youth event. Completed.

2. Cable Wiring.

Every year the church rents a big-screen tv for a superbowl party, and we enjoy a great time of food and fellowship.  After the Superbowl last year, I got to thinking about how we could splice our cable and run it to the church for this event – and tonight I completed it.  It involved a ditch witch, 200 ft of underground cabling, and more RG6 splitters, connectors, and crimp-style terminators than you would believe.  Can I register for a Crimping tool in a baby registry?

3. Firefly Imageworks Persistent Cart

I’ve been doing some application development for Firefly Imageworks on-and-off (mostly off.. sorry d.j!) but completed the bulk of a Persistent Cart tonight.  I built the major portion of the Cart mechanism back in August, but some major work was left incomplete… until today.

We’ll see how much more I can get done before The Boy gets here in about 3 weeks!

Categories: Uncategorized Tags:

Guitar Hero World Tour

September 25th, 2008 joe No comments

I did some research (“googling”) last night and discovered that the latest installment of Guitar Hero – dubbed “World Tour” can already be pre-ordered and is set to release at the end of October.  It will include a new guitar, an electronic drum kit, and a microphone, a la Rock Band.

The song list includes Foo Fighters, The Killers, Weezer, The Eagles… and Blue Oyster Cult.

I hope it comes with a cowbell, too.

More info at http://www.guitarhero4.com.

Categories: Uncategorized Tags: