Concatenate two or more rows single string in SQL
-
Hi I would like to share cool feature of SQL Server with you guys like: Please use the following query when concatenate two or more rows with comma (or any you want) in a single string.
SELECT STUFF((SELECT ',' + RTRIM(RegionDescription) FROM Region FOR XML PATH('')),1,1,'') AS 'Regions'
Please do let me know, if you have any doubt. Please provide "Vote" if this would be helpful.:rose: Thanks, Imdadhusen
sunaSaRa Imdadhusen +91 99095 44184 +91 02767 284464
-
Hi I would like to share cool feature of SQL Server with you guys like: Please use the following query when concatenate two or more rows with comma (or any you want) in a single string.
SELECT STUFF((SELECT ',' + RTRIM(RegionDescription) FROM Region FOR XML PATH('')),1,1,'') AS 'Regions'
Please do let me know, if you have any doubt. Please provide "Vote" if this would be helpful.:rose: Thanks, Imdadhusen
sunaSaRa Imdadhusen +91 99095 44184 +91 02767 284464
Good stuff. :)
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com
-
Hi I would like to share cool feature of SQL Server with you guys like: Please use the following query when concatenate two or more rows with comma (or any you want) in a single string.
SELECT STUFF((SELECT ',' + RTRIM(RegionDescription) FROM Region FOR XML PATH('')),1,1,'') AS 'Regions'
Please do let me know, if you have any doubt. Please provide "Vote" if this would be helpful.:rose: Thanks, Imdadhusen
sunaSaRa Imdadhusen +91 99095 44184 +91 02767 284464
Publish it as a tip/trick, that way people who are looking for it will find it. Your main audience here are people looking to help others and probably already know this method.
Never underestimate the power of human stupidity RAH
-
Publish it as a tip/trick, that way people who are looking for it will find it. Your main audience here are people looking to help others and probably already know this method.
Never underestimate the power of human stupidity RAH
Thanks for your suggestions, i will be share this on Tips/Tricks sections
sunaSaRa Imdadhusen +91 99095 44184 +91 02767 284464