2010-10-12 15 views
17

Kiedy próbuję ustawić zestaw danych w SSRS IDE, pojawia się błąd widoczny w migawce."Element z tym samym kluczem został już dodany" Błąd przy SSRS podczas próby ustawienia zestawu danych

Zapytanie działa całkowicie bez zarzutu w SQL Server Management Studio, zastanawiam się, gdzie się pomyliłem ?!

Połączenie z bazą danych jest dobrze znane.

alt text


OPCJA:

W przypadku, gdy chcesz rzucić okiem na moje pytanie (jej zbyt długo), sprawdziłem to bardzo dobrze. Nic złego w tym:

SELECT Customer.customerID, Customer.companyName, CustomerInvoice.dueDate, CustomerInvoice.cuInvoiceID, CustomerQuote.PONumber, Product.productName, CASE WHEN (SELECT  isTaxPaid 
                FROM   SupplierQuoteProducts 
                WHERE  productID = CustomerQuoteProducts.ProductID) = 1 THEN CustomerQuoteProducts.unitPrice * 1.15 
                WHEN (SELECT  isTaxPaid 
                FROM   SupplierQuoteProducts 
                WHERE  productID = CustomerQuoteProducts.ProductID) = 0 THEN CustomerQuoteProducts.unitPrice 
                ELSE CustomerQuoteProducts.unitPrice 
                END AS "unitPrice", 
         CustomerQuoteProducts.qty, CustomerQuoteProducts.isTaxPaid, PaymentMethod.paymMethDesc, CustomerInvoice.customerQuoteID, CustomerInvDetail.paidDate, CustomerInvDetail.clearedDate, 
         CustomerInvDetail.notes, CustomerInvDetail.sentDate, PaymentExpected.payExpectedTitle, PaymentStatus.paymentStatusTitle, 
CASE WHEN 
(SELECT  isTaxPaid 
FROM   SupplierQuoteProducts 
WHERE  productID = CustomerQuoteProducts.ProductID) = 1 AND CustomerQuoteProducts.qty > 0 AND 
CustomerQuoteProducts.isTaxPaid > 0 THEN (((CustomerQuoteProducts.unitPrice * 1.15) * 1.15) * CustomerQuoteProducts.qty) WHEN 
(SELECT  isTaxPaid 
FROM   SupplierQuoteProducts 
WHERE  productID = CustomerQuoteProducts.ProductID) = 1 AND CustomerQuoteProducts.qty <= 0 AND 
CustomerQuoteProducts.isTaxPaid > 0 THEN ((CustomerQuoteProducts.unitPrice * 1.15) * 1.15) WHEN 
(SELECT  isTaxPaid 
FROM   SupplierQuoteProducts 
WHERE  productID = CustomerQuoteProducts.ProductID) = 0 AND CustomerQuoteProducts.qty > 0 AND 
CustomerQuoteProducts.isTaxPaid > 0 THEN ((CustomerQuoteProducts.unitPrice * CustomerQuoteProducts.qty) * 1.15) WHEN 
(SELECT  isTaxPaid 
FROM   SupplierQuoteProducts 
WHERE  productID = CustomerQuoteProducts.ProductID) = 0 AND CustomerQuoteProducts.qty <= 0 AND 
CustomerQuoteProducts.isTaxPaid > 0 THEN (CustomerQuoteProducts.unitPrice * 1.15) WHEN 
(SELECT  Count(isTaxPaid) 
FROM   SupplierQuoteProducts 
WHERE  productID = CustomerQuoteProducts.ProductID) = 0 AND CustomerQuoteProducts.qty > 0 AND 
CustomerQuoteProducts.isTaxPaid > 0 THEN ((CustomerQuoteProducts.unitPrice * 1.15) * CustomerQuoteProducts.qty) WHEN 
(SELECT  Count(isTaxPaid) 
FROM   SupplierQuoteProducts 
WHERE  productID = CustomerQuoteProducts.ProductID) = 0 AND CustomerQuoteProducts.qty <= 0 AND 
CustomerQuoteProducts.isTaxPaid > 0 THEN (CustomerQuoteProducts.unitPrice * 1.15) WHEN 
(SELECT  isTaxPaid 
FROM   SupplierQuoteProducts 
WHERE  productID = CustomerQuoteProducts.ProductID) = 1 AND CustomerQuoteProducts.qty > 0 AND 
CustomerQuoteProducts.isTaxPaid <= 0 THEN (((CustomerQuoteProducts.unitPrice * 1.15)) * CustomerQuoteProducts.qty) WHEN 
(SELECT  isTaxPaid 
FROM   SupplierQuoteProducts 
WHERE  productID = CustomerQuoteProducts.ProductID) = 1 AND CustomerQuoteProducts.qty <= 0 AND 
CustomerQuoteProducts.isTaxPaid <= 0 THEN ((CustomerQuoteProducts.unitPrice * 1.15)) WHEN 
(SELECT  isTaxPaid 
FROM   SupplierQuoteProducts 
WHERE  productID = CustomerQuoteProducts.ProductID) = 0 AND CustomerQuoteProducts.qty > 0 AND 
CustomerQuoteProducts.isTaxPaid <= 0 THEN ((CustomerQuoteProducts.unitPrice * CustomerQuoteProducts.qty)) WHEN 
(SELECT  isTaxPaid 
FROM   SupplierQuoteProducts 
WHERE  productID = CustomerQuoteProducts.ProductID) = 0 AND CustomerQuoteProducts.qty <= 0 AND 
CustomerQuoteProducts.isTaxPaid <= 0 THEN (CustomerQuoteProducts.unitPrice) WHEN 
(SELECT  Count(isTaxPaid) 
FROM   SupplierQuoteProducts 
WHERE  productID = CustomerQuoteProducts.ProductID) = 0 AND CustomerQuoteProducts.qty > 0 AND 
CustomerQuoteProducts.isTaxPaid <= 0 THEN ((CustomerQuoteProducts.unitPrice * CustomerQuoteProducts.qty)) WHEN 
(SELECT  Count(isTaxPaid) 
FROM   SupplierQuoteProducts 
WHERE  productID = CustomerQuoteProducts.ProductID) = 0 AND CustomerQuoteProducts.qty <= 0 AND 
CustomerQuoteProducts.isTaxPaid <= 0 THEN (CustomerQuoteProducts.unitPrice) END AS [TotalPrice], CASE WHEN row_number() OVER (partition BY 
CustomerInvoice.cuInvoiceId 
ORDER BY newid()) = 1 THEN (CASE WHEN CustomerShipping.isTaxPaid > 0 THEN (CustomerShipping.shippingPrice * 1.15) 
WHEN CustomerShipping.isTaxPaid <= 0 THEN (CustomerShipping.shippingPrice) END) END AS [ShippingCost], 
CASE WHEN row_number() OVER (partition BY 
CustomerInvoice.cuInvoiceId 
ORDER BY newid()) = 1 THEN (CASE WHEN CustomerShipping.isTaxPaidForOrigPr > 0 THEN (CustomerShipping.origShipPrice * 1.15) 
WHEN CustomerShipping.isTaxPaidForOrigPr <= 0 THEN (CustomerShipping.origShipPrice) END) END AS [ShippingOrigCost], 
CustomerShipping.isTaxPaid, 
CustomerShipping.isTaxPaidForOrigPr, 
CustomerShipping.shippingDate, CustomerShipping.trackingNumber, ShippingMethod.shippingVia, CustomerShipping.desAddress, 
CustomerShipping.desCity, CustomerShipping.desPOBox, CustomerShipping.desPostalCode, CustomerShipping.desProvince, CustomerShipping.descName, 
CustomerShipping.packageContent, CustomerShipping.cuShippingID, Country.countryName, CustomerShipping.packageDepth, 
CustomerShipping.packageHeight, CustomerShipping.packageWeight, CustomerShipping.packageWidth, CustomerShipping.pickUpLocation 
FROM   CustomerInvoice INNER JOIN 
         CustomerInvDetail ON CustomerInvoice.cuInvoiceID = CustomerInvDetail.cuInvoiceID INNER JOIN 
         CustomerQuote ON CustomerQuote.CustomerQuoteID = CustomerInvoice.CustomerQuoteID INNER JOIN 
         CustomerQuoteProducts ON CustomerQuoteProducts.CustomerQuoteID = CustomerQuote.CustomerQuoteID INNER JOIN 
         CustomerShipping ON CustomerShipping.CustomerQuoteID = CustomerInvoice.CustomerQuoteID INNER JOIN 
         PaymentStatus ON PaymentStatus.paymentStatusID = CustomerInvDetail.paymentStatusID INNER JOIN 
         Customer ON Customer.CustomerID = CustomerQuote.CustomerID INNER JOIN 
         Product ON CustomerQuoteProducts.productID = Product.productID INNER JOIN 
         Country ON Country.countryID = CustomerShipping.countryID INNER JOIN 
         ShippingMethod ON ShippingMethod.shippingMethodID = CustomerShipping.shippingMethodID INNER JOIN 
         PaymentExpected ON PaymentExpected.paymentExpectedID = CustomerInvDetail.paymentExpectedID INNER JOIN 
         PaymentMethod ON PaymentMethod.paymentMethodID = CustomerInvoice.paymentMethodID 
WHERE CustomerInvoice.cuInvoiceID = @cuInvID 

Odpowiedz

36

Po sformatowaniu skrypt trochę, zauważyłem, że istnieją 2 kolumny o tej samej nazwie, które wybierasz. Pamiętaj, aby zmienić ostateczną nazwę &, aby każda kolumna po uruchomieniu wyciągu w Management Studio zawierała unikalną nazwę unikatową.

Mając na uwadze powyższe, dwie kolumny zauważyłem zduplikowane nazwy są customerquoteproducts.istaxpaid i customershipping.istaxpaid

Mam nadzieję, że pomoże!

+0

widzę, ale te podobne kolumny znajdują się w zupełnie różnych stołach! Wspominam o przedrostku, więc system nie powinien być pomieszany ... Dzięki za pomoc, sprawdzę to ... –

+0

ROZWIĄZANE ............. –

+0

tak, kolejny szalony, niepomocny błąd w Microsoft BI ... Miałem też ten sam problem i zadziałało –

0

Natknąłem się na to stanowisko dzisiaj, kiedy otrzymałem ten sam numer. Mój problem był trochę inny.

Miałem tymczasowy stół i instrukcję If w moim SP. Więc moja SP wyglądał mniej więcej tak:

DECLARE @myCheck as int 
SET @myCheck = 0 

SELECT @myCheck = CASE WHEN [checkfield] = 'xxx' then 1 else 0 end 
    FROM checktable 
    WHERE ... 


SELECT myfields.* 
into #temptable 
FROM mytable 
WHERE ... 


IF @myCheck = 1  --if ssrs does'nt want ot refresh your fields, remove hte if as it does not see past this... 
    select * 
    FROM #temptable 
     LEFT JOIN tableA 
      ON ... 
ELSE 
    select * 
    FROM #temptable 
     LEFT JOIN tableB 
      ON ... 

Więc aby „odświeżyć” swoje pola w SSRS, ja wykomentowane instrukcji If i trzymał jedną z moich kwerend z nazwami pól. Po prostu pamiętać, aby dodać wszystko z powrotem potem ...

użyciu programu Visual Studio 2012/SQL 2012

Powiązane problemy