Re: Deleting Invoices

Dale E. Reed Jr. ( (no email) )
Sat, 01 Mar 1997 18:00:50 -0800

Jeffrey Betts wrote:
>
> I am trying to delete all existing invoices
> and payments from the emerald database.
> I picked up these commands from the list
> a while back. They were from Dale.
>
> TRUNCATE TABLE Invoiceitems
> GO
> TRUNCATE TABLE Payments
> GO
> TRUNCATE TABLE Invoices
> GO
>
> When I run these commands in ISQL/w I get the error
>
> Msg 4712 Level 16, State 1
> Cannot truncate table 'payments' because it is being referanced by a
> foreign key constraint.

Hmmm. :(

Try this:

Update InvoiceItems Set PaymentID = NULL
GO
TRUNCATE TABLE Payments
GO
TRUNCATE TABLE Invoiceitems
GO
TRUNCATE TABLE Invoices
GO

That should work.

-- Dale E. Reed Jr.  (daler@iea.com)_________________________________________________________________       IEA Software, Inc.      |  RadiusNT, Emerald, and NT FAQs Internet Solutions for Today  |    http://www.emerald.iea.com