Last post Mar 22, 2019 06:59 PM by BillJordan
Mar 20, 2019 11:48 AM|binustrat|LINK
I need to loop one temp table and i need to insert data to another #temp table from first temp table based on some condition. how its possible?
I don't want to use cursor
Mar 20, 2019 12:28 PM|PatriceSc|LINK
I assume you know about https://www.w3schools.com/SQL/sql_insert_into_select.asp ? If you have a problem because of your condition we would need to know about it so that one can see it
it could still be done using that or few SQL statements.
At some point if you have really no way around looping on each and every row, cursors are intended for doing that.
Mar 20, 2019 01:37 PM|limno|LINK
Post your table structure and sample data and your expected result. You may think in loop but you should implement set based solution in database. Post your sample and you will get help from there. Thanks.
Mar 22, 2019 06:59 PM|BillJordan|LINK
I would think you would want to do the following:
INSERT INTO #temp2 (column1, column2, column3, ...)
SELECT column1, column2, column3, ...
Hope this helps you.