Wednesday, November 14, 2012


Little knobbly beings :)

In answer to a knitter's call.
(They were escaping from their box!).

Friday, October 26, 2012

Changing Time!

For those wondering if their jobs will run twice (or not at all) because of the daylight time changes in the next few months, here are a couple of links to help

Daylight Time and SQL Server Jobs

and for those using SQL Server 2005 and 2000,

Preparing for Time Changes


Friday, October 19, 2012

I'm counting out time, hoping it goes like I planned it

Title courtesy of Genesis ("The Lamb Lies Down On Broadway").
[Tech Stuff]
A somewhat strange title, you might think, but I just had the task of re-writing a couple of T-SQL functions that calculate times. Numbers of days in an interval, to be more precise. Someone had either written or copied a solution that was kind-of working; I needed the real right answers.

Here's the version for calculating weekdays inclusive between two dates. The "inclusive" means that if you're asking "how many days from Tuesday to Thursday" you really mean "how many days work from the instant that Tuesday begins to the very last moment in Thursday - all 72 hours of it. It may be a little difficult to read - use [Ctrl] & [+] to make it bigger in your browser - but I didn't want to get lots of line-wraps.

ALTER function [dbo].[fnCalcWeekdaysInPeriod]

@daStartDate date, 
@daEndDate date 

returns int 
select dbo.fnCalcWeekdaysInPeriod('9/29/2012', '9/30/2012')
-- ---------------------------------
if @daStartDate > @daEndDate return 0
declare @intDays int, @intWeeks int, @intResDays int
-- ---------------------------------
-- We're only interested in Mon - through -  Fri, 
-- so adjust boundary weekends out of the calculation
-- Push the start date on two for Sat, one for Sun.
-- Pull the end date back two for Sun, one for Sat.
-- ---------------------------------
if (datepart(dw, @daStartDate) = 7) set @daStartDate = dateadd(d, 2, @daStartDate)
if (datepart(dw, @daStartDate) = 1) set @daStartDate = dateadd(d, 1, @daStartDate)
if (datepart(dw, @daEndDate) = 1) set @daEndDate = dateadd(d, -2, @daEndDate)
if (datepart(dw, @daEndDate) = 7)  set @daEndDate = dateadd(d, -1, @daEndDate)
-- ---------------------------------
-- Get the days  --  plus one to make the count inclusive.
-- ---------------------------------
set @intDays = datediff(d, @daStartDate, @daEndDate) + 1
-- ---------------------------------
-- If negative then start date has met end date - which shouldn't happen unless they're very close
-- ---------------------------------
if @intDays < 1 set @intDays = 0
-- ---------------------------------
-- Find out how many weekends there are between the dates
-- ---------------------------------
set @intWeeks = cast((cast(@intDays as float) / 7) as int)
-- ---------------------------------
-- Subtract 2 for every internal weekend
-- ---------------------------------
set @intResDays = @intDays - (@intWeeks * 2)
-- ---------------------------------
return abs(@intResDays)

If anyone can find a problem with it then I'd be happy to buy the first few people a beer each! The next post will be for the same thing but for work days - i.e. the days people work after taking company holidays off. It depends on this, though, so this needs to be correct!

On a more personal note, my cousin Edward now has a berth on the Queen Mary II. Congratulations and best wishes to him!

Go here for information on the ship.

Go here for booking information (shameless plug!).

My darling wife and I collaborated on dinner last night. This isn't a cause for a blog in and of itself, but it turned out more successfully than we'd expected. It was a very simple meal - chicken breast, couscous, and some sauce, with a few veggies - but it turned out to be very nice indeed, and pretty low-effort.

Two (or more!) chicken breasts Chicken broth
Dried Basil and Bay Leaf, crushed up  Salt and Pepper
Spring Onion, chopped small Celery, chopped fairly small
CousCous Cream Cheese
Roast Garlic Jelly Butter

1. Clean the chicken breasts well, trimming off any fat you don't want to serve.
2. Lay each breast on a piece of aluminium foil big enough to fold up loosely around the whole breast.
3. Turn up the foil around the edges  and pour in some broth, enough  to reach about a centimetre
    up the breast.
4. Strew the breast with the herbs.
5. Fold up the foil over the breasts to close them in, put them all on a baking tray, and bake
    for 35-40 minutes at between 380F and 400F.
6. For the sauce, take about 10 oz of cheese, about the same of the roast garlic jelly, and some
    chicken broth to help thin it out. Put it all into a saucepan and whisk gently to mix while heating through.
7. For the couscous, heat some butter (maybe a quarter of a stick) in a pot, then pour in about 3/4 cup of
    courcous per person. Stir while still heating, so that the couscous is a little fried in butter. When you can
    hear the mixture start to sizzle a little, add a cup of chicken broth and stir well. Stir in some more celery
    and spring onion, and any aromatics that catch your eye - such as a little Rosemary or Thyme for
    flavouring to your taste.

Eat well!

Thursday, September 06, 2012

Experts Exchange

Experts Exchange is a site where you go to get help. Yes, I know there are many of these, but this is a really technical one, mainly for programmers, DBAs, and the like, although there are other sides to it too, like areas for operating systems where you could ask questions about things like MS' Office-365.

I've been a member for quite a few years, but only recently started answering more "seriously", if you can put it that way, and today I got a reward:

along with a certificate. Hopefully some more will follow.

Now to go prepare Jambalaya (I think!).


Tuesday, June 26, 2012

On Getting a Cat

I was sitting calmly in work a couple of months ago when the cell phone rings. "Hello darling" the voice at the other end purrs, "please get some cat food on the way home". My thought process went something like "Well ok ... we don't have a cat ... well maybe we do now!"

So I stop on the way home and get some cat food. When I get home I find the wife with a very emaciated cat.

Here she is curled up inside a jam pan.

So I was sent out to get all the bare necessities (tray, litter, scoop, more food, bed ... )

The bed seems to be popular!

Then there's housing for the needy!

and here she is gazing intently at the squirrels feeding noisily outside the window!


Thursday, May 17, 2012


One Egg
Half a cup of Nutella
Five tablespoons of flour.

Mix well
Distribute around a pan of twelve mini-muffins

Bake at 350F for 10 minutes.

Take out and they look like this

They taste seriously good - like muffins made from very very good brownie-mix. Not heavy like brownies, though.

Sunday, May 06, 2012

Maryland Sheep and Wool 2012

And welcome to the fair!

For the very fourth time - and it's Cinco de Mayo today ..... and a super-full moon. There'll be crazyness tonight - that's for sure!

The first thing seen in through the gate today was a yarn- bombed sign - it says "Sock Yarn for Sock Lovers"!

Anyhow, I'm posting just some pictures here. I'll probably not send them all up to PhotoBucket like the last few years 'cos I'm using a new (=better) camera now, and I don't think they'd appreciate a gigabytes-worth of space grabbed all-at-once! 

These two (left and below) are of the booth from the Tsock Tsarina.

 If you've never seen her extras on socks, you need to! I saw some leaves on a sock and, for a moment at a distance, thought them real!

 We kept wandering around the area uphill from the entrance for a while, looking in where people were just finishing setup.

 Below you see the shop from a guy where we bought new chopsticks.

 Next, of course, was my personal favourite - Tess !  I just love the colours and the way they drift into one another.



Courtesy of the young lady below - and her scissors - I'll be getting some brick-red socks in a few months (assuming I keep on the right side of the AG!)

So, that's all the pictures for this post. More next time.


Saturday, May 05, 2012

I Won Again !!

Two years ago I joined a kind of a book club, called 101 Free Tech Books.

About eighteen months ago I won a book on being a SQL Server DBA from 101 Free Tech Books.

Well, guess what? It happened again! This time I chose a Powershell book, 'cos I'm starting to need that more and more.

WIN FREE Tech Books!

101ftb-iconWhy pay for Tech Books when you can get them for FREE! raffles 101 Tech Books each month. Join Now

Yes - it's an advert. It's the advert for 101 Free Tech Books. Click on it and go and join! It's free, and you get books! What's more, it's totally free!!!

 One last note for this post:
We're in MD for the MD Sheep & Wool again, 
so stand by for more photos on Photobucket tomorrow!
so photos will get reduced in size and put up here - 
I went over a gig of images in 2 hours !!


A New Addition!

 A few weeks ago the AG went out to feed the local squirrel-neighbours, and heard a stream of plaintive meows. Going to investigate, she found a tabby-and-white cat lurking loudly in the undergrowth.

Being a total softie, she picked her up and brought her in.

Later on, as I leave from work, I get a call ...
 ... to buy cat-food on the way home!

(say what??? - we don't have a cat! 
Do we?)

Well, suddenly we do. So we get to have new friends - the vets and staff at the Banfield surgery in Cherry Hill, all the staff at Country Kennel in Lindenwold, the people at PetSmart, and, of course, the development office, where we pay extra rent for her!

When we got her she weighed about four pounds and could fairly be called a Flat Cat, she was so thin. We're doing our best to "feed the 'ell out of her", so she ends up being a Fat Cat instead!

As you can see, she's tall and long - three feet long including tail!

She's also a very well-behaved cat, about a year old, and knows all about using a litter tray and a scratching post.

There'll be more pictures of her over the coming posts


And Lightning Doesn't Strike Twice?

So you believed the tale that lightning never strikes twice? You never thought that maybe - just maybe - nobody ever reported a second strike 'cos they were already dead from the first one?

No more than four days after the last tale of Windows woe I get called by the dad of one of my son's friends. "My son's computer died" he said, "Do you think you could look at it?". I suppose a certain amount of desperation was creeping into his tone of voice (small hints like the "How much do you charge?" phrase), so I went over that night to see. The problem was that his netbook would not boot properly into Windows, giving this message:

Windows could not start because the following file is missing or corrupt

 This is not a happy message to see. The files in the config directory are your registry, so this means that the system hive (part) of your registry - probably the most important part - is gone. Without it Windows has no idea what parts of Windows are where, so nothing starts!

There are programs that claim to help you to recover from this problem, but not only did I not have them but I was also constrained by time. So we got his external USB Optical drive, connected it, put in a Linux live image DVD, and tried to boot. Same message!

Drat!! F2 to get to the BIOS and change the boot device sequence (it was an Acer One, so under "Boot" in the BIOS menus). Try again. Same message. Huh??? Check the BIOS - should start from hard drive last, so why isn't it? Turn machine totally off, disconnect optical drive (that uses one USB socket) and try another (that uses a double-headed cable).

Success!! Select PartedMagic. Look at the hard drive ... there are two? Oh! 155 GB and 5 GB means that there's a normal one and a recovery one. Excellent!!

Spent the next hour taking all the irreplaceable personal files off the hard drive and onto a USB drive. Once that's done we used the disk checker in PartedMagic to review the SMART data from the hard drive. It all looked good, so replacement was ok to do.

Reboot yet again - without the optical drive - and hit F6. This got us the menu for replacing the content of the hard drive from the recovery partition. 30 minutes later we had a "brand new" PC!!

Yes, we could have done the system recovery without Linux, but not without losing all the data from the machine. Oh, and no, I didn't charge!


Saturday, April 28, 2012

What Do You Do When Windows Doesn't ......?

You don't really think much about it when your laptop dies because of a low battery. You just put it away and plug it in to feed when you get to an outlet. Once attached to the electrical umbilical you just restart it and continue with your work, games, chatting, or whatever.

So this friend of mine - a student, as it happens - rings up a few days ago at about 5 pm to say that the above was just exactly what had happened ... up until it was time for Windows to re-launch. The all she was getting was a prompt to reboot again.

Well, it could have been a root-kit virus, or an OS failure, or a hard drive failure - from 500 miles away I couldn't tell, but what we did know was that she needed to get her data off the hard drive and also to get a system up so she could finish a paper.

Enter the "Live Distro"!!  You'll have seen magazines on sale with CDs packaged in them. There are at least four (Linux Format, Linux Pro Magazine, Ubuntu User, and Linux User and Developer) that normally carry a CD or DVD in their packaging containing a bootable version of the operating system. The idea is to let people try out the system to see if they like it without installing a whole new OS just to find they hate it!

However, because pretty much all Linux versions now have drivers to read Microsoft's NTFS file system, they make excellent rescue systems!

So she went and got a magazine, opened the case and popped the DVD in to the drive in her laptop and rebooted the machine. When it started it asked her if she wanted to boot from removable disc, and she said Yes. Three or four simple questions (keyboard, time, date, timezone, etc). After that she was in to a functioning modern operating system.

After getting all valuable information off, she found that Libre Office let her open her Windows 2010 Word and PowerPoint documents and finish everything up. Her VB.Net coursework is (luckily) complete, otherwise it would have been an install of Mono and Eclipse!

And Windows? Dell are sending her a recovery disk set and, if that doesn't work, it'll be returned for hardware recovery. Of course, there's always the alternative of popping in a new hard drive and running Linux natively, with maybe a VM with Windows ....

So, to all those of you who panic when Windows fails: help is at hand - just as far away as your nearest Barnes & Noble store! The magazines (they're all British, by the way) cost about $16, so as a way of getting at your data despite a death of Windows it is probably the cheapest method going!


Thursday, April 12, 2012

Even Apple isn't Perfect

Nobody's perfect - not even Apple. Although it tries very hard, I'll admit, and is incredibly successful about it. Right now Apple is worth more than the combined GDP of the economies of Greece, Italy, and Spain! On the downside, it took them three months to publicly realise and try to fix a loophole in the security of their OS (through the Java JVM software, supplied by Oracle) that Oracle fixed for windows 3 months ago. Oracle can't fix it for Mac machines because Apple won't let them!

Anyhow, here's a case of imperfection you may find curious.

We all use USB connections of one sort or another for our computers and our phones. We're all familiar with the standard USB "A" connector - the steel rectangle part-filled with a block of plastic to make sure it goes in the right way around.

I recently bought an Apply wired keyboard. I don't possess an Apple machine, but do like their keyboards, and, as they work fine with Linux (and Windows) systems, I invested in a couple. Each keyboard comes with a USB cable for attaching to the computer and, thanks to Apple's fore-sightedness, an extension cable.

Now look at these photos.

 On the left is a picture of the socket on the end of the extension cable. Look closely, and notice the little "v" on the inside of the metal casing, opposite the plastic block insert.

 Now look here at the USB plug on the end of the USB cable attached to the keyboard. Notice the little trough between the two plastic lugs holding the plastic insert block in place? It perfectly matches the "v" on the socket of the extension cable.


At the other end of the extension cable the USB plug is a perfectly normal one!

This means that the keyboard and extension cable are keyed: you can only plug a keyboard into that extension cable - nothing else.

Well, actually, you can, but you need a pair of small pliers to get them apart again!!  Be warned !


Update !
Apple has released a tool to remove the FlashBack virus.
If you think you might have this infection on your PC,
or want to make sure you don't,
please look here.

Friday, March 23, 2012

Moving On

Well, it's become time to move on to another day-time home. Pay to Play is something of a dirty word in most parts of the USA (excepting here in NJ, where it's the acceptable alternative to Menace to Meet (the menacing usually demonstrating that one is carrying concealed, licenced or not). I'm kind of unusual, it seems, because I really like doing what people around me all call "work". For me, "work" is "play I get paid for", so Pay to (let me) Play is definitely on my approval list!

As I started to say, I'll be finished up here in mid-north NJ at the end of the month, and starting a new gig near Philly - lots nearer home. It'll actually be a lot more miles per week, but I'll save the cost of a hotel room 5 nights a week. Quids in overall, so that's good. OTOH, I'll be sad to leave, as I've been enjoying the atmosphere and working environment here. 

Today was a really nice day up until about 4 pm. I got lots achieved in the morning, had a really nice lunch, got back to find that the explanation of some really weird specs had arrived, so I sat down and finished that requirement in about 90 mins, testing and all, and set about fixing the code for a report that's displaying some really really weird behaviour (although as I think of it right now I suspect I've just realised why!).

Then I got a request from the friendly local DBA who was deploying an SSIS package of mine. "Come on over, we've got a small problem"  ...  the coded equivalent of "I have a cut-throat razor looking for some skin. Feel like volunteering?" !

So I wandered over to find him really perplexed. "did you encrypt anything here?". "No. Why?" and he shows me some error messages. Stop and re-start it and it all goes away - don't ask; it's MS SQL Server 2008! Anyhow, we test the package and it does all the difficult bits fine and then crashes writing to an Excel file.

It turns out that SSIS dynamic variables are evaluated every time they're accessed, so if I have a variable that is composed of a file path and name and a time-stamp and the extension, and the time stamp is created in a formula using getdate(), then getdate() is triggered and the result used to create the string from scratch every time it's asked for.

That would be fine, but I have two tasks: one copies a template file (an empty Excel file) to another folder, adding the time-stamp en route, and the next one pulls data from a database table and writes it into that file.

All had always worked fine in testing, but today the network was so slow and the data quantity sufficiently large, etc., etc., that the first task composed a new name Test_20120322_1602.xls, but by the time the next task was looking to write to it, the name it composed (in exactly the same way) was Test_20120322_1603.xls. Needless to say, this file didn't exist, so I got a nasty OLEDB Failed message for my troubles!

The fix was to compose the name once first and store it (with a script task) into a non-dynamic file name for both tasks to use.

So here I am at my desk in the hotel, writing this (the first entry for several months - I've just not had a great amount of time  and living in a hotel room doesn't exactly encourage the muse) as, I suppose, a way or procrastinating about doing some studying.

I've been answering a lot of questions on ITToolbox recently, and have re-started on Experts Exchange. In fact, in just a few days of trying I've already been given a free month's use! Answering the different types of questions is always a challenge, and sharpens ones' own skills, which is good.

That's All, Folks!