I have a table named NoteTable. I also have a second temporary table that contains some of the identical data as NoteTable.
I want to delete all rows from NoteTable where the same items exist in the temp table, and also delete those same items from the temp table.
Example:
NoteTable contents:
NoteID NoteSeqNum NoteTypeID
12654 232 1
12654 232 3
22520 126 1
22661 282 1
22661 282 5
@NoteTempTable contents:
NoteID NoteSeqNum NoteTypeID
12654 232 1
22520 126 1
22661 282 1
NoteTable contents after delete:
NoteID NoteSeqNum NoteTypeID
12654 232 3
22661 282 5
@NoteTempTable contents after delete:
...[empty]
Partial SQL for what I'm trying to do:
DECLARE @NoteTempTable TABLE(NoteId INT, NoteSeqNum INT);
[...fill @NoteTempTable]
DELETE FROM NoteTable
WHERE
[...a matching NoteId and NoteTypeID are found in @NoteTempTable]
DELETE FROM @NoteTempTable
WHERE
[...the same rows you removed in the above DELETE]
I want to delete all rows from NoteTable where the same items exist in the temp table, and also delete those same items from the temp table.
Example:
NoteTable contents:
NoteID NoteSeqNum NoteTypeID
12654 232 1
12654 232 3
22520 126 1
22661 282 1
22661 282 5
@NoteTempTable contents:
NoteID NoteSeqNum NoteTypeID
12654 232 1
22520 126 1
22661 282 1
NoteTable contents after delete:
NoteID NoteSeqNum NoteTypeID
12654 232 3
22661 282 5
@NoteTempTable contents after delete:
...[empty]
Partial SQL for what I'm trying to do:
DECLARE @NoteTempTable TABLE(NoteId INT, NoteSeqNum INT);
[...fill @NoteTempTable]
DELETE FROM NoteTable
WHERE
[...a matching NoteId and NoteTypeID are found in @NoteTempTable]
DELETE FROM @NoteTempTable
WHERE
[...the same rows you removed in the above DELETE]