Hallo friends... is this possible ... I have two tables whereby I want to insert to table 2 by selecting from table 1 and then delete all the data in table 1
Is this possible
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Rajanikant HawaldarRank #110 · 20.2K reputationPosted Sep 30, 2022, 2:35 AM EDT
check it
with delete_cte as (delete from table 1 returning *) insert into table 2 select * from delete_cte;Vishal JoshiRank #377 · 6.7K reputationPosted Sep 30, 2022, 2:29 AM EDT
Hello,
Yes, it's possible. please find below a sample SQL server query to achieve the same.
-- Insert value from Table_1 to Table_2 INSERT INTO Table_2 SELECT ID,Value,Type FROM Table_1 WITH(NOLOCK) -- We can add where clause to insert diffrent value -- Insert value from Table_1 to Table_3 INSERT INTO Table_3 SELECT ID,Value,Type FROM Table_1 WITH(NOLOCK) --Delete values from Table_1 DELETE FROM Table_1 --We can also use truncate --TRUNCATE TABLE Table_1