Hi again,I am receiving an error message in my code stating that the Column name or number of supplied values does not match table definition. 1)Now this query works without the Insert statement but when i try to insert the result in to a new table it doesn't work2)Prior to me adding in a new column called 'brand', the code worked when i ran it to see the results and it also worked when i tried to insert it into a new table it also worked.3)Since this was a new column, I also included the new column name in design view along with its data type and length etcAny help would be greatly appreciated and I am totally at a lost.The error I am getting is thisServer: Msg 213, Level 16, State 5, Line 6Insert Error: Column name or number of supplied values does not match table definition.
Below is the codeSELECT SCLData_Unique_Sale_Summary.*, SCLData_Unique_Product_Summary.ProductBarcode, SCLData_Unique_Product_Summary.ProductDescription, SCLData_Unique_Product_Summary.ActivePrice, SCLData_Unique_Product_Summary.TotalProductQuantity, SCLData_Unique_Product_Summary.TotalProductSalePrice, SCLData_Unique_Product_Summary.DepartmentDescription, SCLData_Unique_Product_Summary.SubDeptDescription, SCLData_Unique_Product_Summary.Brand, CASE DATEPART( dw, AccountingDate ) WHEN '1' THEN 'SUNDAY' WHEN '2' THEN 'MONDAY' WHEN '3' THEN 'TUESDAY' WHEN '4' THEN 'WEDNESDAY' WHEN '5' THEN 'THURSDAY' WHEN '6' THEN 'FRIDAY' WHEN '7' THEN 'SATURDAY' END AS AccountDateWeekDay, CASE DATEPART( m, AccountingDate ) WHEN '1' THEN 'JAN' WHEN '2' THEN 'FEB' WHEN '3' THEN 'MAR' WHEN '4' THEN 'APR' WHEN '5' THEN 'MAY' WHEN '6' THEN 'JUN' WHEN '7' THEN 'JUL' WHEN '8' THEN 'AUG' WHEN '9' THEN 'SEP' WHEN '10' THEN 'OCT' WHEN '11' THEN 'NOV' WHEN '12' THEN 'DEC' END AS AccountDateMonth, CASE SCLData_Unique_Sale_Summary.StoreId WHEN '105' THEN '3001' WHEN '101' THEN '3024' WHEN '112' THEN '3025' WHEN '103' THEN '3003' WHEN '102' THEN '3002' END AS SubsidiaryIdFROM ( SELECT StoreId, LaneNumber, InvoiceNumber, TransactionNumber, ProductBarcode, MAX( ProductDescription ) ProductDescription, MAX( ActivePrice ) ActivePrice, CEILING( SUM( CONVERT( DECIMAL(10,2), Quantity ) ) ) TotalProductQuantity, SUM( CONVERT( DECIMAL(10,2), DollarAmount ) ) TotalProductSalePrice, MAX( DepartmentDescription ) DepartmentDescription, MAX( SubDeptDescription ) SubDeptDescription ,Brand FROM ( SELECT DISTINCT F1068 AS TransactionType, F254 AS AccountingDate, F253 AS SystemDate, F1056 AS StoreId, F1057 AS LaneNumber, F1035 AS TransactionStartTime, F1036 AS TransactionEndTime, F1032 AS TransactionNumber , F1764 AS InvoiceNumber, F1185 AS OperatorNumber, F1126 AS OperatorCode, F1127 AS OperatorName, F1148 AS MagnaNumberShort, F01 AS ProductBarcode, F02 AS ProductDescription, F04 AS SubDepartmentCode, F03 AS DepartmentCode, F97 AS TaxableFlag, F113 AS ActivePriceDescription, F1101 AS ItemLineNumber, F1007 AS ActivePrice, F1006 AS ActiveQuantity, F65 AS DollarAmount, F64 AS Quantity, F1263 AS Brand, F238 AS DepartmentDescription, F1022 AS SubDeptDescription, F9999 AS XmlFile FROM SCLData_tab ) AS SCLData_Unique_WorkTable WHERE ISNUMERIC( DollarAmount ) = 1 AND ISNUMERIC( Quantity ) = 1 AND StoreId BETWEEN '101' AND '112' GROUP BY StoreId, LaneNumber, InvoiceNumber, Brand, TransactionNumber, ProductBarcode ) AS SCLData_Unique_Product_Summary, ( SELECT StoreId, LaneNumber, InvoiceNumber, TransactionNumber, Brand, MAX( MagnaNumberShort ) MagnaNumberShort, MAX( TransactionType ) TransactionType, MIN( AccountingDate ) AccountingDate, MIN( TransactionStartTime ) TransactionStartTime, MAX( TransactionEndTime ) TransactionEndTime, CEILING( SUM( CONVERT( DECIMAL(10,2), Quantity ) ) ) TotalSaleQuantity, SUM( CONVERT( DECIMAL(10,2), DollarAmount ) ) TotalSalePrice FROM ( SELECT DISTINCT F1068 AS TransactionType, F254 AS AccountingDate, F253 AS SystemDate, F1056 AS StoreId, F1057 AS LaneNumber, F1035 AS TransactionStartTime, F1036 AS TransactionEndTime, F1032 AS TransactionNumber , F1764 AS InvoiceNumber, F1185 AS OperatorNumber, F1126 AS OperatorCode, F1127 AS OperatorName, F1148 AS MagnaNumberShort, F01 AS ProductBarcode, F02 AS ProductDescription, F04 AS SubDepartmentCode, F03 AS DepartmentCode, F97 AS TaxableFlag, F113 AS ActivePriceDescription, F1101 AS ItemLineNumber, F1007 AS ActivePrice, F1006 AS ActiveQuantity, F65 AS DollarAmount, F64 AS Quantity, F1263 AS Brand, F238 AS DepartmentDescription, F1022 AS SubDeptDescription, F9999 AS XmlFile FROM SCLData_tab ) AS SCLData_Unique_WorkTable WHERE ISNUMERIC( DollarAmount ) = 1 AND ISNUMERIC( Quantity ) = 1 AND StoreId BETWEEN '101' AND '112' GROUP BY StoreId, LaneNumber, InvoiceNumber, Brand,TransactionNumber ) AS SCLData_Unique_Sale_Summary WHERE SCLData_Unique_Sale_Summary.StoreId = SCLData_Unique_Product_Summary.StoreId AND SCLData_Unique_Sale_Summary.LaneNumber = SCLData_Unique_Product_Summary.LaneNumber AND SCLData_Unique_Sale_Summary.InvoiceNumber = SCLData_Unique_Product_Summary.InvoiceNumber AND SCLData_Unique_Sale_Summary.TransactionNumber = SCLData_Unique_Product_Summary.TransactionNumber
Thanks