Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Flag for Zambia asked on

How to delete the data in SQL Server

Hi
I want to delete some data in four tables in SQL server back end but the delete query below is failing to do so kindly check the query below and advise accordingly

DELETE DISTINCTROW tblCustomerInvoice.InvoiceID, tblCustomerInvoice.StatusOne
FROM ((tblCustomerInvoice INNER JOIN tblLineDetails ON tblCustomerInvoice.InvoiceID = tblLineDetails.InvoiceID) INNER JOIN tblSalesControls ON tblCustomerInvoice.InvoiceID = tblSalesControls.InvoiceID) INNER JOIN tblCostofSales ON tblCustomerInvoice.InvoiceID = tblCostofSales.InvoiceID
WHERE (((tblCustomerInvoice.InvoiceID)=[Forms]![frmSalesInvoiceDelete]![CboInvoice]) AND ((tblCustomerInvoice.StatusOne) Is Null)) OR (((tblCustomerInvoice.StatusOne)<>"1"));

Regards

Chris
Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
arnold

8/22/2022 - Mon
ste5an

Looks like an Access query?!

What is the error message and how do you execute it? In Access or SQL Server?
ASKER CERTIFIED SOLUTION
Ron Malmstead

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
arnold

Use selects instead of delete first to confirm the rows impacted are the ones you want deleted.

Do you get a constraint violation?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes