Error in BIDS developing reports in SQL Server 2008 R2 Reporting Services: "An item with the same key has already been added"
Trying to add a new report via the Wizard or changing the Dataset afterwards to point to a Stored Procedure:
"An error occurred while the query design method was being saved. An item with the same key has already been added."
This even happens in a brand new project.
Help!
Alan Josephson
May 16th, 2010 6:58pm
Hi Alan,
From the error message, it seems the error is caused by error in Transation-SQL statement.
Could you please post the SQL statement? Or, please check if there is any error in the statement.
Thanks,
Jin ChenJin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
May 18th, 2010 11:46am
Mr. Chen,
I have had the same problem. I am using VS 2008, SQL Server 2000. I am using a stored procedure that works fine within SQL Management Studio. It is a simple SELECT statement that joins on a couple of tables.
I have the latest SP on both VS and SQL.
Thanks,
Tony
June 14th, 2010 10:56pm
Hi,
It might simply the use of multiple variables with the same name (Ex: Select table1.client, table2.client from....), you must then define aliases to differenciate them (Ex: Select table1.client as Client1, table2.client as Client2 from....)
Bye,
Johann
Free Windows Admin Tool Kit Click here and download it now
June 15th, 2010 4:52pm
Hi Tony,
Could you please post the stored procedure? That will help us to solve the issue. Appreciate your understanding.
Or, could you please try using a simple stored procedure to check if the issue happens again?
Thanks,
Jin ChenJin Chen - MSFT
June 16th, 2010 12:52pm
I have the same problem : Here is my query:
select dy3.ReportsToPosition, em3.userlogin, dy4.PositionTitle,
dy2.ReportsToPosition As PostionNumber,em1.userlogin,dy3.PositionTitle,
dy2.PositionNumber, em2.Userlogin, dy2.PositionTitle,
case when em2.Userlogin is null then 0 else count(dy1.PositionNumber) end As Direct_Reports
from amProd.dbo.amEmplDept em1
inner join itilDataStore.dbo.dynamique as dy2 on em1.barcode = dy2.ReportsToPosition
inner join amProd.dbo.amEmplDept em2 on dy2.PositionNumber = em2.barcode
left join itilDataStore.dbo.dynamique as dy3 on dy2.ReportsToPosition = dy3.PositionNumber
left join amProd.dbo.amEmplDept em3 on dy3.ReportsToPosition = em3.barcode
left join itilDataStore.dbo.dynamique as dy4 on dy3.ReportsToPosition = dy4.PositionNumber
left join itilDataStore.dbo.dynamique as dy1 on dy1.ReportsToPosition = dy2.PositionNumber
where em1.userlogin = @UserLogin
group by dy3.ReportsToPosition, em3.userlogin, dy4.PositionTitle,dy2.ReportsToPosition,
em1.userlogin,dy3.PositionTitle, em2.Userlogin, dy2.PositionNumber, dy2.PositionTitle
order by em1.userlogin,em2.Userlogin
... now that's a better format of the query.Stephan Neethling MS SQL DBA
Free Windows Admin Tool Kit Click here and download it now
June 29th, 2010 10:23am
I finaly got it !!!
I had a few columns in the query with the same Name
Example
dy2.ReportsToPosition As PostionNumber
and
dy2.PositionNumber
The disgner has build in constraints to make sure you do not have mulit columns with the same name. Excelent !!!
Here is a better version of the same query
select dy3.ReportsToPosition As PositionNumber1,
em3.userlogin As Userlogin1,
dy4.PositionTitle As PositionTitle1,
dy2.ReportsToPosition As PostionNumber2,
em1.userlogin As UserLogin2,
dy3.PositionTitle As PositionTitle2,
dy2.PositionNumber As PositionNumber3,
em2.Userlogin As Userlogin3,
dy2.PositionTitle As PositionTitle3,
case when em2.Userlogin is null then 0 else count(dy1.PositionNumber) end As Direct_Reports
from amProd.dbo.amEmplDept em1
inner join itilDataStore.dbo.dynamique as dy2 on em1.barcode = dy2.ReportsToPosition
inner join amProd.dbo.amEmplDept em2 on dy2.PositionNumber = em2.barcode
left join itilDataStore.dbo.dynamique as dy3 on dy2.ReportsToPosition = dy3.PositionNumber
left join amProd.dbo.amEmplDept em3 on dy3.ReportsToPosition = em3.barcode
left join itilDataStore.dbo.dynamique as dy4 on dy3.ReportsToPosition = dy4.PositionNumber
left join itilDataStore.dbo.dynamique as dy1 on dy1.ReportsToPosition = dy2.PositionNumber
where em1.userlogin = @UserName
group by dy3.ReportsToPosition, em3.userlogin, dy4.PositionTitle,dy2.ReportsToPosition,
em1.userlogin,dy3.PositionTitle, em2.Userlogin, dy2.PositionNumber, dy2.PositionTitle
order by UserLogin2,Userlogin3
Stephan Neethling MS SQL DBA
June 29th, 2010 10:40am
Finnally find the answer of this problem
If two output column have same name in procedure it create such error as in my procedure mt.RoomID added two time so while adding in SSIS R2 it create this error so found sulution self. any way thanks to Iqbal Ansari from IBM Canada who call and
point out issue
mt.RoomID, dbo.GetDATETIME(mt.Datestamp) as DateTimeMTrx, mt.RoomID, mt.StatusCode,
Ericcisco
when i run this procedure it give return after geting perameter input but in SSIS give following Erorr.
"TITLE: Microsoft SQL Server Report Designer
------------------------------
An error occurred while the query design method was being saved. An item with the same key has already been added.
------------------------------
BUTTONS:
OK
------------------------------
"
i have check to create two tble joint it gives output but when joing 3 tables or four it give upper error my procedure is as follows.
ALTER PROCEDURE [dbo].[sp_0_7_TracingItemPart]
(
@Please_Enter_Number_Here nchar(10)
--@Please_S_for_SerialNum_and_T_BarCod nchar(10),
)
AS
SET NOCOUNT ON;
SELECT ms.BarCod ,ms.SerialNo, ms.BatchNo, ms.MoldingMachine, ms.Type, dbo.GetMaterialType(mt.BarCod)as MaterialType,
mt.RoomID, dbo.GetDATETIME(mt.Datestamp) as DateTimeMTrx, mt.RoomID, mt.StatusCode,
dbo.GetDATETIME(s.StopDatestamp), s.Grade, s.PlMax,
dbo.GetDATETIME(p.PalletDate) as PalletDate, p.Shift, p.Line, p.PalletNo, p.ModelNumber
from dbo.ItemPartTrx mt inner join dbo.ItemParts ms on mt.BarCod = ms.BarCod
join dbo.SimulationData s on mt.BarCod = s.BarCod
join dbo.PackingData p on mt.BarCod = p.BarCod
where
ms.SerialNo=@Please_Enter_Number_Here or mt.BarCod = @Please_Enter_Number_Here
Return
but it work well in Sql and even in SSIS run query i.e ! when we run to test In SSIS
i dont know whets wrong in query or what wrong with procedure i checked on various forum but have no answer..........
needs yours help then.
Eric
Free Windows Admin Tool Kit Click here and download it now
November 15th, 2010 7:12am