Friday, August 5, 2011

How to generate TSQL for data in SQL Server?

How to check a string is in valid number format in C#?

        public static bool IsNumber(string str)
            double Number;
            if (double.TryParse(str, out Number)) return true;
            return false;

Creating a Silverlight 5 Helper for ASP.NET MVC3 Razor

Righting The Wrongs: Van Halen and M&Ms

The 1980s were heady and decadent times for rock stars. Stories of bad behavior by some of rock’s finest – from trashing hotel rooms to over-the-top prima donna demands – were splashed all over the headlines. And few of those stories were as famous as the “Van Halen M&Ms” story.
In case you weren’t around during the 80s, the rock supergroup Van Halen had a clause in their concert contracts that stipulated that the band would “be provided with one large bowl of M&M candies, with all brown candies removed”.
Once the “M&Ms” story leaked to the press, social commentators jumped all over it. Some called it an egregious example of the pampered and spoiled behavior of rock artists. Some saw it as yet another sign of the decline of Western Civilization. And to this very day, any time a story about a celebrity acting like a diva surfaces, my mother rolls her eyes, clucks her tongue, and says “well… did she want the brown M&Ms taken out of the bowl, too??”
Here’s the thing, though: the band put the “no brown M&Ms” clause in their contracts for a very good reason.
Van Halen was one of the first rock bands to bring truly massive concerts to mid-size cities like Macon, Georgia. The arena staff in these smallish cities were used to bands coming to town with, at most, three tractor-trailers full of equipment. Van Halen’s equipment took up nine tractor-trailers. It was a lot of stuff, and staff at these venues were frequently overwhelmed. And when people are overwhelmed, they make mistakes. At a rock concert, “making a mistake” during setup has a large number of possible outcomes. Some mistakes don’t have any effect at all. Other mistakes can make the band sound awful, which only hurts the band’s image. But more serious mistakes can kill people… which is exactly what the band was afraid of.
At the heart of any major concert is the contract. Much of the text of these contracts is standard legal boilerplate, but each band may attach specific demands via something called a “rider”. Most contracts involving large venue concerts are jam-packed with riders, most of which involve technical details specific to the band’s stage design. For instance, a rider might say “Article 148: There will be fifteen amperage voltage sockets at twenty-foot spaces, spaced evenly, providing nineteen amperes total, on beams suspended from the ceiling of the venue, which shall be able to support a total gross weight of 5,600 pounds each, and be suspended no less than 30 feet, but no more than 37.5 feet, above the stage surface”. Van Halen’s concert contracts would have several hundred such demands, and their contracts ended up, as lead singer David Lee Roth would say, looking “like a Chinese Yellow Pages”.
The staff at large venues in big cities were used to technically-complex shows like Van Halen’s. The band played in venues like New York’s Madison Square Garden or Atlanta’s The Omni without incident. But the band kept noticing errors, sometimes significant errors, in the stage setup in smaller cities. The band needed a way to know that their contract had been read fully. And this is where the “no brown M&Ms” came in. The band put a clause smack dab in the middle of the technical jargon of other riders: “Article 126: There will be no brown M&M’s in the backstage area, upon pain of forfeiture of the show, with full compensation”. That way, the band could simply enter the arena and look for a bowl of M&Ms in the backstage area. No brown M&Ms? Someone read the contract fully, so there were probably no major mistakes with the equipment. A bowl of M&Ms with the brown candies? No bowl of M&Ms at all? Stop everyone and check every single thing, because someone didn’t bother to read the contract. Roth himself said:
“So, when I would walk backstage, if I saw a brown M&M in that bowl . . . well, line-check the entire production. Guaranteed you’re going to arrive at a technical error. They didn’t read the contract. Guaranteed you’d run into a problem. Sometimes it would threaten to just destroy the whole show. Something like, literally, life-threatening.”
The “no brown M&Ms” clause became a national news story after an “incident” at Colorado State University. The national press told a story of unacceptable behavior from the band, and how they caused $85,000 worth of damage to the arena. David Lee Roth remembers it a bit differently:
The folks in Pueblo, Colorado, at the university, took the contract rather kinda casual. They had one of these new rubberized bouncy basketball floorings in their arena. They hadn’t read the contract, and weren’t sure, really, about the weight of this production; this thing weighed like the business end of a 747.
I came backstage. I found some brown M&M’s, I went into full Shakespearean “What is this before me?” . . . you know, with the skull in one hand . . . and promptly trashed the dressing room. Dumped the buffet, kicked a hole in the door, twelve thousand dollars’ worth of fun.
The staging sank through their floor. They didn’t bother to look at the weight requirements or anything, and this sank through their new flooring and did eighty thousand dollars’ worth of damage to the arena floor. The whole thing had to be replaced. It came out in the press that I discovered brown M&M’s and did eighty-five thousand dollars’ worth of damage to the backstage area.
Well, who am I to get in the way of a good rumor?