Nigel Rivett

New way to use up time

Published Wednesday, May 21, 2008 5:08 AM

Hello all,

My first attempt at a blog. Well second actually - I've just created another one for myself at http://nigelrivettblog.blogspot.com/. Anyway I'm trying to concentrate a bit more on contributing to this fine site.

I recently published an article on identities - it contains info that I would expect most people to know already but it's surprising how many don't know about scope_identity(), think the values are unique and sequential.

Next should be an article on a .net app that is driven by data in a table. I'm having a few problems with my .net dev environment at the moment but when that's sorted out...

Comments

 

Phil Factor said:

Well, it's good to see that you've got a grip on the technology. While you're around, do you know the answer to this ...
Why is this statement legal?

   Select 1+++++++++++++1

Try it. It works. it gives the answer 2. I discovered this by accident
Sadly ...
   Select 3--1
... gives the answer 3
May 21, 2008 6:55 AM
 

Phil Factor said:

I forgot to mention that ....
  Select 3+-+-+-+-+-+-+1
...gives the answer 4
May 21, 2008 7:14 AM
 

nigelrivett said:

Seem to recall this being raised before. Can't remember the response but guess it's just a foible.
1--1, it's using the -- to make the rest of the line a comment so anything aftrwards is ignored.

It looks like it's usng them as unary operators.
1+(+1), 1+(+(+1))
so that
1+-1 = 0
1+-+-1 = 2
1+-+-+-1 = 0

Interestingly in v2000 (just happened to have one available)
1+-1 gives an error
1+++1 = 2

So I would say that v2005 gives a justifiable result.
May 21, 2008 8:54 AM
 

nigelrivett said:

Correction - it seems to work the same way in v2000
i.e. 1+-1 = 0 not and error, I must have mistyped.

So it's using them as unary operators unless there's two minus signs in which case it becomes a comment.
May 21, 2008 9:00 AM
 

Ken3 said:

I think we have a potential new SQL Puzzle here. The best drawing which can be evaluated by a select statement

My entry  is this


select -1-+-1-
       0-2+2-0
        | 1 |
          0/
         1-1




(This is meant to be a sheeps head but hasn't come out as well as it did in SSMS.)
The answer, curiously, is 0
May 21, 2008 1:35 PM
 

Phil Factor said:

Nigel. Your first blog seems to have been unsuccessful. I just got a message saying
Blog not found
Sorry, the blog you were looking for does not exist. However, the name nigelrivett is available to register!

May 29, 2008 5:53 AM
 

nigelrivett said:

Thank's - looks like I had the wrong URL. I've corrected it now.
June 3, 2008 7:12 AM
You need to sign in to comment on this blog

















<May 2008>
SuMoTuWeThFrSa
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
Investigating SQL Server 2008 Wait Events with XEVENTS
 Some reasons for the slow-running of database applications aren't obvious. Occasionally, even the... Read more...

Controlling Email Messages using Exchange's Transport Rules
 Some tasks that should have been easy in previous versions of Exchange just weren't. Now, with... Read more...

Software Tool design: The Three Rs
 To understand the full extent of the requirements of your users when you are redesigning a software... Read more...

JSON and other data serialization languages
 The easiest way to speed up an Ajax application is to take out the 'X' and use JSON rather than XML. Of... Read more...

Embedding Help so it will be used
 It is not good enough to make assumptions about the way that users go about getting help when they use... Read more...