No space queries

2

April 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.

2 thoughts on “No space queries

  1. bad Oedipus says:

    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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 2,148 other followers

Follow me on Twitter

ToadWorld Pro of the Month November 2013
%d bloggers like this: