SQL Server: Concatenate Strings using the GROUP BY clause

In this post, I am sharing one script to perform concatenation of strings by applying GROUP BY in SQL Server.

I was performing one of the task for Production server report and required to merge strings based on GROUP BY columns.I have used only FOR XML PATH to get this solution.

First, create sample table and data.

Execute this script:

The Result:

Group String SQL Server


Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from dbrnd.com

Leave a Reply

7 Comments on "SQL Server: Concatenate Strings using the GROUP BY clause"

Notify of
avatar
Sort by:   newest | oldest | most voted
lena
Guest

Thanks very nice blog!

jorg
Guest

Hello, just wanted to tell you, I liked this article.

It was practical. Keep on posting!

Roy
Guest

Pretty! This was an incredibly wonderful post.
Many thanks for supplying these details.

Leo
Guest

I appreciate, cause I found just what I was looking for. You have ended my 4 day long hunt! God Bless you man. Have a nice day. Bye

Sandeep
Guest

Thanks, It works for us

John
Guest

Great post Sir!

Was struggling grasping this xml path stuff, but that example table did it for me.

Took me 5 minutes to get my queries right after trying it out using your example data first!

trackback

perfect post !
thanks

wpDiscuz