Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Outer Join issue in SSRS

$
0
0

Symptom description:

I have a Department table and an Employee table. In Department table, Deptno is the primary key. In Employee table, Empid is the primary key and Deptno is a foreign key pointing to Deptno of Department table.

Using BIDS, I have created a Data Source View (DSV) incorporating the above two tables and a relationship is also formed where Employee is the source and Department is the destination. I have then autogenerated a Report Model (.smdl) using the DSV.

Now, when I select attributes from both Department entity and Employee entity in Report Builder 3.0, the query generated by Report Builder fetches only those records from Department for which an employee exists.

My objective is to fetch all records from Department when Department is joined with Employee irrespective of whether an employee exists or not for that department. How can this be achieved?

Given below is the query generated by Report Builder:

SELECT DISTINCT
    "DEPT"."DepartmentNo" "DepartmentNo",
    "DEPT"."DepartmentDepartmentName" "DepartmentDepartmentName",
    "DEPT"."City" "City",
    "EMP"."EMPID" "EmployeeID",
    "EMP"."EMP_NAME" "EmployeeName",
    "EMP"."SALARY" "Salary"
FROM
    "CLINICOPIA_REPORTS"."EMP" "EMP"
    LEFT OUTER JOIN (
        SELECT /*+ NO_MERGE */
            "DEPT"."DEPTNO" "DepartmentNo",
            "DEPT"."DEPT_NAME" "DepartmentDepartmentName",
            "DEPT"."CITY" "City",
            "DEPT"."DEPTNO" "DEPTNO"
        FROM
            "CLINICOPIA_REPORTS"."DEPT" "DEPT"
    ) "DEPT" ON "EMP"."DEPTNO" = "DEPT"."DEPTNO"
WHERE
    CAST(1 AS NUMERIC(1,0)) = 1
ORDER BY
    "DepartmentNo", "DepartmentDepartmentName", "City", "EmployeeID", "EmployeeName", "Salary";

Environment: SharePoint 2010 serves as the Web Front-End Server and also hosts Reporting Services Add-in. SQL Server 2008 R2 SP2 is the Back-End Server hosting Sql Server Reporting Services (SSRS) in SharePoint Integrated mode. The data is fetched in the Report Builder 3.0 reports from an Oracle database.

Environment details-

  • Web Front-End Server: SharePoint Server 2010 with Enterprise Client Access License features. Operating System is Microsoft Windows Server 2008 R2 Standard - 64 Bit.
  • Back-End Database Server: SQL Server 2008 R2 Enterprise SP2. Operating System is Microsoft Windows Server 2008 R2 Standard - 64 Bit.
  • Oracle Database Server: Operating System is Red Hat Enterprise Linux Server release 5 (Tikanga). Oracle Database version is Oracle Database 10g R2 Enterprise Edition Release 10.2.0.2.0 - Production.

Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>