|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 3:36 AM
Points: 2,522,
Visits: 3,616
|
|
Hi Openminded, I am not sure what your question is. But here is a transformation of the selects you gave which might be helpful to you. Just remember that the unary plus (+) or minus (-) have a higher precedence than multiplication or division, which in turn also have a higher precedence than addition or substration. Finally the calculation is executed from left to right (if not overridden by the precedence of operators or parentheses):
select 1 - 2 This is a simple substraction
select 1 + 1 * 2 This translates to 1 + (1 * 2)
select 1 +-+ 1 * 2 This translates to (1 + ((-(+1)) * 2))
select 1 +0+ 1 * 2 This translates to ((1 + 0) + (1 * 2))
select 1 ++ 1 * 2 This translates to (1 + ((+1) * 2))
Best Regards,
Chris Büttner
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, April 11, 2013 12:58 AM
Points: 174,
Visits: 555
|
|
| @christian That was perfect. Thanks.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Monday, January 28, 2013 9:41 PM
Points: 179,
Visits: 157
|
|
Thanks.. Now I understand.
I was wondering what happened to '-'
Also, why not it work like this:
'-' being string, other two can implicitly convert to string?
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 3:36 AM
Points: 2,522,
Visits: 3,616
|
|
You are welcome, Open Minded
Best Regards,
Chris Büttner
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 3:03 PM
Points: 5,233,
Visits: 7,032
|
|
krishnaroopa (7/1/2010) Also, why not it work like this:
'-' being string, other two can implicitly convert to string? They can, but they won't. SQL Server uses well-defined rules for data type precedence for implicit conversions. Lower predence data types will always convert to higher precedence data types; never the other way around. These rules are documented in Books Online. Use the index to find "data types [SQL Server]], precedence". Or read through the discussion, I believe I posted a link to this subject in the online version of BOL on one of the first pages.
Hugo Kornelis, SQL Server MVP Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Today @ 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 2:02 PM
Points: 3,788,
Visits: 5,543
|
|
edited: never mind
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller Stop, children, what's that sound? -- Stephen Stills
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 1:10 PM
Points: 7,084,
Visits: 7,137
|
|
Definitely a fun question - and interesting discussion. But, as Christian pointed out, "Print vagaries" is not the right title for this.
Tom Que conclure à la fin de tous mes longs propos? C'est que les préjugés sont la raison des sots. (Voltaire, 1756)
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 1:10 PM
Points: 7,084,
Visits: 7,137
|
|
Hugo Kornelis (7/2/2010) These rules are documented in Books Online. Use the index to find "data types [SQL Server]], precedence". Or read through the discussion, I believe I posted a link to this subject in the online version of BOL on one of the first pages. No, the link is in one of Christian's posts (the 8th post in this topic) but not in either of your posts in the first 30 in this topic (where it would have been redundant after Christian's post).
Tom Que conclure à la fin de tous mes longs propos? C'est que les préjugés sont la raison des sots. (Voltaire, 1756)
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Wednesday, March 27, 2013 9:32 AM
Points: 336,
Visits: 152
|
|
interesting question!
Regards, Suresh
|
|
|
|