How to Throttle Logins to SQL Server

So, uh, you can use WAITFOR in a logon trigger:

You probably don’t want it to be TOO long, lest their app report it as a connection timeout. You want it just slow enough to make them angry.

I mean, theoretically. I would certainly never do anything like this. And I’m certainly not as diabolical as Dave Dustin:

https://twitter.com/venzann/status/959509799401529344

And as long as I’m talking about triggers, Marc Brooks had a request:

Sure! Here you go:

That one’s an especially bad idea because it’ll likely break 3rd party apps and maybe even SQL Server upgrades.

And I know what you’re thinking: does that trick work in TempDB? Kinda – it prevents the creation of “regular” tables, like dbo.Whatever, but it doesn’t prevent the creation of temp tables.

Free, 3× a week

Get my new posts by email

Three posts a week, plus a Monday roundup of the best database news from around the web.

7 comments

  1. I found a practical use for this:

    CREATE OR ALTER TRIGGER VendorWatcher ON ALL SERVER FOR LOGON AS
    BEGIN
    IF ORIGINAL_LOGIN()= ‘EandCService’

    EXEC msdb.dbo.sp_send_dbmail
    @profile_name = ‘NoReply’,
    @recipients = ‘nunya@business.org’,
    @subject = ‘The vendor is up to no good again.’ ,
    @execute_query_database = ‘Master’,
    @body = ‘Call them now.’,
    @body_format = ‘html’

    END;
    GO

Leave a comment

Your email address will not be published. Required fields are marked *

Email me about new comments: