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: Wednesday, September 3, 2014 1:12 AM
Points: 370, Visits: 716
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: Friday, September 5, 2014 2:00 PM
Points: 2,160, Visits: 2,191
Nice question thanks!
Post #945182
Posted Tuesday, June 29, 2010 11:14 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, August 28, 2014 2:39 AM
Points: 1,880, Visits: 2,846
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: Wednesday, July 16, 2014 6:22 AM
Points: 271, Visits: 96
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: Tuesday, September 16, 2014 5:48 AM
Points: 3,241, Visits: 5,002
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
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, August 5, 2014 2:43 AM
Points: 2,086, Visits: 105
Good question!!! Thanks!
Post #945228
Posted Wednesday, June 30, 2010 12:57 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 1:05 AM
Points: 2,842, Visits: 3,875
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