[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Delete help

Posted on 2005-05-11
13
Medium Priority
?
210 Views
Last Modified: 2010-03-19
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?
0
Comment
Question by:jay-are
  • 5
  • 3
  • 2
  • +2
13 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 13982353
What's the relevance of the (SELECT * FROM FINANCE INNER JOIN....) part?
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 13982359
Perhaps...

DELETE FROM FINANCE
INNER JOIN VEHMASTER ON FINANCE.STKNUM = VEHMASTER.STKNUM
WHERE vehmaster.status = '1'
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 2000 total points
ID: 13982360
DELETE FINANCE
FROM FINANCE
          INNER JOIN VEHMASTER ON FINANCE.STKNUM = VEHMASTER.STKNUM
WHERE vehmaster.status = '1'
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:softplus
ID: 13982379
DELETE FROM FINANCE
WHERE STKNUM IN (SELECT STKNUM FROM VEHMASTER WHERE status = '1' )
0
 
LVL 13

Expert Comment

by:softplus
ID: 13982386
should he try them all out and see which one deletes the most records? :)))
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 13982389
set a timer to them and see which one executes fastest.  
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 13982394
>>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
 
LVL 6

Expert Comment

by:PePi
ID: 13982398
>>should he try them all out and see which one deletes the most records? :)))

I suggest DELETE * FROM FINANCE ;)
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 13982412
>>DELETE * FROM FINANCE<<
I miss that MS Access syntax :)
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 13982429
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
 

Author Comment

by:jay-are
ID: 13982437
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
 

Author Comment

by:jay-are
ID: 13982499
acperkins, I posted a "please delete my question" in community service...

Thanks!
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 13982558
Thanks and I appreciate the points.
0

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question