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

后端 未结 2 1209
心在旅途
心在旅途 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

    0 讨论(0)
  • 2020-12-11 15:27

    After formatting your script a bit, I noticed that there are 2 columns with the same name that you are selecting. Make sure to change the final name & that every column when you do run your statement in Management Studio has a unique name.

    That being said, the two columns I noticed have duplicate names are customerquoteproducts.istaxpaid and customershipping.istaxpaid

    I hope that helps!

    0 讨论(0)
提交回复
热议问题