SQL Script To Fix A Corrupt VAT 100 Return

Microsoft Dynamics GPThe process of creating a Tax Return in Microsoft Dynamics GP can sometimes take a while when there are a large number of transactions to process. While this usually isn’t a problem, on occasion a network connectivity issue (or a Citrix server cutting the user off after a certain length of time) can cut GP off from the database resulting in corrupt information in the Tax Return tables.

The following script will remove the corrupt data from the Tax tables and reset the flag on the transactions which shows which tax Return they’re on.

Change the highlighted section to the Tax Return ID to be reset:

/*
Created by Ian Grieve of azurecurve|Ramblings of a Dynamics GP Consultant (https://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int).
*/
DECLARE @TAX_RETURN_ID AS VARCHAR(100) = 'taxreturnid'

DELETE FROM
	TX00301
WHERE
	TAX_RETURN_ID = @TAX_RETURN_ID
GO

DELETE FROM
	TX00303
WHERE
	TAX_RETURN_ID = @TAX_RETURN_ID
GO

DELETE FROM
	TX00304
WHERE
	TAX_RETURN_ID = @TAX_RETURN_ID
GO

UPDATE
	TX30000
SET
	Included_On_Return = 0
	,Tax_Return_ID = ''
WHERE
	TAX_RETURN_ID = @TAX_RETURN_ID
GO

Before running the script make sure you have a good backup of the database and test afterwards to make sure everything is OK.

What should we write about next?

If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.

Your Name

Your Email

Suggested Topic

Suggestion Details

Looking for support or consultancy with Microsoft Dynamics GP?

I no longer work with Microsoft Dynamics GP, but the last company I worked for was ISC Software in the UK; if you’re looking for support or consultancy services with Microsoft Dynamics GP you can contact them here.

1 thought on “SQL Script To Fix A Corrupt VAT 100 Return

Leave a Reply

Your email address will not be published. Required fields are marked *