Me writing things down when I have time, as well as putting up some things that other people might find useful
Tuesday, May 11, 2010
Vitamine D for Hodgkins Lymphoma
Its all over the internet but I think its important enough to keep repeating. Vitamin D hinders lymphoma and a whole bunch of other cancers. So much so that this study found that people diagnosed in summer times seems to have a 20% better survival rate!!! So stock up on Vitamin D supplements, and if possible get in the SUN as much as possible!! (without, obviously, burning yourself and getting skin cancer, kinda defeats the purpose)
Thursday, March 18, 2010
Microsoft SQL - Return random number in Query in Microsoft SQL
After a lot of searching around for a random number generation function for Microsoft SQL views, and trying all kinds of different methods, and only finding very resource expensive methods for getting a random number for each line in a query result set, I stumbled on this very obvious solution in a forum. I unfortunately cannot remember the forum otherwise I would post the link but I figured it couldn't hurt posting this here.
We all know NEWID() function will return us a GUID, which is nicely random. So using this we can generate ourselves a nice random number.
Step 1. Convert the Guid to Binary using
Step 2. Great so we have random binary, which we can change into anything we basically want, so lets convert it to an in CAST(CAST(NEWID() AS VARBINARY) AS int)
Step 3. Ok we have a random number but it may be negative and we probably just need something positive, so lets do ABS(CAST(CAST(NEWID() AS VARBINARY) AS int))
Step 4. Last step is to limit our Random number, The mod operator will help us here so lets say we want a random number up to 1000 we go ABS(CAST(CAST(NEWID() AS VARBINARY) AS int)) % 1000
So if you have a Northwind database and run
Select ABS(CAST(CAST(NEWID() AS VARBINARY) AS int)) % 10000 as RANDOMNUMBER,* from dbo.Customers
You will get a random number for each row in the Customer table in the database
You can also use this in a View and it works perfectly.
Hope this makes someone else's search a bit less frustrating than mine was.
Thursday, February 11, 2010
Cars are better than trains
There are certain definite advantages to public transport, aside from the obvious environmental benefits, you don't have to worry about car maintenance, traffic (at least not the kind the makes you calves hurt from having to maintain constant clutch control) and the fact that you can read your paper while travelling to work instead of concentrating on the road.
My mind, the unfortunate cynic, complains that my bodies environment suffers from the various city folk, coughing in my face, that traffic isn't that bad (you need the exercise) and you can get the news from the radio and get the added benefit of music instead of endless advertising in the paper (And even if there is advertising on the radio, its sometimes more entertaining, would miss the cartoons though...). So the trump card is car maintenance, which boils down to money.
Now personally I'm starting to think that the money for a car is really the well justified. First and foremost its a health issue. There is endless propaganda that talks about it being good for the environment to use public transport, but every winter I have to fight off flu after flu because some prior victim of the public transport health hazard, sneezes or coughs on me.
There are also the benefits of having a car for weekend trips (which cost some money anyway might as well pay a big oil corporate than a big public transport corporate). You don't need to rush to catch trains for you relaxing trips because the car leaves when you want to leave, and the comport of being in your own personal space (and not being sneezed on) is a brilliant perk.
One of the best perks I believe is the personal space perk of driving a car. When you leave work and get in your car, its your space. Its almost like being half-way home already. Your 4 square meters of space, in which you can do (and unfortunately some people take this too far) whatever you want to. No attention seeking teenagers with attitude playing their hip-hop as loud as possible, because they don't get enough attention at home and so needs it from the public hordes (join a football club or something!!!). No-one coughing on your head. No-one eating like giraffe with a twig stuck between their teeth. Just you, your music, your time.
Yup, cars are better than trains any day of the week.
Subscribe to:
Posts (Atom)