﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by bitbucket  / STUFF - 1 / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sun, 19 May 2013 03:12:51 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>When the question says "I then execute (second SELECT statement) that implies to me that you execute ONLY that SELECt statement, which would give an error, as the variable is not defined.I am taking the question literally.  Is that wrong?D</description><pubDate>Mon, 24 Dec 2012 18:06:17 GMT</pubDate><dc:creator>Dr. Diana Dee</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>really very good question. i answered it in hurry, but after i check it again and got the reason behind the answer.thanks</description><pubDate>Mon, 03 Dec 2012 06:45:55 GMT</pubDate><dc:creator>Danny Ocean</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>Simple but tricky One.</description><pubDate>Thu, 29 Nov 2012 08:34:47 GMT</pubDate><dc:creator>asifkareem</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>Nice question and I learned STUFF.</description><pubDate>Mon, 26 Nov 2012 10:47:22 GMT</pubDate><dc:creator>Meow Now</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>Thanks for the STUFF question.</description><pubDate>Mon, 26 Nov 2012 05:37:16 GMT</pubDate><dc:creator>(Bob Brown)  </dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>nice question for the week..+1 :-)learn about STUFF today</description><pubDate>Mon, 26 Nov 2012 00:41:04 GMT</pubDate><dc:creator>kapil_kk</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>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?</description><pubDate>Sat, 24 Nov 2012 02:47:52 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>Nice Stuff.T-SQL is Great</description><pubDate>Sat, 24 Nov 2012 02:39:01 GMT</pubDate><dc:creator>@Cassie</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>Nice question about a function that I do not use enough. Thanks for the question!</description><pubDate>Fri, 23 Nov 2012 12:54:57 GMT</pubDate><dc:creator>KWymore</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>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 [quote]I could not find an explanation of the "lengthing" of the declared item....[/quote]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:[code="sql"]DECLARE @string2 VARCHAR(50)set @string2 = STUFF(@string1, 11,0,@Stuffing)select @string2	  ,len(@string2)[/code]A truncated value of "Microsoft ******" or "Microsoft ********************" would hardly be acceptable.</description><pubDate>Fri, 23 Nov 2012 11:04:09 GMT</pubDate><dc:creator>john.arnott</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>[quote][b]kalyani.k478 (11/22/2012)[/b][hr]+1[/quote]+1 :-)</description><pubDate>Fri, 23 Nov 2012 10:28:41 GMT</pubDate><dc:creator>Revenant</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>Nice question.  I learned something new about T-SQL today.  Thanks!Andre Ranieri</description><pubDate>Fri, 23 Nov 2012 08:46:41 GMT</pubDate><dc:creator>Andre Ranieri</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>There's an explanation of sorts herehttp://msdn.microsoft.com/en-us/library/ms188043(SQL.105).aspx(in the comments section at the end)</description><pubDate>Fri, 23 Nov 2012 02:10:17 GMT</pubDate><dc:creator>Toreador</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>Thanks for a good question, I know about STUFF for replacing parts of strings but thought the '0' for the length parameter formed part of a trick question (i.e. insert no characters from @stuffing rather than delete no characters from @string1) so selected 16, not 46.Then after getting it wrong :-( and researching the question I found this comment from Zafar Yousafi in BOL:[quote]At first sight it might not be clear directly how to insert a character (or a string) instead of substituting characters in the original string.To insert a string, without replacing/substituting characters in the original string you need to specify a length of 0 (zero).SELECT STUFF('abcghi', 4, 0, 'DEF');-- this results in 'abcDEFghi'.[/quote]So, learned something new today - thanks!</description><pubDate>Fri, 23 Nov 2012 02:08:06 GMT</pubDate><dc:creator>derek.colley</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>Good question to end the week on, thanks Ron</description><pubDate>Fri, 23 Nov 2012 01:27:33 GMT</pubDate><dc:creator>Stewart "Arturius" Campbell</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>[quote][b]vk-kirov (11/22/2012)[/b][hr]Another question about different stuff :-)An interesting example of inserting one string into another. Never thought it could be done that way. I always did it using something like[code="sql"]SELECT LEFT(@string1, 10) + @Stuffing + RIGHT(@string1, LEN(@string1) - 10)[/code][/quote]STUFF is a very powerful function that can be used for many things, but unfortunately is not very well known. I have seen people struggle with RIGHT and REVERSE or SUBSTRING and LENGTH to cut off the first three characters of a string, instead of simply using STUFF(@string, 1, 3, '').Ron, thanks for this question. I hope it helps spread the knowledge about STUFF.</description><pubDate>Fri, 23 Nov 2012 01:16:20 GMT</pubDate><dc:creator>Hugo Kornelis</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>Nice question to end the week. Thanks Ron!</description><pubDate>Fri, 23 Nov 2012 00:49:36 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>Couldn't work out if it was a trick question or not - decided it wasn'tThanks for the point and the question Ron</description><pubDate>Fri, 23 Nov 2012 00:46:20 GMT</pubDate><dc:creator>Stuart Davies</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>+1</description><pubDate>Thu, 22 Nov 2012 23:07:16 GMT</pubDate><dc:creator>kalyani.k478</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>Another question about different stuff :-)An interesting example of inserting one string into another. Never thought it could be done that way. I always did it using something like[code="sql"]SELECT LEFT(@string1, 10) + @Stuffing + RIGHT(@string1, LEN(@string1) - 10)[/code]</description><pubDate>Thu, 22 Nov 2012 22:59:41 GMT</pubDate><dc:creator>vk-kirov</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>Thanks ,good question.. learn first time about STUFF and then answered it :-)</description><pubDate>Thu, 22 Nov 2012 22:54:14 GMT</pubDate><dc:creator>sanket kokane</dc:creator></item><item><title>RE: STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>nice :) thank you for the question(though it was simple and straight question, not sure why i kept occupied myself thinking as it was a trick question... :crazy:)</description><pubDate>Thu, 22 Nov 2012 22:29:32 GMT</pubDate><dc:creator>Raghavendra Mudugal</dc:creator></item><item><title>STUFF - 1</title><link>http://www.sqlservercentral.com/Forums/Topic1388011-1222-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/STUFF/94522/"&gt;STUFF - 1&lt;/A&gt;[/B]</description><pubDate>Thu, 22 Nov 2012 20:57:00 GMT</pubDate><dc:creator>bitbucket-25253</dc:creator></item></channel></rss>