Ph: 1000200030004000

I want some Moore

Blog about stuff and things and stuff...
mostly about SQL server and .Net
posts - 159, comments - 1455, trackbacks - 33

SQL Server 2005 evil DBA prank

Today I feel a bit evil minded so I thought I'd share this little prank-friendly function.

If you put this into a .Net Assembly you import to SQL Server as a function or a stored procedure

you can wreck some real havoc :)

 

private static void SQLPrank()
{
    Random r1 = new Random(DateTime.Now.Millisecond);
    int lowerBound = r1.Next(1000, 2000);
    int upperBound = r1.Next(3000, 4000);
    int randomNumber = r1.Next(1000, 4000);
    /*
    1000             2000             3000             4000
      |----------------|----------------|----------------|
      .....|...................................|..........
    random lower bound                  random upper bound
      ..........................|.........................
                        random number 
      |----|-----------------------------------|---------| 
       Exit          Normal operation             Wait
    */
    if (randomNumber >= 1000 && randomNumber < lowerBound)
        Environment.Exit(0);            
    else if (randomNumber >= upperBound && randomNumber < 4000)
        Thread.Sleep(5000);
}

 

The gem here is the Environment.Exit(0) which shuts down SQL Server without anyone having a clue why.

This is perfect for a prank on your least favorite DBA or developer. :)

 

kick it on DotNetKicks.com

Print | posted on Thursday, November 15, 2007 10:05 PM

Feedback

# re: SQL Server 2005 evil DBA prank

I always thought a cruel prank was to set up an "instead of" trigger that did nothing!
11/16/2007 8:29 AM | Matt G

# re: SQL Server 2005 evil DBA prank

uuuu... combined with this in an instead triiger... ufff!! :))
that would be something!
11/16/2007 10:24 AM | Mladen

# re: SQL Server 2005 evil DBA prank

Wow - dunno what to say to that one. That would stump anyone for hours and hours. I would not be your friend when I found out the true answer :) Also good is the "old standby":

ALTER PROC GetEmployeeInfo (@EmpId INT)
AS
IF USER = 'Mike'
WAITFOR DELAY '00:00:07'

SELECT * FROM EmployeeId=@EmpId
GO
11/16/2007 11:08 AM | Scott Whigham

Post Comment

Title Please enter a title
Name Please enter your name
Email Email is not required, but it must be valid if specified.
Url Url is not required, but it must be valid if specified.
Comment  Please enter a comment
Please enter the answer to the supplied question.Please add 2 and 1 and type the answer here:
[image]Please enter the correct word

Powered by:
[image] [image]


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser