Why do delete statements have limitations beyond their select counterparts?
I am not stuck because the problem was easy enough to work around but I'd rather fix my understanding than continue using workarounds.
Case in point, I have an undirected, edge list with fields, V1 and V2. Unfortunately, when creating the table, I introduced duplicates (i.e. V1 -> V2 and V2 -> V1). To identify the dups, I ran the query:
SELECT t1.V1, t1.V2
FROM table t1
WHERE t1.V1 > t1.V2
and EXISTS (
SELECT *
FROM table t2
WHERE t2.V1 = t1.V2
and t2.V2 = t1.V1 )
since this returned a nice set of rows from the table, I thought I should be able to replace the select line with delete and rerun the same query. Sql server however, got mad and gave me red letters instead. Once about syntax and after a tweak, something about binding multipart identifiers.
I managed to store the select in a table variable and get the delete done - which is ok, but what was wrong with my original approach and could I have done it with a single SQL statement?
table? Would you name your childrenchild?