472,783 Members | 979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,783 software developers and data experts.

SQL Delete statement

Hi all

wondering if anybody could spot anything wrong with this SQL DELETE
statement, both my Access and SQL skills are not what they used to be
so i reckon its something simple, any suggestions appreciated.

-----
DELETE dbo_SUMBill_New.*, dbo_SUMBill_New.BillAccountNumber,
dbo_SUMBill_New.POBReference

FROM a INNER JOIN dbo_SUMBill_New ON a.POBReference =
dbo_SUMBill_New.POBReference

WHERE (((dbo_SUMBill_New.BillAccountNumber)=[a].[BillAccountNumber])
AND ((dbo_SUMBill_New.POBReference)=[a].[POBReference]));
-----

Regards, Alan Aylett
Nov 13 '05 #1
4 8984
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Might try these:

DELETE N.*
FROM dbo_SUMBill_New As N INNER JOIN A
ON N.POBReference = A.POBReference
AND N.BillAccountNumber = A.BillAccountNumber

or

DELETE *
FROM dbo_SUMBill_New As N
WHERE EXISTS (SELECT * FROM A
WHERE N.POBReference = A.POBReference
AND N.BillAccountNumber = A.BillAccountNumber)

As a safety precaution change DELETE to SELECT to test - it should show
you the records that will be selected for deletion.

These queries should delete the records from dbo_SUMBill_New that have
the same POBReference and BillAccountNumber as table A. Is this what
you want?

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQQ6BWoechKqOuFEgEQJd+gCghLYEGRsn/8WAa0i1pIQ3J19HCAMAnjPc
+/o8GqH0MdK1H27UEcqgYMwM
=/7+5
-----END PGP SIGNATURE-----
AlanAylett wrote:
Hi all

wondering if anybody could spot anything wrong with this SQL DELETE
statement, both my Access and SQL skills are not what they used to be
so i reckon its something simple, any suggestions appreciated.

-----
DELETE dbo_SUMBill_New.*, dbo_SUMBill_New.BillAccountNumber,
dbo_SUMBill_New.POBReference

FROM a INNER JOIN dbo_SUMBill_New ON a.POBReference =
dbo_SUMBill_New.POBReference

WHERE (((dbo_SUMBill_New.BillAccountNumber)=[a].[BillAccountNumber])
AND ((dbo_SUMBill_New.POBReference)=[a].[POBReference]));
-----

Regards, Alan Aylett


Nov 13 '05 #2
Cheers for reply, unfortunately still experiencing problems.

probably didnt give enough information yesterday, brain was shot from
long office day.

my problem is more with access than the SQL, i am trying to run the
SQL in microsoft access 2000. If i replace the DELETE with SELECT it
returns all the records which i wish to delete, thus SQL works ok

However, when i try to execute the DELETE statement i get the error
message

'Could not delete from specified tables'

in a pop up box. The help supplied for this error is the usual ms
waffle which doesnt give you alot to work with.

Any access experts, please have a stab in the dark.

Regards, Alan Aylett

MGFoster <me@privacy.com> wrote in message news:<Fj****************@newsread2.news.pas.earthl ink.net>...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Might try these:

DELETE N.*
FROM dbo_SUMBill_New As N INNER JOIN A
ON N.POBReference = A.POBReference
AND N.BillAccountNumber = A.BillAccountNumber

or

DELETE *
FROM dbo_SUMBill_New As N
WHERE EXISTS (SELECT * FROM A
WHERE N.POBReference = A.POBReference
AND N.BillAccountNumber = A.BillAccountNumber)

As a safety precaution change DELETE to SELECT to test - it should show
you the records that will be selected for deletion.

These queries should delete the records from dbo_SUMBill_New that have
the same POBReference and BillAccountNumber as table A. Is this what
you want?

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQQ6BWoechKqOuFEgEQJd+gCghLYEGRsn/8WAa0i1pIQ3J19HCAMAnjPc
+/o8GqH0MdK1H27UEcqgYMwM
=/7+5
-----END PGP SIGNATURE-----
AlanAylett wrote:
Hi all

wondering if anybody could spot anything wrong with this SQL DELETE
statement, both my Access and SQL skills are not what they used to be
so i reckon its something simple, any suggestions appreciated.

-----
DELETE dbo_SUMBill_New.*, dbo_SUMBill_New.BillAccountNumber,
dbo_SUMBill_New.POBReference

FROM a INNER JOIN dbo_SUMBill_New ON a.POBReference =
dbo_SUMBill_New.POBReference

WHERE (((dbo_SUMBill_New.BillAccountNumber)=[a].[BillAccountNumber])
AND ((dbo_SUMBill_New.POBReference)=[a].[POBReference]));
-----

Regards, Alan Aylett

Nov 13 '05 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Just a guess: Do you have permission to delete on the MS SQL table?
Check the Permissions on the table you are trying to delete on. Use the
SQL Enterprise Manager.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQQ/TFoechKqOuFEgEQIZLACfeNl0Xb7tK1ajh8VY/ZubBVqskj8AnjW+
3kJBUfcY3r+UflJsQO6GwfF4
=PF+N
-----END PGP SIGNATURE-----
AlanAylett wrote:
Cheers for reply, unfortunately still experiencing problems.

probably didnt give enough information yesterday, brain was shot from
long office day.

my problem is more with access than the SQL, i am trying to run the
SQL in microsoft access 2000. If i replace the DELETE with SELECT it
returns all the records which i wish to delete, thus SQL works ok

However, when i try to execute the DELETE statement i get the error
message

'Could not delete from specified tables'

in a pop up box. The help supplied for this error is the usual ms
waffle which doesnt give you alot to work with.

Any access experts, please have a stab in the dark.

Regards, Alan Aylett

MGFoster <me@privacy.com> wrote in message news:<Fj****************@newsread2.news.pas.earthl ink.net>...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Might try these:

DELETE N.*
FROM dbo_SUMBill_New As N INNER JOIN A
ON N.POBReference = A.POBReference
AND N.BillAccountNumber = A.BillAccountNumber

or

DELETE *
FROM dbo_SUMBill_New As N
WHERE EXISTS (SELECT * FROM A
WHERE N.POBReference = A.POBReference
AND N.BillAccountNumber = A.BillAccountNumber)

As a safety precaution change DELETE to SELECT to test - it should show
you the records that will be selected for deletion.

These queries should delete the records from dbo_SUMBill_New that have
the same POBReference and BillAccountNumber as table A. Is this what
you want?

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)


Nov 13 '05 #4
> my problem is more with access than the SQL, i am trying to run the
SQL in microsoft access 2000. If i replace the DELETE with SELECT it
returns all the records which i wish to delete, thus SQL works ok

However, when i try to execute the DELETE statement i get the error
message

'Could not delete from specified tables'

in a pop up box. The help supplied for this error is the usual ms
waffle which doesnt give you alot to work with.


Do you have any relationships with delete contraints that might be interfering?
Nov 13 '05 #5

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

Similar topics

14
by: php newbie | last post by:
I am getting error messages when I try to delete from a table using the values in the table itself. The intent is to delete all rows from TableA where col_2 matches any of the col_1 values. ...
4
by: Stefan Strasser | last post by:
why is delete an expression and not a statement? (in my draft copy of the standard). I was about to ask the same question about "throw" but found an expression case of throw("return boolvalue ? 5...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
1
by: Matt | last post by:
I am writing a DELETE statement and I want to filter the records using another SELECT statement. My SELECT statement is a GROUP BY query that grabs all social security numbers from the "Data...
12
by: yufufi | last post by:
Hello, How does delete know how much memory to deallocate from the given pointer? AFAIK this informations is put there by new. new puts the size of the allocated memory before the just before...
3
by: atrottier | last post by:
I'am new here so I'd like to say hello and this seems to be a great site it has already helped me a few times. I just got an assignment to correct and modify a simple access application. First some...
1
by: codedhacker | last post by:
I have a piece of code that uses the db-library with sql server 2000/2005 and runs the following delete statement: DELETE FROM TABLE1 WHERE COL1 IN( 'Some Val1' ) AND COL2 IN( 'Some Val2' )...
8
by: Michel Esber | last post by:
Hello, Env: DB2 V8 LUW FP16 running Linux create Table X (machine_id varchar(24) not null, ctime timestamp not null); create index iFoo on X (MACHINE_ID, CTIME) allow reverse scans; alter...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.