Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Delete all rows from a temporary table except those meeting a selection criteria

$
0
0

I have a temporary table #SearchTbl in my procedure that is filled with data.  I have a SELECT statement that selects some of the data from #SearchTbl.  Instead of putting the selected data into a new table, how can I simply delete the rows that do not meet the select statement criteria?

Current method:

INSERT INTO #LoopTbl SELECT * FROM #SearchTbl WHERE Var1 = X AND Var2 > Y AND Var3 < Z
I'd rather end up with the selected data in the #SearchTbl (deleting the rest that was in the #SearchTbl), without having to use the #LoopTbl.  Is there a simple way to do this?


Gina


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>