There are cases when you need to generate a comma separated
string for 'IN' clause in a Select statement. For example:
SELECT *
FROM SomeTable
WHERE SomeColumn IN (xxx,yyyy,www,zzzz)
Let`s assume that you have some values separated by Enter,
like this:
42344
32432
54435
45345
43534
45243
This also can be the result of copying some column values
from a select in the SSMS:
Ok, suppose you copied these values and pasted them in MS Word
document. The quickest way to replace the Enters with commas
is to use Find and Replace option (Ctrl-H)
Press Ctrl-H and enter the following:
Now click on "Replace All" button:
Here are some more useful codes you can use:
TAB CHARACTER
Type ^t or type ^9
ANY DIGIT
Type ^#
ANY LETTER
Type ^$
You can see more codes here
Note: All this above can be also done in SSMS by using Regular Expressions:
See my post about it.
Note: All this above can be also done in SSMS by using Regular Expressions:
See my post about it.
P.S: do you know the way how to do this in Notepad?
I think it is not possible , because the "Replace" dialog box
in Notepad does not work with non-printing characters.
I will be glad to know if I am wrong.
Wow! This is what I call useful info on the web. Cheers!
ReplyDeleteHi, These was very useful for me, thanks! I have always wondered what is "enter" "character" when you do replace in Excel or Word.
ReplyDeleteHi, this was very useful. Thanks for sharing the info.
ReplyDeleteExtremely useful tip. Would have never found out that ^p refers to Enter. Thanks.
ReplyDeletenice one thank you
ReplyDeleteI Needed this SO MUCH!!! Outstanding!!
ReplyDeletethank you so much!! this helped me alot
ReplyDeleteNice one, Thanks you
ReplyDeleteAnd all these years later this just saved me a LOT of time. THANKS!
ReplyDeleteThis is something I have not seen before. Thanks the replace commas with new lines.
ReplyDeleteRegards
How To Code
you made my life today, hats off
ReplyDeleteVery help full. thanks brother.
ReplyDeleteNice work, Brother
ReplyDeleteAwesome article very helpful to me. Find and Replace in Word
ReplyDeleteThanks FOR GIVING US SUCH A NICE AND SIMPLE INFORMATION Word Find & Replace Software
ReplyDeleteThanks for sharing this article with us. This article is so helpful for us
ReplyDeleteAdvance Word Find and Replace.
thanks bro
ReplyDeletethanks alots this was helpful
ReplyDelete