I am not recommending that you use this but query, I am posting it for reference. It will produce the same result and it's easier to read & understand.
DECLARE @listStr VARCHAR(MAX)='insert into tablename values (';
SELECT @listStr = @listStr+''''+Name+''','
FROM sys.all_columns WHERE object_id = object_id ('you table');
Alternatively, you can do it like this...
SELECT @listStr='insert into tablename values ('+
( SELECT ''''+Name+''''+','
WHERE object_id = object_id ('reports.dbo.wt_rpt_peo_educ_lang')
FOR XML PATH(''))+')';
Koen did a great job explaining your query. I just wanted to include a couple alternatives that do the same thing and are easier to understand.
-- Alan Burstein
Best practices for getting help on SQLServerCentral
Need to split a string? Try DelimitedSplit8K
Need a pattern-based splitter? Try PatternSplitCM
Need to remove or replace those unwanted characters? Try PatExclude8K
. "I can't stress enough the importance of switching from a 'sequential files' mindset to 'set-based' thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code. " -- Itzek Ben-Gan 2001