Logic: The art of thinking and reasoning in strict accordance with the limitations and incapacities of the human misunderstanding. ~Ambrose Bierce

On a lighter note SQL

0
Wedding Queries........ ........ (SQL Style)
HUSBAND’S QUERY

CREATE PROCEDURE MyMarriage (
BrideGroom Male (25) ,
Bride Female(20) )
AS
BEGIN

SELECT Bride FROM  india_ Brides
WHERE FatherInLaw = 'Millionaire'
AND  Count(Car) > 20   AND  HouseStatus ='ThreeStoreyed'
AND BrideEduStatus IN (B.TECH ,BE ,Degree ,MCA ,MiBA) AND Having  Brothers= Null
AND Sisters =Null

SELECT Gold ,Cash,Car,BankBalance
FROM FatherInLaw
UPDATE MyBankAccout
SETMyBal = MyBal + FatherInLawBal

UPDATEMyLocker
SET MyLockerContents = MyLockerContents + FatherInLawGold

INSERT INTOMyCarShed VALUES('BMW')
END
GO

Then the wife writes the query below:

DROP HUSBAND;
Commit;

SQL Resultset in CSV format..

0
There might be a requirement very often to dump the query results straightaway into CSV file format or in other words into a .CSV file. Here is what we need to do to achieve the same.

1) In case we are using OSQL through JCL to call the stored proc, then we need to add a new parameter (-s) as "," or ";" to indicate the character separator. E.g. SET PARM5= -s %";"%
The other parameter (-o) needs to be modified to specify (.CSV) as output file format instead of (.TXT).

2) This is not all. The stored proc needs to be modified as well to accommodate the changes. Please refer to these different approaches taken.

SELECTED APPROACH:

a) SELECT 'col_1' + ',' + 'col_2' + ',' + ' '
    UNION ALL
    SELECT CONVERT (varchar, col_1) + ','
             + CONVERT (varchar, col_2) + ',' + ' '

ALTERNATIVE APPROACH:

a) SELECT 'col_1', ',' , 'col_2'
    UNION ALL
    SELECT CONVERT (varchar, col_1), ','
                , CONVERT (varchar, col_2).................cont.

b) SELECT  CONVERT( varchar,col_1) AS [col_1,]
                ,CONVERT( varchar,col_2) AS [col_2,]........cont.

NOTE:
Conversion to varchar is required to append the character separator.

ISSUES WITH ALTERNATIVE APPROACH:
1) Alignment problem with alphanumeric columns.
2) Space issues which could not be handled through generic sql trim functions.
3) Unoptimized file size.
4) Truncation of data in some cases if varchar size is not carefully specified.
5) Last column of unusual width.

UNSOLVED ISSUES:
1) The column header being present in the final CSV output file.
2) The date field losing its formatibility once converted to varchar and exported to excel.
Unresolved Issue # 1 can be resolved by the following approaches.

The SQL output contains 2 records, the Header name in the first line and the Line (-) in the second line. This can be removed by
1. We can create DTS package to export the data into Text file and call that DTS from the JCL script. This removes the header lines.
2. These lines can be skipped directly from the JCL script itself with the following code

We just need to provide the record length like [LRECL=357]

//SORTCPY EXEC PGM=SORT
//SORTIN DD DSN=&&UCMDFILE, DISP=OLD
//SORTOF01 DD DSN=&&UCMDSORT,
// DISP= (, PASS, DELETE),
// DCB= (RECFM=FB, LRECL=357),
// SPACE= (2048, (500,500), RLSE)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FILES=01, STARTREC=2




Orphaned Distributed Transaction SPID

0
Explanation:
This example is of an Orphaned Distributed Transaction SPID which specifically involves MSDTS, the Microsoft Distributed Transaction Coordinator. The is what happens when a transaction involves data which resides on more than one server (such as when a database record is replicated out to two or more servers where MSDTC needs to become involved) and the following happens:
a) A server drops off the network
b) There’s a power outage at the distributor server.


The Negative SPID (-2) in SQL Server
Phenomenon: May be you have been investigating a performace issue in SQL Server or exploring the error log file for sometime. But to add to your astonishment you notice that there is a negative SPID = -2 at the top of the chain and is the cause of all deadlocks.

What next?
Definitely you would like to wait (not sure how long?) or try to kill the process.

Here is what you have when you try any of them:
Wait: No use waiting as the process will not complete/refresh untill a server restart.
Kill: Yes. Ofcourse you can try to kill the process by executing KILL -2. Here is your prize:
Msg 6101, Level 16, State 1, Line 1Process ID -2 is not a valid process ID. Choose a number between 1 and 2048

Anything else in Pandora's box?
No...?

Solution:
Try this.
SELECT req_transactionUOWFROM master..syslockinfo
WHERE req_spid = -2

This will return a 32 digit UOW number which looks like a GUID. Something like ‘BCD12078-0199-1212-B810-AB46A24F2498’
Run the KILL command with the above UOW.
KILL ‘BCD12078-0199-1212-B810-AB46A24F2498’
Now run sp_who2/sp_who. To your surprise its SPID -2 is GONE.

 

Letter To Dean (Funny)

0

Forget...

0

Know Your Customer

0
A disappointed salesman of Coca Cola returns from his Middle East assignment. A friend asked, "Why weren't you successful with the Arabs?"

The salesman explained, "When I got posted in the Middle East, I was very confident that I would make a good sales pitch as Cola is virtually unknown there. But, I had a problem I didn't know to speak Arabic. So, I planned to convey the message through three posters...



First poster - A man lying in the hot desert sand...totally exhausted and fainting….

Second poster - man is drinking our Cola.

Third poster- Our man is now totally refreshed.

Then these posters were pasted all over the place "That should have worked," said the friend.
The salesman replied "I didn't realize that Arabs read from right to left"

Fun With Graph

0







Man & Wife

0
Quite a popular one but lets refresh..

A man and his wife were having some problems at home and were giving each other the silent treatment.
Suddenly, the man realized that the next day,
...He would need his wife to wake him at 5:00 AM for an early morning business flight.
Not wan...ting to be the first to break the silence (and LOSE), he wrote on a piece of paper,
'Please wake me at 5:00 AM '
He left it where he knew she would find it.
The next morning, the man woke up, only to discover it was 9:00 AM
And he had missed his flight.
Furious, he was about to go and
See why his wife hadn't wakened him, when he noticed a piece of paper by
The bed.
The paper said, 'It is 5:00 AM. Wake up.'
Men are not equipped for these kinds of contests.

Water or Coke???

0
An interesting  information..

WATER
#1.   75% of Americans are chronically dehydrated..
 
(Likely applies to half the world population)

#2.     In 37% of Americans, the thirst mechanism is so weak
that it is mistaken for hunger.


#3.    Even MILD dehydration will slow down one's metabolism as 3%.
#4.   One glass of water will shut down midnight hunger pangs
   
for almost 100% of the dieters studied in a University of
Washington
study.

#5.     Lack of water, the #1 trigger of daytime fatigue.
#6.    Preliminary research indicates that 8-10 glasses of
   
 water a day could significantly ease back and joint pain
for up to 80% of sufferers.


#7.    A mere 2% drop in body water can trigger fuzzy short-term
     
memory, trouble with basic math, and difficulty focusing on
the computer screen or on a printed page.

#8..   Drinking 5 glasses of water daily decreases the risk of
 
 colon cancer by 45%, plus it can slash the risk of breast
cancer by 79%., and one is 50% less likely to develop
bladder cancer. Are you drinking the amount of water
you should drink every day?


COKE
#1.    In many states the highway patrol carries
     
two gallons of Coke in the trunk to remove blood from
the highway after a car accident.


#2.     You can put a T-bone steak in a bowl of Coke
and it will be gone in two days.

#3.    To clean a toilet: Pour a can of Coca-Cola into the
   toilet bowl
and let the 'real thing' sit for one hour,
then flush clean. The citric acid in Coke removes
stains from vitreous china.

#4.    To remove rust spots from chrome car bumpers:
     
Rub the bumper with a rumpled-up piece of Reynolds
Wrap aluminum foil dipped in Coca-Cola.

#5.    To clean corrosion from car battery terminals: Pour
   
a can of Coca-Cola over the terminals to bubble
away the corrosion.

#6.   To loosen a rusted bolt: Apply a cloth soaked in Coca-Cola
to the rusted bolt for several minutes.


#7.    To bake a moist ham: Empty a can of Coca-Cola into
 
the baking pan, wrap the ham in aluminum foil, and bake.
Thirty minutes before ham is finished, remove the foil, allowing the drippings to mix
with the Coke for a sumptuous brown gravy.

#8.   To remove grease from clothes: Empty a can of Coke
 
into the load of greasy clothes, add detergent, and run
through a regular cycle.. The Coca-Cola will help loosen
grease stains. It will also clean road haze from your
windshield.

FOR YOUR INFORMATION:
#1     the active ingredient in Coke is phosphoric acid.
It will dissolve a nail in about four days. Phosphoric
acid also leaches calcium from bones and is a major
contributor to the rising increase of osteoporosis.

#2.   To carry Coca-Cola syrup! (the concentrate) the
commercial trucks must use a hazardous Material place
cards reserved for highly corrosive materials.

#3.    The distributors of Coke have been using it to clean
engines of the trucks for about 20 years!
Now the question is, would you like a glass of water?

Onions Rs.65, Petrol Rs.65 and Beer Rs.65

0


For the first time in the history of mankind ‘Need’, ‘Comfort’ and ‘Luxury’ are sold at the same price in India!
Onions Rs.65, Petrol Rs.65 and Beer Rs.65

Happy New Year 2011....

0
These are my two friends who wished me a new year.....I liked both, so I am sharing with you all.

1) To all my dear friends,

Wish you all a Happy New Year 2011.

  • For all those I've made promises to and never kept - it was not deliberate but I will "improve" in 2011.
  • Those that I owe lunches, movies, night out , etc..., I'll fix that as well, I'll make time . For sure.
  • For those that have supported me and made me smile through all my hardships...I salute you! halaala.
  • For those I've disagreed with, argued with and just never got along with......well, I'm Sorry!!!!!!! Let's try again next year.
  • Those that I've hurt.....unintentionally/intentionally....I've already apologized "I'm Sorry" again...
  • For those that stuck a knife in my back the past is all forgotten.... forgiveness is the best revenge Maybe!!!
  • For those that have let me down.....oh well.... I should have known better
  • All the true friends that I have: you Rock!!..Awesome!
  • Congratulations to all the new mommies & fathers, newly weds etc..., no funerals please guys
  • But all in all, you guys have made 2010 a great year; I wish you and your loved ones prosperity, good health, wealth, happiness, greener pastures,   abundant blessings.
  • And Oh!! a wonderful festive season.
  May 2011 be the year you achieve wonderful things in God's guidance and strength.
  May God Be With You.........Be Blessed!!!!!!!

Affable
XYZ

Wishing you and your family an extremely prosperous, recession-proof, financially-stable, job-secure, debt-free, investment-profiting, environment-friendly, promotion-assured, hike-replete, air/water/rail/road-safe, terrorist-free, friends-filled, market-booming, approvals-breezy, MISs-scanty, PPTs-sparse, escalations-nil, bonus-credited, healthy, wealthy, joyous and cheerful New Year 2011 .. :) :) :)

Save The Roar......

0
This was an email written by me as a reply to my colleagues....on Wednesday, March 31, 2010

Some should be known tiger facts before i get into the original email...

From around 40,000 tigers at the turn of the last century, there are just 1411 tigers left in India . What started as a Royal Sport during the olden times is now a target of Poaching and Depleting Habitat. Our National Animal is fighting for its life!
2009 was the worst year for tigers in India , with 86 deaths reported.
There are 37 Tiger sanctuaries in India . However, 17 sanctuaries are on the verge of losing their tiger population.
Corbett National Park is the oldest tiger park in India . It was created in 1936 as ‘ Hailey National Park ’.
The Kanha National Park ’s lush sal and bamboo forests, grassy meadows and ravines provided inspiration to Rudyard Kipling for his famous novel, The Jungle Book.

Do you want your future Generations to see our National animal in books and photos???



Here goes my reply to a forwarded email from one of colleague....

Believe me....forwarding these mails will not help a single Tiger.
Till date did anyone of you did anything for the street dogs you see everyday. You all might be living in big apartments, your own houses etc. and planning to keep a Labrador, German Shephard (Status symbol you know!!!!)
Did you ever provide shelter/accomodation to a shivering puppy/kitten in winter?
Did you ever even think of it......? May be yes, may be no. Mostly NO.

Awareness and consciousness amongst a mere tribe of Software Engineers is not going to help. Believe me the person who will help is not waiting for your awareness email.

I know what can happen atmost. Dont mind I am being very optimistic, may be after reading the mail you will contribute a feeble sum of your monthly salary for ONCE to an animal welfare organization. You think its DONE????

Did you ever take that SMALL STEP to see a weeping puppy smile from the sense of warmth it got from your shelter in winter cold?
Did you ever give a promise of life (and not a broken limb) to that petty canine? A little effort of yours, could have prevented that casually shooted stonepiece by a neighbourhood kid, make that innocent animal a permanent handicap.

Huh..too much i guess. That should be a 6 Sigma Green Belt OR should acquire 350 IQ points.  

We, the Homo Sapiens have made the planet our own regime/kingdom. We call ourselves, the superior most in the animal hierarchy.
Taken granted, God has given this whole planet for us to live. Not a single ant can pass under our nose without prior permission.

You think we can save a single Tiger??? Its an IRONY i feel. Someday these Indian Roadies will be an extinct species. Only Labradors & German Shephards will rule and once again you will initiate this kind of mail for awareness....the count of street dogs, cats or any other so called cute animals are too high now.
Let it come down to 1411 atleast.

Merely not killing them is not letting them survive....we humans need to be truly superior individuals in our own VALUES and inculcate/infuse our next generation to look upon these fellow living beings with love, affection & mercy. May be then we can think of saving a nearly extinct species in the next millenium. I see that is quiet a distant future.

We dont spare a fellow helpless human being, how can we spare a tiger to LIVE.....

"God loved the birds and invented trees.  Man loved the birds and invented cages." ~Jacques Deval

Regards,
Rajkumar.
gf510712275410


The musical first step..

1