I've got an external data query set up and I'm trying to parameterise it. I've done exactly the same thing with various other queries in the workbook, but there's something about this one that Excel doesn't like:
PHP Code:
SELECT supkey, SUPCompanyName, LSMIdNumber, MATKey, MATDescription, MATRefiningChargeGBP, LSMDiscountPercent, LSMSuppressEaLevy, LSMSuppressTransportCharge, ISNULL((SELECT SUM(JIMQuantityActual) FROM dbo.tb_JIMJobItem WITH (NOLOCK) INNER JOIN dbo.tb_JOBJob WITH (NOLOCK) ON tb_JIMJobItem.JIMJobId = JOBIDNumber INNER JOIN dbo.tb_MATMaterial WITH (NOLOCK) ON dbo.tb_JIMJobItem.JIMMaterialId = dbo.tb_MATMaterial.MATKey WHERE JIMMaterialId = lsmmaterialid AND JOBArrangement in (select distinct supArr.arridnumber from tb_ARRArrangement supArr (nolock) inner join tb_SUPSupplier (nolock) on supArr.arrschemeid = supkey inner join tb_ARRArrangement (nolock) sh on sh.ARRSupplierId = SUPKey where SUPIsSchemeCode = schemeH.SUPIsSchemeCode) AND JOBCollectionDate >= '2012-08-01'), 0) AS ActualQuantityCollected, ISNULL((SELECT SUM(CONVERT (DECIMAL(16,4), JIMQuantityActual) * CONVERT (DECIMAL(16,4), MATNetMarginFactor)) FROM dbo.tb_JIMJobItem WITH (NOLOCK) INNER JOIN dbo.tb_JOBJob WITH (NOLOCK) ON tb_JIMJobItem.JIMJobId = JOBIDNumber INNER JOIN dbo.tb_MATMaterial WITH (NOLOCK) ON dbo.tb_JIMJobItem.JIMMaterialId = dbo.tb_MATMaterial.MATKey WHERE JIMMaterialId = lsmmaterialid AND JOBArrangement in (select distinct supArr.arridnumber from tb_ARRArrangement supArr (nolock) inner join tb_SUPSupplier (nolock) on supArr.arrschemeid = supkey inner join tb_ARRArrangement sh on sh.ARRSupplierId = SUPKey where SUPIsSchemeCode = schemeH.SUPIsSchemeCode)
AND JOBCollectionDate >= '2012-08-01'), 0) AS TotalNominalWeightKg FROM tb_SUPSupplier schemeH (nolock) inner join tb_LSMLinkSupplierMaterial (nolock) on LSMSupplierId = SUPKey inner join tb_MATMaterial (nolock) on LSMMaterialId = MATKey Where schemeH.SUPIsSchemeCode = ?
SUPIsSchemeCode is a string, but when I try to use a cell value as the parameter, I get a Bad Parameter Type error message. I think Excel is expecting the value to be a date since if I try to enter a date, the query fires but I get OBDC errors.
Bookmarks