• Hi , I want to ask a question ,

    Is it possible executing dynamic sql and store values in a temp table with WITH clause like below code?

    DECLARE @sqltxt nvarchar(max) ;

    SET @sqltxt='select col112,col221 from sometable';

    WITH temptable (col1,col2) as

    (exec sp_executesql @sqltxt )

    select * from temptable

    Or how can I achive this task with sql?

    Thanks.