Hi, I am working on a requirement where we are migrating to an ERP application from a legacy application. We are in the parallel testing phase and I am tasked with the requirement to see we have a smooth migration and in case if we are generating same information on both the sales systems. In case the two are giving different results for same transaction that issue needs to be captured and reported as new field "Data Issue". We will be doing this for 3 months and make sure 2 systems generate exact results before we go live. Please find a sales transaction query below. I am using SQL Server 2008 R2.
DROP TABLE [dbo].[Test] CREATE TABLE [dbo].[Test]( [RecordId] [int] IDENTITY(1,1) NOT NULL, [System] [varchar](35) NOT NULL, [Store] [int] NULL, [Date] [datetime] NULL, [IssueNumber] [nvarchar](32) NOT NULL, [StockId] [nvarchar](255) NULL, [Name] [nvarchar](255) NULL, [SKU] [smallint] NULL, [Area] [int] NULL, [DaysShipped] [int] NULL, [Code] [smallint] NULL, [Size] [int] NULL, [Sample] [int] NULL, [Weighed] [int] NULL, [lbs] [decimal](12, 2) NULL ) INSERT INTO [Test] ([System],[Store],[Date],[IssueNumber],[StockId],[Name],[SKU],[Area],[DaysShipped],[Code],[Size],[Sample],[Weighed],[lbs])VALUES('Legacy Application',2,'May 30 2002 12:00:00:000AM','34789','4437','ASEFT',81,2,1,65,0,1,NULL,8.00) INSERT INTO [Test] ([System],[Store],[Date],[IssueNumber],[StockId],[Name],[SKU],[Area],[DaysShipped],[Code],[Size],[Sample],[Weighed],[lbs])VALUES('Legacy Application',2,'May 30 2002 12:00:00:000AM','34789','4437','ASEFT',81,2,1,65,4,4,NULL,46.00) INSERT INTO [Test] ([System],[Store],[Date],[IssueNumber],[StockId],[Name],[SKU],[Area],[DaysShipped],[Code],[Size],[Sample],[Weighed],[lbs])VALUES('Legacy Application',2,'May 30 2002 12:00:00:000AM','34789','4437','ASEFT',81,2,1,65,3,26,NULL,236.00) INSERT INTO [Test] ([System],[Store],[Date],[IssueNumber],[StockId],[Name],[SKU],[Area],[DaysShipped],[Code],[Size],[Sample],[Weighed],[lbs])VALUES('New ERP Application',2,'May 30 2002 12:00:00:000AM','1','4437',NULL,81,2,1,65,3,27,27,236.00) INSERT INTO [Test] ([System],[Store],[Date],[IssueNumber],[StockId],[Name],[SKU],[Area],[DaysShipped],[Code],[Size],[Sample],[Weighed],[lbs])VALUES('New ERP Application',2,'May 30 2002 12:00:00:000AM','1','4437',NULL,81,2,1,65,4,4,4,46.00) INSERT INTO [Test] ([System],[Store],[Date],[IssueNumber],[StockId],[Name],[SKU],[Area],[DaysShipped],[Code],[Size],[Sample],[Weighed],[lbs])VALUES('New ERP Application',2,'May 30 2002 12:00:00:000AM','1','4437',NULL,81,2,1,65,2,1,1,7.00) INSERT INTO [Test] ([System],[Store],[Date],[IssueNumber],[StockId],[Name],[SKU],[Area],[DaysShipped],[Code],[Size],[Sample],[Weighed],[lbs])VALUES('Legacy Application',2,'May 30 2002 12:00:00:000AM','34789','4437','ASEFT',81,2,1,65,2,1,NULL,7.00) SELECT * FROM [Test] ORDER BY 2 GO
SELECT *
FROM [Test] A -- Legacy Application
FULL JOIN [Test] B -- New ERP Application
ON A.Store = B.Store
AND A.[Date] = B.[Date]
AND A.StockId = B.StockId
AND A.SKU = B.SKU
AND A.Area = B.Area
AND A.Code = B.Code
AND A.Size = B.Size
WHERE B.[System] = 'New ERP Application' AND A.[System] = 'Legacy Application'
Could please let me know an efficient way to do this. In this example "New ERP Application" is missing Size = 0 record altogether and for Size = 3 the Sample Units are different. These 2 issues need to be reported for this example.
Ione