Delete help

Hello Experts!
I'm trying to do something like this:

DELETE FROM FINANCE
WHERE vehmaster.status = '1'  (SELECT * FROM FINANCE INNER JOIN VEHMASTER ON FINANCE.STKNUM = VEHMASTER.STKNUM )

but I get this error:  The column prefix 'vehmaster' does not match with a table name or alias name used in the query.

Do I have the incorrect syntax?
jay-areAsked:
Who is Participating?
 
Anthony PerkinsCommented:
DELETE FINANCE
FROM FINANCE
          INNER JOIN VEHMASTER ON FINANCE.STKNUM = VEHMASTER.STKNUM
WHERE vehmaster.status = '1'
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
What's the relevance of the (SELECT * FROM FINANCE INNER JOIN....) part?
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Perhaps...

DELETE FROM FINANCE
INNER JOIN VEHMASTER ON FINANCE.STKNUM = VEHMASTER.STKNUM
WHERE vehmaster.status = '1'
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
softplusCommented:
DELETE FROM FINANCE
WHERE STKNUM IN (SELECT STKNUM FROM VEHMASTER WHERE status = '1' )
0
 
softplusCommented:
should he try them all out and see which one deletes the most records? :)))
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
set a timer to them and see which one executes fastest.  
0
 
Anthony PerkinsCommented:
>>should he try them all out and see which one deletes the most records?<<
There are only two that are syntactically correct :)  Perhaps he can average out.  Randomly pick one or he other ....
0
 
PePiCommented:
>>should he try them all out and see which one deletes the most records? :)))

I suggest DELETE * FROM FINANCE ;)
0
 
Anthony PerkinsCommented:
>>DELETE * FROM FINANCE<<
I miss that MS Access syntax :)
0
 
Anthony PerkinsCommented:
jay-are,

This question is considered now to be technically abandoned:
03/23/2005 500 VB help!  Open Visual Basic
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21362341.html

See here for more info:
Nobody answered my question.  What do I do?
http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi71
0
 
jay-areAuthor Commented:
acperkins solution was the first one to work properly!

PePi, unfortunately I accidently did a "DELETE FROM FINANCE"...  :(   had to rebuild the whole thing.
0
 
jay-areAuthor Commented:
acperkins, I posted a "please delete my question" in community service...

Thanks!
0
 
Anthony PerkinsCommented:
Thanks and I appreciate the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.