Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Article Discussions
»
Article Discussions by Author
»
Discuss content posted by bitbucket
»
STUFF - 1
23 posts, Page 1 of 3
1
2
3
»
»»
STUFF - 1
Rate Topic
Display Mode
Topic Options
Author
Message
bitbucket-25253
bitbucket-25253
Posted Thursday, November 22, 2012 8:57 PM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 8:06 AM
Points: 5,100,
Visits: 20,193
Comments posted to this topic are about the item
STUFF - 1
If everything seems to be going well, you have obviously overlooked something.
Ron
Please help us, help you -before posting a question please
read
Before posting a performance problem please
read
Post #1388011
Raghavendra Mudugal
Raghavendra Mudugal
Posted Thursday, November 22, 2012 10:29 PM
SSC-Addicted
Group: General Forum Members
Last Login: 2 days ago @ 9:56 AM
Points: 443,
Visits: 1,191
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...
)
ww; Raghu
--
There are only 10 types of people in the world, those who understand binary, and those who don't.
Note: (as of now) only.. 1 and 4 applies (i am on my way...)
Post #1388026
sanket kokane
sanket kokane
Posted Thursday, November 22, 2012 10:54 PM
Old Hand
Group: General Forum Members
Last Login: Thursday, May 16, 2013 9:49 PM
Points: 323,
Visits: 960
Thanks ,good question.. learn first time about STUFF and then answered it
-----------------------------------------------------------------------------
संकेत कोकणे
Post #1388034
vk-kirov
vk-kirov
Posted Thursday, November 22, 2012 10:59 PM
Hall of Fame
Group: General Forum Members
Last Login: 2 days ago @ 1:32 AM
Points: 3,187,
Visits: 4,140
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
SELECT LEFT(@string1, 10) + @Stuffing + RIGHT(@string1, LEN(@string1) - 10)
Post #1388035
kalyani.k478
kalyani.k478
Posted Thursday, November 22, 2012 11:07 PM
SSChasing Mays
Group: General Forum Members
Last Login: Wednesday, February 20, 2013 1:45 AM
Points: 616,
Visits: 97
+1
Post #1388041
Stuart Davies
Stuart Davies
Posted Friday, November 23, 2012 12:46 AM
SSCrazy
Group: General Forum Members
Last Login: 2 days ago @ 1:19 AM
Points: 2,473,
Visits: 2,131
Couldn't work out if it was a trick question or not - decided it wasn't
Thanks for the point and the question Ron
-------------------------------
Posting Data Etiquette - Jeff Moden
Smart way to ask a question
There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
Post #1388066
Koen Verbeeck
Koen Verbeeck
Posted Friday, November 23, 2012 12:49 AM
SSCrazy Eights
Group: General Forum Members
Last Login: 2 days ago @ 6:54 AM
Points: 9,364,
Visits: 6,462
Nice question to end the week. Thanks Ron!
How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
Member of
LinkedIn
. My blog at
LessThanDot
.
MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1388067
Hugo Kornelis
Hugo Kornelis
Posted Friday, November 23, 2012 1:16 AM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 11:51 AM
Points: 5,232,
Visits: 7,023
vk-kirov (11/22/2012)
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
SELECT LEFT(@string1, 10) + @Stuffing + RIGHT(@string1, LEN(@string1) - 10)
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.
Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog:
http://sqlblog.com/blogs/hugo_kornelis
Post #1388071
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
Posted Friday, November 23, 2012 1:27 AM
Hall of Fame
Group: General Forum Members
Last Login: 2 days ago @ 1:49 AM
Points: 3,123,
Visits: 4,310
Good question to end the week on, thanks Ron
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1388075
derek.colley
derek.colley
Posted Friday, November 23, 2012 2:08 AM
SSC-Addicted
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 3:40 AM
Points: 496,
Visits: 583
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:
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'.
So, learned something new today - thanks!
---
Note to developers:
CAST(SUBSTRING(CAST(FLOOR(NULLIF(ISNULL(COALESCE(1,NULL),NULL),NULL)) AS CHAR(1)),1,1) AS INT) == 1
So why complicate your code AND MAKE MY JOB HARDER??!
Want to get the best help? Click here
http://www.sqlservercentral.com/articles/Best+Practices/61537/
(Jeff Moden)
My blog:
http://uksqldba.blogspot.com
Visit
http://www.DerekColley.co.uk
to find out more about me.
Post #1388079
« Prev Topic
|
Next Topic »
23 posts, Page 1 of 3
1
2
3
»
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.