Click here to monitor SSC

New way to use up time

Published 20 May 2008 11:08 pm

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…

7 Responses to “New way to use up time”

  1. Phil Factor says:

    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

  2. Phil Factor says:

    I forgot to mention that ….
    Select 3+-+-+-+-+-+-+1
    …gives the answer 4

  3. nigelrivett says:

    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.

  4. nigelrivett says:

    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.

  5. Ken3 says:

    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

  6. Phil Factor says:

    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!

  7. nigelrivett says:

    Thank’s – looks like I had the wrong URL. I’ve corrected it now.

Leave a Reply