Bad Idea Jeans: Building Big Query Plans

When you build a monitoring tool that sends advice via email, you discover two things: Some people have really, really big execution plans Email servers have reasonable limits on file attachment sizes Add those two things together, and Richie found himself working on a new feature for SQL ConstantCare® that would automatically break up advice…
Read More
Portrait in T-SQL

So, uh, you can, like, draw me in SSMS.

Adrian Sullivan and Michael J. Swart have way too much time on their hands, because Adrian just posted this T-SQL gist, which draws … me: It uses the spatial results feature in SSMS. My mind is blown. I’m totally going to use that in a demo. Thanks, Adrian! I’m already envisioning all kinds of crazy…
Read More

Pop Quiz: SQL 2000 Bug or SQL 2017 Bug?

2002: Me and Bailey, mom’s Great Dane When I was thinking about this site’s 17th birthday, I started wondering: back in 2002, what bug might I have been working with in SQL Server? I started reading back to the list of bugs fixed in SQL Server 2000 Service Pack 1, and it hit me…these bugs…
Read More

One Hundred Percent CPU

Raise Your Hand If You’ve ever wanted to play a prank on your co-workers, but just didn’t have a any ideas that didn’t involve exploding Hot Pockets. Now you have something even less safe than molten cheese squirts! A stored procedure that pushes CPUs to 100%. All of’em. Transact-SQL CREATE OR ALTER PROCEDURE dbo._keep_it_100 AS…
Read More

300 Blogs And Running

Why Bother Blogging? I blog primarily because there’s a Certain Kind of Person that irks me to no end. The kind of person who: Withholds information (you wouldn’t understand anyway) Mocks people for not knowing what they know (oh, you silly things) Uses the people they mock to validate their necessity (you’d be lost without…
Read More

Stupid T-SQL Tricks

Presented without comment: Transact-SQL CREATE TABLE dbo.[FROM] ([SELECT] INT, [WHERE] INT, [LIKE] INT); GO SELECT [SELECT] FROM [FROM] WHERE [WHERE] LIKE [LIKE]; GO 1234 CREATE TABLE dbo.[FROM] ([SELECT] INT, [WHERE] INT, [LIKE] INT);GOSELECT [SELECT] FROM [FROM] WHERE [WHERE] LIKE [LIKE];GO Next up, can you break up a query with spaces? Yep: Transact-SQL SELECT * FROM…
Read More

Stuff People Tell Me Is The Default

Playing The Odds Assuming that life carries on as usual for a couple more weeks, I’ll have been a consultant here for three years. In that time, I’ve had some really interesting conversations with people, mostly about why things are the way they are on their servers. My favorite response is “isn’t that the default?”,…
Read More

Let’s Give The Optimizer A Name

Clunky As my favorite monkey likes to say, the hardest things do with computers are: 1. Naming things 4. Asynchronous processing 2. Cache invalidation 5. Off by one errors Things are tough for Microsoft, too. Take “the optimizer” for instance. It’s based on something called the Cascades Framework. No one wants to say “Cascades Framework”,…
Read More

How to Throttle Logins to SQL Server

So, uh, you can use WAITFOR in a logon trigger: Transact-SQL CREATE OR ALTER TRIGGER SorryNorm ON ALL SERVER FOR LOGON AS BEGIN IF ORIGINAL_LOGIN()= 'NormTheNewGuy' WAITFOR DELAY '00:00:15'; END; GO 123456 CREATE OR ALTER TRIGGER SorryNorm ON ALL SERVER FOR LOGON ASBEGINIF ORIGINAL_LOGIN()= 'NormTheNewGuy'    WAITFOR DELAY '00:00:15';END;GO You probably don’t want it to be TOO…
Read More