February 10, 2006 at 2:01 pm
I'm using SQL Server 2000.
I have the following SELECT query which gives me just the result set I want. No syntax errors are reported.
SELECT * FROM tblAPData AS d
WHERE EXISTS
(SELECT t.* FROM tblAPDataTemp AS t
WHERE (t.DataDate = d.DataDate AND t.Region = d.Region AND t.Site = d.Site AND t.VendorNumber = d.VendorNumber));
If I try to delete those specific rows using the following syntax, I get an error:
DELETE FROM tblAPData AS d
WHERE EXISTS
(SELECT t.* FROM tblAPDataTemp AS t
WHERE (t.DataDate = d.DataDate AND t.Region = d.Region AND t.Site = d.Site AND t.VendorNumber = d.VendorNumber));
"Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'AS'."
Anyone know what I might be missing here? Thanks.
February 10, 2006 at 2:14 pm
>>DELETE FROM tblAPData AS d
If using a tablename and alias, you have to explicitly delete from 1 of them before the FROM keyword:
DELETE d
FROM tblAPData AS d
WHERE EXISTS
(SELECT t.* FROM tblAPDataTemp AS t
WHERE (t.DataDate = d.DataDate AND t.Region = d.Region AND t.Site = d.Site AND t.VendorNumber = d.VendorNumber));
February 10, 2006 at 2:30 pm
Thanks. That fixed it.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply