Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12345»»»

PRINT vagaries Expand / Collapse
Author
Message
Posted Tuesday, June 29, 2010 9:45 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, October 22, 2013 5:44 PM
Points: 368, Visits: 714
Comments posted to this topic are about the item PRINT vagaries
Post #945180
Posted Tuesday, June 29, 2010 9:53 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, March 27, 2014 8:50 AM
Points: 2,163, Visits: 2,184
Nice question thanks!
Post #945182
Posted Tuesday, June 29, 2010 11:14 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Wednesday, April 09, 2014 12:58 AM
Points: 1,904, Visits: 2,771
Good tricky one...thank you

----------------------------------------------
Msg 8134, Level 16, State 1, Line 1
Divide by zero error encountered.
Post #945206
Posted Wednesday, June 30, 2010 12:06 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, September 09, 2013 7:57 AM
Points: 267, Visits: 93
Interesting & tricky!!
Post #945219
Posted Wednesday, June 30, 2010 12:13 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, July 22, 2013 1:05 AM
Points: 248, Visits: 373

Yes.. it is tricky, this query also results the same..

PRINT LEN(@StringArray) + '-' + LEN(@Delimiter)



KSB
-----------------------------
Thousands of candles can be lit from a single candle, and the life of the candle will not be shortened. Knowledge and happiness never decreases by being shared.” - Buddha
Post #945221
Posted Wednesday, June 30, 2010 12:33 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 10:46 AM
Points: 3,241, Visits: 4,987
Good question..

And its because the datatype of the variables ( @lenStringArray and @lenDelimiter) is INT.



----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Sometimes, winning is not an issue but trying.

You can check my BLOG here

Post #945226
Posted Wednesday, June 30, 2010 12:35 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, March 18, 2014 4:00 AM
Points: 1,969, Visits: 98
Good question!!! Thanks!
Post #945228
Posted Wednesday, June 30, 2010 12:57 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 7:19 AM
Points: 2,814, Visits: 3,851
Nice question, but this is not a "PRINT vagary". Instead this is just how type conversion works (http://msdn.microsoft.com/en-us/library/ms190309.aspx).

SELECT @lenStringArray + '-' + @lenDelimiter

behaves the same way, because int (@lenStringArray & @lenDelimiter) has a higher precedence than varchar(1) ('_').


Best Regards,
Chris Büttner
Post #945236
Posted Wednesday, June 30, 2010 1:29 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, May 14, 2013 11:41 AM
Points: 77, Visits: 218
I'm surprised but is true:

Select Cast( '+' as int ) --> 0
Select Cast( '-' as int ) --> 0
Post #945256
Posted Wednesday, June 30, 2010 2:04 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, May 23, 2012 5:39 AM
Points: 169, Visits: 49
Yes, that's reason, because the result of an implicit casting of '-' is zero
SELECT 6 + 1 + '-'

Post #945276
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse