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 ««123»»

STUFF - 1 Expand / Collapse
Author
Message
Posted Friday, November 23, 2012 2:10 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, May 17, 2013 9:52 AM
Points: 1,356, Visits: 4,761
There's an explanation of sorts here
http://msdn.microsoft.com/en-us/library/ms188043(SQL.105).aspx
(in the comments section at the end)
Post #1388081
Posted Friday, November 23, 2012 8:46 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 4:56 PM
Points: 277, Visits: 201
Nice question. I learned something new about T-SQL today. Thanks!

Andre Ranieri
Post #1388188
Posted Friday, November 23, 2012 10:28 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: Today @ 2:42 PM
Points: 3,457, Visits: 2,532
kalyani.k478 (11/22/2012)
+1

+1
Post #1388211
Posted Friday, November 23, 2012 11:04 AM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Wednesday, April 17, 2013 10:57 PM
Points: 1,491, Visits: 3,008
First, thank you for prodding me to read about STUFF, a function I'd seen mentioned but which I haven't used.

Your explanation of answer starts with
I could not find an explanation of the "lengthing" of the declared item....

This was the point I considered after reading the BOL entry and before choosing my answer. The given QOD code does not assign the modified value to either of the variables. The function may return data with a type inherited from the input, but the length of the function's output is not constrained by the lenghth of either input string. Consider what you may naturally expect if you were to add these lines to the end of the given script:
DECLARE @string2 VARCHAR(50)

set @string2 = STUFF(@string1, 11,0,@Stuffing)
select @string2
,len(@string2)

A truncated value of "Microsoft ******" or "Microsoft ********************" would hardly be acceptable.
Post #1388218
Posted Friday, November 23, 2012 12:54 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 1:57 PM
Points: 2,575, Visits: 1,533
Nice question about a function that I do not use enough. Thanks for the question!
Post #1388242
Posted Saturday, November 24, 2012 2:39 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Wednesday, April 24, 2013 2:28 PM
Points: 515, Visits: 119
Nice Stuff.

T-SQL is Great
Post #1388292
Posted Saturday, November 24, 2012 2:47 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:07 PM
Points: 7,096, Visits: 7,156
Nice question - and a reminder to me to use STUFF more often.

I don't understand why the explanation worries about the result length. . I agree with John Arnott's comments above about this. String functions either do or don't have a length parameter, and the ones that don't have a resulting length that can be any valid length (except MAX, unless a parameter of the function is declared with length MAX). Why should anyone expect STUFF to behave differently from + in this respect?


Tom
Que conclure à la fin de tous mes longs propos? C'est que les préjugés sont la raison des sots. (Voltaire, 1756)
Post #1388293
Posted Monday, November 26, 2012 12:41 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Sunday, May 19, 2013 11:16 PM
Points: 1,061, Visits: 1,151
nice question for the week..
+1
learn about STUFF today
Post #1388452
Posted Monday, November 26, 2012 5:37 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Friday, April 19, 2013 10:27 AM
Points: 690, Visits: 1,100
Thanks for the STUFF question.
Post #1388559
Posted Monday, November 26, 2012 10:47 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, May 15, 2013 2:15 PM
Points: 471, Visits: 485
Nice question and I learned STUFF.

Aigle de Guerre!
Post #1388726
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse