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
Finding Stuff in SQL Server Database DDL
 You'd have thought that nothing would be easier than using SQL Server Management Studio (SSMS) for... Read more...

Mission Critical: SQL Server 2008 Performance Tuning Task List
 In which Buck Woody imagines how the US military would have tackled DBA checklists for... Read more...

Simple Query tuning with STATISTICS IO and Execution plans
 A great deal can be gleaned from the use of the STATISTICS IO and the execution plan, when you are... Read more...

Switching rows and columns in SQL
 When they use SQL Server, one the commoner questions that Ms Access programmers ask is 'Where's the... Read more...

Writing Efficient SQL: Set-Based Speed Phreakery
 Phil Factor's SQL Speed Phreak challenge is an event where coders battle to produce the fastest code to... Read more...