Log in  ::  Register  ::  Not logged in

 Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 PRINT vagaries Rate Topic Display Mode Topic Options
Author
 Message
 Posted Thursday, July 1, 2010 2:32 AM
 SSCrazy Group: General Forum Members Last Login: Tuesday, December 1, 2015 6:09 AM Points: 2,891, Visits: 3,889
 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 - 2This is a simple substractionselect 1 + 1 * 2This translates to 1 + (1 * 2) select 1 +-+ 1 * 2This translates to (1 + ((-(+1)) * 2))select 1 +0+ 1 * 2This translates to ((1 + 0) + (1 * 2))select 1 ++ 1 * 2This translates to (1 + ((+1) * 2)) Best Regards, Chris Büttner
Post #945998
 Posted Thursday, July 1, 2010 3:16 AM
 SSC-Enthusiastic Group: General Forum Members Last Login: Monday, August 18, 2014 4:04 AM Points: 176, Visits: 567
 @christian That was perfect. Thanks.
Post #946010
 Posted Thursday, July 1, 2010 10:27 PM
 SSC-Enthusiastic Group: General Forum Members Last Login: Thursday, May 21, 2015 2:00 AM Points: 182, Visits: 168
 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?
Post #946578
 Posted Friday, July 2, 2010 12:42 AM
 SSCrazy Group: General Forum Members Last Login: Tuesday, December 1, 2015 6:09 AM Points: 2,891, Visits: 3,889
 You are welcome, Open Minded Best Regards, Chris Büttner
Post #946607
 Posted Friday, July 2, 2010 1:57 AM
 SSCertifiable Group: General Forum Members Last Login: Today @ 9:45 AM Points: 7,765, Visits: 11,371
 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 MVPVisit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #946632
 Posted Wednesday, July 7, 2010 2:59 PM
 SSC-Insane Group: General Forum Members Last Login: Monday, November 21, 2016 11:03 AM Points: 20,009, Visits: 18,255
 Nice question - thx Jason AKA CirqueDeSQLeilI have given a name to my pain...MCM SQL Server, MVPSQL RNNRPosting Performance Based Questions - Gail Shaw
Post #948861
 Posted Thursday, July 8, 2010 10:08 PM
 Hall of Fame Group: General Forum Members Last Login: Tuesday, November 29, 2016 2:42 PM Points: 3,370, Visits: 6,889
 edited: never mind __________________________________________________Against stupidity the gods themselves contend in vain. -- Friedrich Schiller Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
Post #949712
 Posted Friday, July 9, 2010 7:25 AM
 SSCrazy Eights Group: General Forum Members Last Login: Today @ 9:19 AM Points: 9,822, Visits: 11,891
 Definitely a fun question - and interesting discussion. But, as Christian pointed out, "Print vagaries" is not the right title for this. Tom
Post #949947
 Posted Friday, July 9, 2010 7:33 AM
 SSCrazy Eights Group: General Forum Members Last Login: Today @ 9:19 AM Points: 9,822, Visits: 11,891
 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
Post #949954
 Posted Friday, July 9, 2010 11:21 AM
 Old Hand Group: General Forum Members Last Login: Wednesday, April 1, 2015 5:22 PM Points: 354, Visits: 216
 interesting question! Suresh
Post #950127

 Permissions