“An item with the same key has already been added” Error on SSRS When Trying to Set Dataset

后端 未结 2 1212
心在旅途
心在旅途 2020-12-11 14:52

When i try to set the Dataset in SSRS IDE, i get the error you see in the snapshot.

The query works totally fine in SQL Server Management Studio, i wonder where did

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-11 15:26

    I came across this post today when I received the same issue. My problem how-ever was a little bit different.

    I had a temporary table and an If statement in my SP. So my SP looked something like this:

    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 ...
    

    So in order to "refresh" my fields in SSRS, I commented out the If statement and kept one of my queries with the field names. Just had to remember to add everything back afterwards...

    Using Visual Studio 2012 / SQL 2012

提交回复
热议问题