473,902 Members | 4,610 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delete using another table's values

SG
Hi all,
I am trying to perform a delete that I could achieve in Access but
need to do this in sql2000.
I have two tables Warranty and Registrations. I would like to delete
all items in the warranty table where there is a match in
registrations on a common field.
I access the query would be:
DELETE warranty.*
FROM warranty INNER JOIN registrations ON warranty.BBMQCE =
registrations.v ins;

But cannot replicate this in SQL server?

Any help would be much appreciated.

Thanks
Sam
Jul 20 '05 #1
5 20145
On 23 Sep 2004 02:40:24 -0700, SG wrote:
I access the query would be:
DELETE warranty.*
FROM warranty INNER JOIN registrations ON warranty.BBMQCE =
registrations. vins;

But cannot replicate this in SQL server?


Hi Sam,

You're almost there. The Transact-SQL version of this would be

DELETE warranty
FROM warranty
INNER JOIN registration
ON warranty.BBMQCE = registrations.v ins

Yes - you only need to drop the .* !!!
However, the above is proprietary code that will not port well to other
databases. If you want portability, use the ANSI-standard delete syntax
instead:

DELETE FROM warranty
WHERE NOT EXISTS (SELECT *
FROM registration
WHERE warranty.BBMQCE = registrations.v ins)

(both queries untested - beware of spelling errors!)

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 20 '05 #2

Many thanks - i was so nearly there!
Sam
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
Hugo Kornelis wrote:
On 23 Sep 2004 02:40:24 -0700, SG wrote:

I access the query would be:
DELETE warranty.*

FROM warranty INNER JOIN registrations ON warranty.BBMQCE =

registrations .vins;

But cannot replicate this in SQL server?

Hi Sam,

You're almost there. The Transact-SQL version of this would be

DELETE warranty
FROM warranty
INNER JOIN registration
ON warranty.BBMQCE = registrations.v ins

Yes - you only need to drop the .* !!!
However, the above is proprietary code that will not port well to other
databases. If you want portability, use the ANSI-standard delete syntax
instead:

DELETE FROM warranty
WHERE NOT EXISTS (SELECT *
FROM registration
WHERE warranty.BBMQCE = registrations.v ins)

(both queries untested - beware of spelling errors!)

Best, Hugo


DELETE FROM warranty
WHERE EXISTS (SELECT *
FROM registration
WHERE warranty.BBMQCE = registrations.v ins)

There shouldn't be *NOT* in WHERE clause, because SG wants to delete all matches
Jul 20 '05 #4
On Sat, 25 Sep 2004 06:01:13 GMT, Andrey wrote:
There shouldn't be *NOT* in WHERE clause, because SG wants to delete all matches


Hi Andrey,

Good catch! Thanks for correcting my mistake.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 20 '05 #5
Hugo Kornelis wrote:
On Sat, 25 Sep 2004 06:01:13 GMT, Andrey wrote:

There shouldn't be *NOT* in WHERE clause, because SG wants to delete all matches

Hi Andrey,

Good catch! Thanks for correcting my mistake.

Best, Hugo


You're welcome :)
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1504
by: Jim Sneeringer | last post by:
I have a GridView that loads correctly from a SQL table using a TableAdapter and stored procedures. However, when I try to delete from the GridView, I get "Procedure or Function 'EventDelete' expects parameter '@Original_Comment', which was not supplied." Of course, the call to EventDelete was generated by Visual Studio, making it hard to debug. In fact, I nothing in the stack trace is my code. If I remove the parameter @OriginalComment...
1
1759
by: BT Openworld | last post by:
I've just had to upgrade to Access 2003. Our company's main sales database started in Access V1.0 and has progressed through V2.0 and 97 without problems. I've converted it to 2003 format and have been going through a process of testing it. To my horror I noticed that seemingly without provocation, it has started re-using old Autonumber values. For example, I have an archive routine which removes completed sales enquiry records out of the...
1
2015
by: Richard Dixson | last post by:
Under ASP.NET (C#) I want to create a page that people can use to submit questions. This page will consist of a table with several rows of information, like: Name: Bill Smith Job title: Developer Address: 123 Main Street. After the table of information will be the web form. So basically I want to display the table and then have the web form.
2
2372
by: Richard Dixson | last post by:
Under ASP.NET (C#) I want to create a page that people can use to submit questions. This page will consist of a table with several rows of information, like: Name: Bill Smith Job title: Developer Address: 123 Main Street. After the table of information will be the web form. So basically I want to display the table and then have the web form.
8
1332
by: ibiza | last post by:
Hi SQL fans, I realized that I often encounter the same situation in a relation database context, where I really don't know what to do. Here is an example, where I have 2 tables as follow: ________________________ __________________ | PortfolioTitle |
0
3342
by: Ed | last post by:
All of a sudden my previously working code started throwing this error. from the SqlDatasource. I am using C# and Asp.net 2.0. Getting the following error: You have specified that your delete command compares all values on SqlDataSource 'sdsAddEdit', but the dictionary passed in for values is empty. Pass in a valid dictionary for delete or change your mode to OverwriteChanges.
20
188398
by: talktozee | last post by:
Hey, everyone! Basically, I need to insert *multiple rows* into table A from table B based upon some criteria, and I need to insert some static values along with each row from table A. For example: insert into tableA (col1,col2,col3,col4,col5) values ('Cheese', 'Blue',
10
2695
by: nickvans | last post by:
Hello everyone, I'm fairly new to VBA and MS Access (I'm using 2003) but my issue seems like a pretty straight forward one. I would like to delete all records found in one table from another one. I have code which grabs values from a list box (which has as its source "tblNewModPart") then uses them in a Make-Table query which creates a table called "tblRemovedParts." I would like to delete all values from "tblRemovedParts" from...
0
1393
by: Gammazoni | last post by:
Hello, I have a code like that, which has been using by me, but now I need another one, which won't differ a lot, I hope. Please, analize it, I believe that here I'll find somebody with large luggage of experience. Please, write any suggestions you have. Sub test() Dim ws As Worksheet, a, i As Long, ii As Long, b(), n As Long, w(), e With CreateObject("Scripting.Dictionary") For Each ws In Worksheets With...
0
9997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11279
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10870
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10981
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5893
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4725
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.