I am writing a stored proc in SQL Server.
It selects value from one table and inserts those values in another table.
IF <some condition>
DELETE from table1;
SELECT column1 FROM table2;
Insert into table3;
table3 has 2 columns, first one is an autogenerated number and second one needs to be fetched from table2 and inserted in table3.
Please tell me how to do this.