Concatenate String Using Regular SELECT

-- Create "WebUsers" table CREATE TABLE WebUsers( Id INT PRIMARY KEY IDENTITY(1,1), Email VARCHAR(200) UNIQUE ) -- Declare variable to concatenate string DECLARE @result VARCHAR(MAX) = '' -- Execute retrieve process SELECT @result = @result +',' + u.Email FROM WebUsers u -- Tweak and show query result SET @result = SUBSTRING(@result,2,LEN(@result)) PRINT @result

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.