August 5, 2005 at 12:12 pm
I use an ACCESS 2003 front end to SQL server.
I am passsing a simple SQL statement
SQLText1 = "Delete dbo_tblBook_inventory from dbo_tblBook_inventory a ,dbo_tblrhd_inventory b " & _
" where A.drive_num = b.drive_num And b.date_verified Is Not Null"
DoCmd.RunSQL SQLText1
This gives me the error 3128 - Specify the table ontaining the records that you want to delete.
But the same statement works when I try it in Query Analyzer.
Any help will be appreciated.
August 5, 2005 at 12:18 pm
Delete A from dbo_tblBook_inventory A inner join dbo_tblrhd_inventory B on A.drive_num = B.drive_num where B.date_verified Is Not Null
August 5, 2005 at 12:26 pm
Tried that. Gives me the same error message as before.
Any other ideas ?
August 5, 2005 at 12:33 pm
you run the statement directly on the server?
replace dbo_ with dbo.
August 5, 2005 at 1:01 pm
The errors occurs when I run from ACCESS where these are linked tables and have a dbo_ prefixed. These statements run without any error when run directly on the server. But the use has an ACCESS frontend to run them.
August 5, 2005 at 1:15 pm
Can you run the statement while the profiler is running? I'd like to know if the error is sql or access generated.
August 5, 2005 at 1:28 pm
I have never used the profiler but there is no error generated in SQL server when I run it through query analyzer. Only when I run the statement throught aCCESS.
August 5, 2005 at 1:33 pm
have you tried to rebuild the query with the wizard?? maybe the delete join in access is different than the one on sql server.
August 7, 2005 at 9:20 am
Try changing the first part of your SQL statement to DELETE a.*
I think ACCESS needs the .* along with the table name.
August 7, 2005 at 2:02 pm
AFAIK, RunSQL (in MDB ODBC connections) uses Access SQL to run an action query, not T-SQL. Therefore you have to modify the T-SQL for Access (JET) syntax:
The syntax is:
DELETE [table.*]
FROM table
WHERE criteria
i.e., You can write: DELETE FROM table WHERE criteria
Your T-SQL will run in QA, but JET will not understand it. Of course, you can also do a pass through query to use T-SQL.
August 8, 2005 at 10:00 am
Thanks for all your input. What finally worked was the sub-query method:
Delete dbo_tblBook_Inventory.* FROM dbo_tblBook_Inventory
WHERE dbo_tblBook_Inventory.Drive_Num in
(select Drive_Num from dbo_tblRHD_Inventory where Date_Verified Is Not Null)
Thriveni
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply