I like the way both variables are declared varchar(100)just in case you want them to be 'YYYYYYYYEEEEEEESSSSSSS' or something like that. Why send a bit when 100 bytes will work? Unfortunately, he didn't use nvarchar(100) so this is clearly not suitable for international applications.

It is a case of enmeshed double-backloop logic, in which the truth of the opposite does not necessarily imply the falsness of the other, nor does it negate the other way around if the same becomes truly false.

See? Simple!

It's that higher system Godel implied which can express the contradictory/recursive/closured logic found in our current system.

I dont know this code context...but..I hope those values arent being used later on (umm..then, what's the point to initialize them?) because the possible values of @Online and @Offline are: ('Y','N','').

So, it's a FileNotFound inside a FileNotFound.In fact, if @OnlineOffline='Both',at least it gets "consistent" values for @Online and @Offline...

The application was written with separate variables for Online and Offline, because the author was stupid. Thousands of features were added which depend on having these two variables.

A smarter person said "these are the same variable" and created the OnlineOffline variable. For compatibility, he used it to set the original two variables, so he didn't have to fix the old code.

Along comes someone either stupid or brilliant (or more likely brillant), who says "there's actually a third mode which is both online AND offline" and creates the "Both" value.

And of course, a rarely-used function deep in the bowels of the system sets the OnlineOffline variable to "FileNotFound", which breaks everything.

As far as I can see the @Online variable will always have one of the two values null or 'Y' and @Offline variable will always have one of the two values null or 'N'. I am not sure what he does with the values.

I think this SQL fragment is the equivalent of Abbot & Costello's "Who's on First" skit. Or maybe that scene from Airplane 2: "Unger, didn't you serve under Oveur in the Air Force?" "Not directly. Technically, Dunn was under Oveur and I was under Dunn." Et cetera.

what about systems that allow multiple connections? One could be online, the other offline; Of course, then an intelligent person would have 2 flags: loggedInChannelOne and loggedInChannel2, but hey, what do I know?

Yes, I believe you are right, it's a godel thingy.
Still .. if you are neither online, nor offline, and i accept that is follows that you have to be both, I still dont accept you are either ...

At least that's wat my tortoise named Achilles claimes

It's really quite simple: as long as you accept that
x) you have to be both online and offline, and
y) (a AND b) IMPLIES a (similarly, (a AND b) IMPLIES b)
then because ((p IMPLIES q) AND p) IMPLIES q
z) you have to be online (similarly, you have to be offline)

As I said in my first post, the solution is less than perfect, but it works pretty well. It is clearly not a WTF.

The reason I did it my way rather than your way is yours does not deal with @OnlineOffline and isOnline both being the same, invalid value. Both could be 'Space Shuttle' and it would be returned. Doing the @a = 'Y' and @b = 'Y' would be the same as @a = 'Y' and @a = @b, with one fewer variable references. I don't have the DB schema, so I don't know whether isOnline would be enum'd into only Y or N values, in which case yours would be the same effect. But for a non enum'd varchar(100), @OnlineOffLine = isOnline could return false positives.

As I said in my first post, the solution is less than perfect, but it works pretty well. It is clearly not a WTF.

Oh, I disagree. The code shouldn't have to be a failure in order to qualify as a WTF. A function or code snippet can be technically exactly functional, may even be a smart solution to a problem in its context, and yet generate that "WTF?" reaction upon reading. I think this is an excellent example: when I saw the post, I could not possibly imagine what the author had intended, and yet you and fennec came up with an entirely plausible explanation. Kudos to you both.

isOnline should be a BOOLEAN, but (as of SQL:2003) BOOLEAN is optional because people keep arguing about how NULL and/or UNKNOWN (sound familiar?) should be handled. PostgreSQL gets it right (I wish I could use PostgreSQL at work), everyone else has an ugly-but-good-enough equivalent (BIT is MS SQL's), which makes Joe Celko roll in his grave (despite the minor detail that he isn't actually dead).

I like the way both variables are declared varchar(100)just in case you want them to be 'YYYYYYYYEEEEEEESSSSSSS' or something like that. Why send a bit when 100 bytes will work? Unfortunately, he didn't use nvarchar(100) so this is clearly not suitable for international applications.

Its a 'varchar', so the db will store up to 100 bytes, depending on what was in the field. Unlike a 'char' type, which would always store exactly 100 bytes, regardless of the field's value. So that in of itself isnt a big deal.

I'm guessing there's some appendix code here somewhere. Offline is either 'N' or null, Online is either 'Y' or null. I haven't even touched on the fact that we don't see what may have happened to OnlineOffline prior to this snippet, and assuming it's also varchar(100), the value could be just about anything. Hm, what happens then?

--- this one, and only this one, is equivalent to SELECT * FROM some_user_table

Of course this does assume a couple of things about the database (mostly that comparing to the default value / null of the variable is okay to do and doesn't return any extraneous rows - presumably the column IS NOT NULL - and 'Y'/'N' are the only values). And it's a fairly lousy way to do things, all told, really. But anywho. :)