Fun with SQL part 2
Last time we looked at some easy tricks to tease your co-worker when you have only a few seconds.
Like when he or she is away from his computer and Management Studio is open.
In this post we will explore some more.
Again, this is for fun. Never do this on Production!
Ready? Set? Go?
You might not be aware of this, but GO isn't actual an SQL command.
It is merely a seperator in Management Studio to indicate that Queries seperated by GO should be executed one by one.
There is even a Setting for this under Tools, Options, Query Execution:
Since it is a Setting, it can be changed.
Can you imagine when you change it to FROM?
No, you should really try it and run any Select Statement after that!
p.s. It would only affect queries in windows opened after the change.
Where did that Column go? It is still there?
A bit evil, but you can rename an often used Column but only make a subtle change. Like adding a Tab in the name:
Make sure you add a Tab and not a Space since that one will be trimmed. From now on, this Query will fail because the Column does not exist:
from Absences
Additional bous is that the Column still shows up in the Onject Explorer.
And you will see it when you do a "select * from Absences".
But that is because the Tab is not visible there.
Is your co-worker getting desperate? Simply rename it back to its original name.
It works on my machine
This one is fun when you are working together and it doesn't require you to have access to your co-worker's machine.
First you need to find your login name with this:
Now go and copy what value and use it add a Constrain to a View you are working on, like this:
Since this one is only True when you run it, it will produce no results at all for anyone else.
That's it for today
Yes, we're done for today. Now go back to work and be kind for your co-workers.
You can leave a comment or send a question to andre@andrespeek.com. Let me know if you got inspired and stay safe and healthy always!