• 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');

    SET @listStr=LEFT(@listStr,LEN(@listStr)-1)+')';

    SELECT @listStr;

    Alternatively, you can do it like this...

    SELECT @listStr='insert into tablename values ('+

    (SELECT ''''+Name+''''+','

    FROM sys.all_columns

    WHERE object_id = object_id ('reports.dbo.wt_rpt_peo_educ_lang')

    FOR XML PATH(''))+')';

    SELECT REPLACE(@listStr,',)',')')

    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.

    "I cant 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."

    -- Itzik Ben-Gan 2001