Configuring DB2 (Legacy) as Linked Server on MS SQL

Like I have discussed before, I have been banging my head against the table (I mean it!) on a project I am working on presently. This project involves writing fancy reports against very nasty databases. One, they are as old as my late grandfather (the oldest among the two) and two, the data is all messed up.I am writing more code to circumvent thrash data than to present the application itself.

I have tried some magic using CFMX query of queries but I guess that provide only dumd ass results. I remembered that while at my former work place, some fancy dude has connect the main Oracle DB to SQL server before as linked server. On I went to the net looking for resources. Now, DB2 is not a terribly popular database (It is mostly used by high-end enterprise organizations) not to talk of  a legacy version.

Anyway, after about a million years of trial by error, and a million pages of internet materials, I was able to link the two together. But my queries still won’t run with the four part notation (linkserver.catlog.schema.object). I tried and tried until I discovered that a bug on SNA server (corrected on service pack 4) doesn’t allow four part notation on DB2. So I finally settled down to the OpenQuery() method.

And to thrill my colleagues, I ran a query inner joining an EXCEL worksheet with a DB2 table….

Select b.*,scab+scan+scas accountNumber,scshn accountName from openquery(EQX,
‘select * from S44K7816.KFILKLV.scpf where scan=”783227”’) a, EXCEL_AUTHORS…sheet2$ b
where a.scan=b.[ID]

I can now go home and sleep in peace.

Oracle NVL equivalent on MS SQL

I have been an Oracle DB person for quite a while until my new job where we are running DB2 and MS SQL for the moment. Now, in Oracle, the NVL() function is a quick shortcut for series of nasty CASE THEN ELSE statements. Since the data am dealing with here is a little messy, I needed plenty of such.To make matters worse, SQL is the only common denominator for me between Oracle and MS SQL (as far as Mr. Olowe is concerned).

Anyway, after banging my head on the table exactly 1001 times, I finally discovered that ISNULL(element_to_check,value_if_null) does the same thing. I gleefully went over my previous codes and yanked the sonafab***h CASE statements out.

Knowledge is really power.

To read more on ISNULL for MS SQL, head over to http://msdn.microsoft.com/en-us/library/ms184325.aspx

Honda Accords and their Nigerian pet names

While shopping for a new car recently, I was seriously considering a Honda Accord. What struck me however was the funny names Nigerians have given the different generations of Honda Accords.Third Generation Accord
Code Name: Honda Pure Water
Year of Manufature: 1986 – 1989

Fourth Generation Accord
Code Name: Honda Ala
Year of Manufacture: 1990 – 1993

Fifth Generation Accord
Code Name: Bulldog (European Version is called Bullet)

Year of Manufacture: 1994 – 1997

Sixth Generation Accord
Code Name: Baby Boy
Year of Manufature: 1998 – 2002

Seventh Generation Accord
Code Name: End of Discussion (EOD)
Year of Manufacture: 2003 – 2006