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
Microsoft Office Communications Server 2007 R2 – Part II
  Once you have set up Office Communication Server 2007 R2 to provide IM within the rganisation, the... Read more...

Mission Critical: Database Design
 There is nothing like a checklist to make sure you've completed all the tasks in designing a database,... Read more...

SQL Server Intellisense VS. Red Gate SQL Prompt
 Fabiano Amorim is hooked on today's Integrated Development Environments with built-in Intellisense, so... Read more...

Doug Crockford: Geek of the Week
  Doug Crockford is the man behind JavaScript Object Notation (JSON). He is a well-known critic of XML... Read more...

Raw Materials: Mirror, Mirror, on the Desk
 Seeing ourselves as we see ourselves. Read more...