In this article I will explain how to write a query to concatenate row values in SQL server.
DECLARE @name NVARCHAR(MAX)
SELECT @name = COALESCE(@name + ',', '') + UserName FROM UserDetails
SELECT UserNames =
@name
|
DECLARE @name NVARCHAR(MAX)
SET @name=''
SELECT @name =
@name +','+UserName FROM UserDetails
SET @name = Substring(@name, 2, (len(@name)))
SELECT @name as
UserNames
|
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|


Subscribe by RSS
Subscribe by Email
2 comments :
Dear Sir, Could you please explain the second method step by step please i am not getting, first method also showing error
Please update dynamic query to bind the data for reports table from dropdown based selected values