Mark Cohen is a CIO at Australia's largest online retailer and is a hands-on, sleeves-rolled-up, code-cutting geek. He lives in Sydney, Australia with his wife and boys and can sometimes be spotted puffing and panting as he runs at Maroubra Beach

Archive for January, 2008

My boy turns four

This post’s one for the family. We had a little somebody’s fourth birthday party this weekend. I put the (shabby) video onto youtube, to see if I could share it. if all goes well you should see it here:

We had a jumping castle, scooters with little ramps to roll down, face painting, and other kid stuff to keep them busy.

happy australia day!


happy australia day!
And what a perfect day to be australian and in sydney. We’re at a rooftop pool in bondi, overlooking the beach. This is the life :-)
Blogged from my mobile

Fring rocks!

fring.pngOnce in a while I see something that wows me. Fring is one of those things. Fring is a free application that installs on your mobile, and brings together a host of services. I have it set up on my mobile to log in to my iinet voip service, skype and msn. This gives me the ability to make outbound calls using my SkypeOut (great for international), my voip (great for national) or my mobile service (great for mobile). In truth, choosing a service is probably already one step of effort more than I would take except for international, but having all the services unified on my mobile including a 02* (traditional landline / PSTN) phone number on my mobile blows me away.

The Fring website says “fring is compatible with Symbian 8, 9.1, 9.2, Windows Mobile 5 & 6 and UIQ handsets”. It installed on my Nokia N73 with no problems at all, and was a breeze to configure. I have 500MB a month included in my data plan with 3, so it will be interesting to see how quickly I burn through the 500MB using Fring.

Simple script to iterate through db objects

[Mostly just a "note to self" for next time, stating the obvious].

If you ever need to iterate through tables in SQL and perform an action here’s a simple script that will do the trick. This particular script will do a reindex on every table in the database.

DECLARE @Table NVARCHAR(100)
DECLARE @sql NVARCHAR(100)
DECLARE tables CURSOR
FOR
        SELECT
                name
        FROM
                sysobjects
        WHERE
                type = ‘u’
OPEN tables
FETCH NEXT FROM tables INTO @Table

WHILE @@FETCH_STATUS = 0
BEGIN
        SELECT @sql = ‘DBCC dbreindex (‘ + @Table + ‘)’;
        BEGIN TRY
                PRINT @Sql;
                EXEC sp_executesql @sql
        END TRY
        BEGIN CATCH
                PRINT ‘Error encountered executing:’ + @Sql;
        END CATCH
        FETCH NEXT FROM tables INTO @Table
END

CLOSE tables
DEALLOCATE tables

You could just as easily make this iterate through stored procedures, or any object type by changing the type = ‘u’ to say type = ‘p’ for stored procedures, etc. Also if you want particular objects then the where clause could include a clause saying AND name like ‘up_%’

You could also easily use something like this to generate scripts for sets of items based on a naming convention, say

DECLARE @Proc NVARCHAR(100)
DECLARE @sql NVARCHAR(100)
DECLARE Procs CURSOR FOR

SELECT
    name
FROM

    sysobjects
WHERE
    type
= ‘p’
    AND name like ‘report_%’
OPEN Procs

FETCH NEXT FROM Procs INTO @Proc

WHILE @@FETCH_STATUS = 0
BEGIN
    SELECT @sql = ’sp_helptext ‘ + @Proc;
    BEGIN TRY
        PRINT
‘IF EXISTS (SELECT * FROM sysobjects WHERE NAME = ”’ + @Proc + ”’)’
        PRINT ‘ DROP PROCEDURE ‘ + @Proc
        PRINT ‘GO’ + CHAR (10)
        EXEC sp_executesql @sql
        PRINT CHAR(10) + CHAR(10) + ‘GO’ + CHAR (10) + CHAR (10)
    END TRY
    BEGIN
CATCH
        PRINT
‘– // Error encountered executing: ‘ + @Sql + ‘ //–’;
    END CATCH
    FETCH
NEXT FROM Procs INTO @Proc
END

CLOSE Procs
DEALLOCATE Procs

Although for this to be useful you would need to run from command-line, or turn off results headings and use text results in SQL Management Studio