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

Deleting data in a table based on 2 columns

$
0
0

I have 2 tables, one contains data and one contains parameters.

table A (Data Table) looks like this:
SID     NAME     METER    DATE
95       Jones            1   01-01-13
95       Jones            2   01-21-13
95       Null               3   01-01-13
95       Null               4   01-11-13
95       Jones            5   01-02-13
96       Abbott          1   01-01-13
96       Null               4   01-11-13
96       Jones            5   01-02-13

table B (Parameters Table) looks like this
SID     METER
95               1
95               2
96               1

I want a delete statement that deletes all records in table A where SID and METER are not in Table B

The results on the above table A would be
SID     NAME     METER    DATE
95       Jones            1   01-01-13
95       Jones            2   01-21-13
96       Abbott          1   01-01-13

This cant be that hard.... I think I am over thinking it???


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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