***************************** Internal to Citixsys Support Team*********************************
Environment :
iVend 6.6 7989 with SAPB1
Problem Statement :
Store database doesn't purge by iVend MC End of day process. so there is need to purge the store database manually .
Note : It should be discussed with Level 3 team first before using this one
SQL Queries :
SELECT DISTINCT A.TransactionKey INTO #TempTransactionsToBeCleaned FROM TrxTransaction A
WHERE CONVERT(NVARCHAR, A.BusinessDate, 112) < '20130201'
DELETE FROM TrxTransactionPromotionDetail WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionQuotation WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionPrinting WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionStatus WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionSurcharge WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionSalesPerson WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionSignature WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionPayment WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionGiftCertificate WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionInstallmentDetail WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionFulfillmentDetail WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionItemAttribute WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionLoyalty WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionOrder WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionSaleItem WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionLayaway WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionLostSaleItem WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionAttribute WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxARPayment WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionAudit WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionFulfillment WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionConsignment WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransactionCoupon WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DELETE FROM TrxTransaction WHERE TransactionKey IN (SELECT TransactionKey FROM #TempTransactionsToBeCleaned)
DROP TABLE #TempTransactionsToBeCleaned