Simple Way to Get a Domain from an Email Using T-SQL

One of my recent projects required me to create a Microsoft SQL Server view that displayed (among other information) and email address and its underlying domain. Microsoft SQL Server and T-SQL provide a few simple functions that, when used together, make this a fairly easy task.

So here’s the T-SQL example (with the important stuff highlighted):


Parsing text inside a SQL Query can slow things down if you’re dealing with a large dataset, so use this code snippet with caution. If the application allows it, it’s generally a better idea to perform this kind of parsing in the application layer. ColdFusion, PHP and JavaScript provide comparable functions to T-SQL’s RIGHT, LEN and CHARINDEX.

If you’re feeling brave, you can also try pure RegEx rather than use native functions.

Episode I: The Phantom Mini

This from doesn’t show Amazon Kindle devices, but it still doesn’t help the iPad Mini’s case.

Over on, I’ve been writing about my quest to find an iPad Mini. More than a month later, and I still haven’t been able to track one down in stores that I can actually purchase. Sure, the Apple Store will let me play with a demo unit, but unless I can run faster than the mall cop, I’m not leaving with one.

On Amazon, several online retailers say they have a few iPad Minis in stock, but they’re selling out quitckly. will allow me to place an order (and take my money), but both the estimated shipping date and in-store pickup still show “Not Available.” The Apple online store claims the 16GB WiFi iPad Mini will ship two weeks from the time I order it.

But I’m not buying it.

I’m not buying into Apple’s promise of future joy. Nobody’s getting my hard earned ducats unless I get some good, old-fashioned, instant gratification.

On the positive side, Apple’s procrastination is has given me ample opportunity to compare other tablets that are actually in stores or available for immediate shipment. There are dozens and dozens of awesome Android tablets out there, and even Windows 8 tablets seem to rallying in time for the holiday spending spree.

My wife really loves the original Amazon Kindle Fire that I bought her last year. It didn’t have the hottest technical specifications on the market, but it’s proved itself to be a solid performer. Still maintaining the $200 price tag, but sporting improved technology, the Kindle Fire HD is a tempting holiday treat.

Apple seems to have a good handle on its App store, but I finally dumped iBooks last year due its content being locked in iOS devices. I want to read my books on any device I happen to get my hands on, and Amazon has been smart to make  the Kindle eBook Store available on any device. Amazon Prime Instant Video also isn’t locked into an Amazon-only ecosystem: I can watch rented, purchased or streaming movies on the Kindle Fire, my iPhone, my iPad, my MacBook Pro, or Xbox 360.

Apple, do you  have a bad feeling about this?

You should.

Never Give Up, Never Surrender – Part 2

I’d been given Vicodin after a few hours arriving at the Alexandria INOVA Hospital Emergency Room, so I was down to an a eight on the pain scale, rather than the twelve I was when I arrived in the ambulance. Perhaps this is why the ER doctor felt my back injury didn’t warrant any actual care.   Fortunately, the Physician Assistant came to my rescue in the nick of time with the news that Radiology could fit me in after all.

When the ER doctor stopped glaring at PA, who had just made her look lazy and incompetent, she signed off on the order for the MRI and sent me and my gurney on our merry way.

Radiology also proved to be no less of an adventure than the ER.

My previous experience with MRI machines was that my weight would be a problem: many MRI machines have tables that only support 250lbs or less. With INOVA’s MRI machine, my weight wasn’t a problem, but my shoulders were. Fortunately, the radiology tech had a few tricks up his sleeve, and he had me stretch my arms about my head before sliding me into the MRI “pipe”. The fit was snug, and the country music piped in over headphones helped, but after ten minutes of buzzing, the tech pulled me out and said they were having calibration issues and needed to use another MRI machine.

The walk to the second MRI machine was the slowest and most painful fifteen yards I’d ever walked. But I made it to the table, laid down, stretched my arms above me, closed my eyes, and relaxed to some Kenny Chesney while the MRI hummed in the background.

After a five minutes, the technician’s voice popped in over the radio, saying the machine was calibrated, and the test would take about thirty minutes. I just kept my eyes closed, half-listening to the country lyrics, and tried not to give into claustrophobia.

After another five minutes, I realized I had a bigger problem: I needed to pee.

One of the possible side effects of an MRI is an increase in body temperature. The MRI machine works a lot like a microwave oven, so over the next twenty-five minutes, I could feel the urine in my bladder steadily increasing in temperature. I knew the technicians probably wouldn’t be happy if I wet their multi-million-dollar machine, so I did my best to pass the time without thinking about growing pressure, warmth and discomfort. By the end of the scan, the pain in my bladder had reached parity with the pain in my back, and I felt like I was sprinting to the restroom twenty yards way.