I was just despairing, because I'm in a little bit of a writing slump. "I'm not doing anything exciting at work", I thought. "Where on earth will I find inspiration for my next blog?" Then, the gods opened a query window unto me, and there sheweth me an unholy violation of the immortal commandment:
Thou shalt not double-hit thy tables!
Here's the code I saw (the names have been changed to protect, well, me):
SELECT @ActorID = ActorID
FROM Producers
WHERE ProducerID = @ProducerID
SELECT @SceneID = SceneID
FROM Actors
WHERE ActorID = @ActorID
SELECT @Movie = Movie
FROM Producers
WHERE ProducerID = @ProducerID
Tell me, my people. What on this particular planet precludes you from getting @Actor and @Movie values, oh, I dunno, in the same select???
SELECT @ActorID = ActorID,
@Movie = Movie
FROM Producers
WHERE ProducerID = @ProducerID
SELECT @SceneID = SceneID
FROM Actors
WHERE ActorID = @ActorID
Is it some sort of religious thing, you can't assign more than one variable in a select on Tuesdays? I'll take a breath in a minute and assume it was an honest mistake…but right now I have to get a qualified team lead to bless a bowl of Diet Dr. Pepper, so I can conduct a stored procedure cleansing ritual.