Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
SLM09
Starting Member
31 Posts |
Posted - 2009-10-07 : 09:01:09
|
| Could someone tell me if it is possible to delete records from a temp table based on the contents of another table? So-#temp1 a b c#temp2 a c dDELETE FROM #temp1 WHERE #temp1.data = #temp2.dataOr something along those lines?Thanks |
|
|
Sachin.Nand
2937 Posts |
Posted - 2009-10-07 : 09:07:29
|
| Delete T1 from #temp1 T1INNER JOIN #temp2 On T1.data=T2.dataPBUH |
 |
|
|
SLM09
Starting Member
31 Posts |
Posted - 2009-10-07 : 09:40:19
|
| Sorry, I think I did my usual horrible attempt at an explanation.#temp1col1 col2 col3a 1 ...b 2 ...c 3 ...#temp2col1 col2 col3a 4 ...c 5 ...d 6 ...#temp1 has a record where col1 'a' also appears in #temp2. I want to delete the entire row from #temp1 in this case. |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2009-10-07 : 09:43:05
|
| Did you try my solution?Please take a backup before u do it.Just in case :)PBUH |
 |
|
|
SLM09
Starting Member
31 Posts |
Posted - 2009-10-07 : 11:25:08
|
| Thanks Idera, it did work! I misunderstood the code when I first looked at it, that was my bad. :PThanks again! |
 |
|
|
|
|
|