Connecting Tech Pros Worldwide Help | Site Map

SQL Delete statement

  #1  
Old November 13th, 2005, 02:31 AM
AlanAylett
Guest
 
Posts: n/a
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
  #2  
Old November 13th, 2005, 02:32 AM
MGFoster
Guest
 
Posts: n/a

re: SQL Delete statement


-----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:
[color=blue]
> 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[/color]

  #3  
Old November 13th, 2005, 02:32 AM
AlanAylett
Guest
 
Posts: n/a

re: SQL Delete statement


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:<FjvPc.6320$cK.2377@newsread2.news.pas.earthl ink.net>...[color=blue]
> -----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:
>[color=green]
> > 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[/color][/color]
  #4  
Old November 13th, 2005, 02:33 AM
MGFoster
Guest
 
Posts: n/a

re: SQL Delete statement


-----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:
[color=blue]
> 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:<FjvPc.6320$cK.2377@newsread2.news.pas.earthl ink.net>...
>[color=green]
>>-----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)[/color][/color]

  #5  
Old November 13th, 2005, 02:33 AM
Nicole
Guest
 
Posts: n/a

re: SQL Delete statement


> my problem is more with access than the SQL, i am trying to run the[color=blue]
> 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.[/color]

Do you have any relationships with delete contraints that might be interfering?
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
512 error in delete statement codedhacker answers 1 March 2nd, 2008 04:02 AM
SQL delete statement - atrottier answers 3 July 10th, 2007 05:19 PM
Syntax error in SQL Delete statement tara99 answers 3 December 21st, 2006 06:06 AM
sql delete C L Humphreys answers 4 November 12th, 2005 02:34 PM