I need to save select query output into temporary table. Then I need to make another select query against this temporary table. Does anybody know how to do it?
I need to make this on SQL Server.
You can use select ... into ... to create and populate a temp table and then query the temp table to return the result. No you don't. If you want to fill a table that already exist with rows you need to use a different syntax.
Temporary tables are stored in tempdb. They work like a regular table in that you can perform the operations select, insert and delete as for a regular table. If created inside a stored procedure they are destroyed upon completion of the stored procedure.
select * into #TempTable from SomeTale select * from #TempTable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With