In a stored procedure I have table DBTAB and an internal temporary table #TMPTAB containing the following:
DBTAB
Product (key) | Other | Release Date |
---|---|---|
PROD1 | ... | 01102014 |
PROD2 | ... | NULL |
PROD3 | ... | NULL |
#TMPTAB
Product (key) | Product Group (key) | Date (key) | Amount |
---|---|---|---|
PROD1 | A | 30092014 | 100 |
PROD1 | A | 01102014 | 110 |
PROD1 | A | 02102014 | 120 |
PROD2 | B | 30092014 | 200 |
PROD2 | B | 01102014 | 210 |
PROD2 | B | 02102014 | 220 |
The question is: what is the SQL syntax to delete those entries in #TMPTAB with a corresponding Date prior to the Release Date in DBTAB when the Release Date <> NULL.
The result in the above example would be that the first line and only the first line in #TMPTAB is deleted.
I appreciate any assistance on this. Thanks.