No space queries
2April 13, 2017 by Kenneth Fisher
You know, sometimes you get a silly idea in your head and you just HAVE to try it out. The idea? Can I write a query without any white space? No spaces, no carriage returns etc. As it happens, yes. Yes I can.
SELECT*FROM[Person].[Person]WHERE[LastName]='Duffy';
You’ll notice I had to use brackets to make it work. So just for fun here is another version without the brackets but using carriage returns instead.
SELECT * FROM Person . Person WHERE LastName = 'Duffy' ;
Fair warning though, I’m pretty sure this is going to be a typical response if you ask for a code review on this type of thing:
In case you are wondering, the lesson you should have learned from this is not “I can write even more obnoxious looking queries now”. What you should learn is that if you have an idea for something that might work, it’s worth trying it out and finding out for yourself.
If you don’t already subscribe to the notion of having an idea and trying it out to see if it works, I feel real sorry for your users. After all isn’t that the basis of a design-build-test-deploy development lifecycle?
Sure, but there is a difference between work related tasks and random one off thoughts. Or between having an environment that can use to test and setting up an environment (tables, data etc) to try something out outside of even your dev environment.