-4

I'm trying to use a new syntax for a delete statement. I have never used an alias directly after the delete statement. Is this the correct format?

delete a
from FirstTable a
inner join @tablevariable b
  on a.column1 = b.column1
Neil Keicher
  • 39
  • 1
  • 1
  • 5
  • 4
    Have you tried googling this before asking it? This question may be voted down because it shows lack of research effort. – rory.ap Dec 10 '14 at 16:38
  • Did you even try executing it? Pressing F5 once would certainly give you your answer faster than posting a question here... – Siyual Dec 10 '14 at 16:43
  • @Siyual -- I'm assuming he's concerned with deleting the wrong data, not whether it works at all without an error. – rory.ap Dec 10 '14 at 16:46
  • Roryap - Thank you, that's why I didn't run it. – Neil Keicher Dec 10 '14 at 16:46
  • to test put it in an explicit transaction and rollback rather than commit. after the delete. of course you never test this stuff on prod either. And specify he database backend, different ones may handle the join in a delete differntly. – HLGEM Dec 10 '14 at 16:49

1 Answers1

0

This is how I would test the statement

Begin tran
select a.* 
from FirstTable a
inner join @tablevariable b
on a.column1 = b.column1

delete a
from FirstTable a
inner join @tablevariable b
on a.column1 = b.column1

select a.* 
from FirstTable a
inner join @tablevariable b
on a.column1 = b.column1

rollback tran
HLGEM
  • 94,695
  • 15
  • 113
  • 186