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”,…
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…
For this month’s T-SQLTuesday, Aaron Bertrand asked what we’re passionate about – but outside of the tech community, and asked for pictures. Seems like a great way to get to know about us. From my personal blog and my Instagram feed, you probably already know that I’m into cars, travel, and food, so I wanted…
Say you’ve got an application that insists on inserting data into the database, and…you don’t want the data. You want the application to THINK it inserted the data – you don’t want to roll it back or return an error to the end user. You just don’t want the data, and you don’t want the…
“No, don’t bother the DBA. It’s probably not a database problem.” “But it says right here that it worked on my machine.” “Solid state storage sure is overrated.” “Thank God for auto-shrink, really saved the day again.” “We’re not picky – you can apply updates whenever you want, whenever’s convenient.” “The VM admin said to…
Do you ever wonder about the history of the systems you rely on every day? They didn’t teach us database history in school. Instead, we got calculus and art and interpretive dance. Fat lot of good that did us, right? So from time to time, we’re taking it upon ourselves to bring you the history…
File this under bad idea thong In the tradition of Klaus Aschenbrenner wanting to prevent people from writing SELECT * queries, I thought it might be nice to prevent people from running deletes or updates without a WHERE clause. In a vaguely scientific way. Now, I don’t really condone this. It just seemed funny at…
Even error messages: Transact-SQL SELECT * FROM sys.messages WHERE language_id = 1036; 12 SELECT * FROM sys.messagesWHERE language_id = 1036; Produces: Talk dirty reads to me These sound better than anything I would ever write in a romantic letter: “SQL Server a détecté une corruption de mémoire matérielle dans la base de données « %1! », à l’ID…
I know, I know I swore I’d never talk about variables again. Then I ran into some funny business. Maybe it was quite as funny as the Temp Table Ghosts, but hey. What’s as funny as temp tables? It’s in your heaaaaaaaad If I run this, what do you think will come back? Transact-SQL IF…
I need to start this blog post with a disclaimer: you should not be doing this. Hell, *I* should not be doing this. But when SQL Server 2017 came out Monday, I noticed a few unusual SNAPSHOT_MATERIALIZATION entries in sys.messages and a few related undocumented system objects that hinted about a new feature Microsoft hadn’t…
I love answering questions about SQL My forum of choice is dba.stackexchange.com because I find the voting and point system with badges for being a decent internet person addictive. If you like more traditional forums, SQLServerCentral.com has a lot of really smart people on it as well. When I post questions or answers, I try…
True story You may find it hard to believe, but I recently had to fix a small bug in sp_BlitzCache and sp_BlitzQueryStore. Since both stored procedures have similar functions, they also share some temp table names (mainly the ones for parsing down XML nodes to more manageable chunks). In the window where I was making…
For this week’s What If series, we’re exploring what would happen if you had access to SQL Server’s source code – like if you got a job at Microsoft, signed a partner NDA, if the code leaked, or if it went open source. Today’s question is, “What would you look at first?” Brent says: I’d…
Top Secret For the sake of any lawyers out there reading, I want to start by saying we do not now, nor have we ever possessed SQL Server’s source code. I wouldn’t even know what to do with it if I did — I doubt it’s written in crayon. Heck, I’m not even competent enough…
Sometimes I need to reset stuff during performance training classes. I know some of you teach classes, too, and some of you just like doing crazy stuff. So here you go, a stored procedure to lose weight fast: DropIndexes for SQL Server 2016 & Newer Transact-SQL CREATE OR ALTER PROCEDURE dbo.DropIndexes @SchemaName NVARCHAR(255) = 'dbo',…
Oh, hey, happy Saturday First, I’d like to apologize to Conor Cunningham for the blatant theft of a blog title. That’s what you get for not posting in three years (like the desert miss the rain~). Why am I here? Why am I writing PowerShell, my sworn enemy? I do it for you. I’m trying…
Guess who I’m going to give you three queries, and you have to guess what the output will be before you run them. Here they are: Transact-SQL DECLARE @DatabaseName NVARCHAR(256) = N'' SELECT @DatabaseName = d.name FROM sys.databases d WHERE d.name = 'master' AND compatibility_level = 130 ORDER BY d.database_id PRINT @DatabaseName SELECT @DatabaseName =…
SQL Server has three ways to get execution plans from the plan cache: sys.dm_exec_query_plan – around since SQL Server 2005 sys.dm_exec_text_query_plan – added in 2005 SP2 sys.query_store_plan – new in SQL Server 2016 And there’s an important problem with the first one. To show it, let’s take one of my many bad ideas, building queries that take 12+…
I hate that you can do this Here’s the thing: I’m mostly writing this because I didn’t know you could do it. But it’s cool, because it’ll reinforce some other concepts, and I’ll show you why you shouldn’t do it. I’m talking, of course, about index hints. To be more specific, hinting multiple indexes on…