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

Cannot create a dataset in SSRS

$
0
0

I have the following SSRS report:

As you can see I have three different Datasets (AllDivisions, AllActiveSalesperson andRolloffRevenueSummary).

For unknown reason to me, I am not able to create the dataset for RolloffRevenueSummary but I am able to create the other two datasets without any issues.  I am using the same exact data sources.  I tested the connection and I was able to connect successfully.  I also tested the query used to created RolloffRevenueSummary and the query ran successfully.

Here is the query I used to create RolloffRevenueSummary dataset:

I appreciate the help!

USE MASTER  --- Uses Master DB to get Tower Databases Dynamically

------ Tower Stats Temp Table --------------------------------------
CREATE Table #TempTable
(
CompanyID	varchar(34),
CustClass	varchar(34), 
SiteID		varchar(34), 
SiteName varchar (30),
WorkOrderID varchar (30),
CustType varchar (30),
Driver varchar (30),
LineOfBusiness varchar (30), 
Route varchar (30),
Worker varchar (30),
Vehicle varchar (30),
WorkDate datetime, 
DayName varchar (30),
Charges float,					  
Status varchar (30), 
WorkflowCode varchar (30), 
CompanyName varchar (30), 
Salesperson varchar (30),
TemporaryPermanent smallint
)

---- Cursor for returing all db names for reporting purposes -----

DECLARE @name Varchar(80) -- database Name

---- Exclude non-Tower DBs and demo dbs --------------------------
DECLARE db_cursor CURSOR FAST_FORWARD FOR  
SELECT name 
FROM master..sysdatabases
WHERE NAME NOT IN ('MASTER', 'TEMPDB', 'MODEL', 'MSDB', 'DOSSIERREPORTING', 'DOSSIER', 'MDBADB',
'TRANSFERSTATION', 'DBRS_distribution',

'Columbia' )
AND (NAME NOT LIKE '%REPORTSERVER%')
AND (NAME NOT LIKE '%TEST%')
AND (NAME NOT LIKE '%BU')
AND (NAME NOT LIKE 'PCS%')
AND (NAME NOT LIKE '%DEMO%')
AND (NAME NOT LIKE 'TOWER%')
AND (NAME NOT LIKE '%ETOWER%')


OPEN db_cursor   
FETCH NEXT FROM db_cursor INTO @name   

WHILE @@FETCH_STATUS = 0   
BEGIN   
       
------  BEGIN QUERY RESULTS -----------------------
declare @SQL nvarchar(max) 
set @SQL = 
------  Tower Stats Insert ------------------------ 
'USE ['+@name+'] 

INSERT INTO #TempTable
(CompanyID ,
CustClass ,
SiteID ,
SiteName ,
WorkOrderID ,
CustType ,
Driver ,
LineOfBusiness , 
Route  ,
Worker ,
Vehicle  ,
WorkDate , 
DayName  ,
Charges ,					  
Status  , 
WorkflowCode,
CompanyName  , 
Salesperson  ,
TemporaryPermanent
 )




--------------------------Tower Query ---------------------------------------------------

SELECT 
 
 Company.CompanyID,
 Customer.CustClass,

 Site.SiteID,
 Site.SiteName,
 ServiceHistory.WorkOrderID,
 Route.CustType,
 DailyRouteEntry.Driver,
 Route.LineOfBusiness, 
 ServiceHistory.Route,
 Worker.Worker,
 DailyRouteEntry.Vehicle,
 DailyRouteEntry.WorkDate, 
 DayName = 
  CASE (DATEPART(dw, DailyRouteEntry.WorkDate) + @@DATEFIRST) % 7
    WHEN 1 THEN ''Sunday''
    WHEN 2 THEN ''Monday''
    WHEN 3 THEN ''Tuesday''
    WHEN 4 THEN ''Wednesday''
    WHEN 5 THEN ''Thursday''
    WHEN 6 THEN ''Friday''
    WHEN 0 THEN ''Saturday''
  END,
 ISNULL(WorkOrder_vw_Totals.Charges,0) Charges,
 ServiceHistory.Status, 
 LTRIM(RTRIM(WorkflowCode.WorkflowCode)) AS WorkflowCode, 
 Company.CompanyName, 
 Site.Salesperson,
 ServiceInfo.TemporaryPermanent
 FROM   ((((((([WPSQL01\TOWER].['+@name+'].[dbo].WorkflowCode WorkflowCode 
 LEFT OUTER JOIN ((([WPSQL01\TOWER].['+@name+'].[dbo].DailyRouteEntry DailyRouteEntry 
 LEFT OUTER JOIN [WPSQL01\TOWER].['+@name+'].[dbo].ServiceHistory ServiceHistory 
 ON (DailyRouteEntry.Route=ServiceHistory.Route) AND (DailyRouteEntry.WorkDate=ServiceHistory.ServiceDate)) 
 LEFT OUTER JOIN [WPSQL01\TOWER].['+@name+'].[dbo].Route Route ON DailyRouteEntry.Route=Route.Route) 
 LEFT OUTER JOIN [WPSQL01\TOWER].['+@name+'].[dbo].Worker Worker ON DailyRouteEntry.Driver=Worker.Worker) 
 ON WorkflowCode.WorkflowCode=ServiceHistory.WorkflowCode) 
 LEFT OUTER JOIN [WPSQL01\TOWER].['+@name+'].[dbo].WorkOrder_vw_Totals WorkOrder_vw_Totals 
 ON ServiceHistory.WorkOrderID=WorkOrder_vw_Totals.WorkOrderID) 
 LEFT OUTER JOIN [WPSQL01\TOWER].['+@name+'].[dbo].Trip Trip 
 ON ServiceHistory.WorkOrderID=Trip.WorkOrderID) 
 LEFT OUTER JOIN [WPSQL01\TOWER].['+@name+'].[dbo].ServiceBilling ServiceBilling 
 ON ServiceHistory.ServiceInfoUID=ServiceBilling.ServiceInfoUID
 INNER JOIN [WPSQL01\TOWER].['+@name+'].[dbo].ServiceInfo ServiceInfo 
	ON ServiceInfo.ServiceInfoUID = ServiceHistory.ServiceInfoUID) 
 LEFT OUTER JOIN [WPSQL01\TOWER].['+@name+'].[dbo].Site Site 
	ON ServiceBilling.SiteID=Site.SiteID) 
 LEFT OUTER JOIN [WPSQL01\TOWER].['+@name+'].[dbo].Customer Customer 
	ON Site.CustID=Customer.CustID
 LEFT OUTER JOIN [WPSQL01\TOWER].['+@name+'].[dbo].Company Company
	ON Company.CompanyID = Site.CompanyID) 
 LEFT OUTER JOIN [WPSQL01\TOWER].['+@name+'].[dbo].WP_Solomon_Budgets B
	ON B.CompanyID = Company.CompanyID and GLAcct in (''401102410000'',''401102510000'',''401202410000'',''451202410000'') and LedgerType = ''budget'')
 WHERE (DailyRouteEntry.WorkDate BETWEEN ''02-01-2013'' AND ''02-01-2013'') 
 AND ServiceHistory.Status=1 AND Route.LineOfBusiness IN (''T'', ''Temporary'', ''Roll Off'', ''RollOff'')
 -------------------------------------------------------------------------------------
 --AND ISNULL(Site.Salesperson,0) =      -- Select All Salesperson or Single Salesperson
 --          (CASE @Salesperson
	--			WHEN ''All'' THEN ISNULL(Site.Salesperson,0)
	--			ELSE  @Salesperson
 --           END)
--------------------------------------------------------------------------------------
 AND ISNULL(Company.CompanyID,0) =     ''0102'' -- Select All Divisions or Single Division
    --       (CASE @Division
				--WHEN ''All'' THEN ISNULL(Company.CompanyID,0)
				--ELSE  @Division
    --        END)
--------------------------------------------------------------------------------------


GROUP BY 
		
		
		ServiceHistory.WorkOrderID, 
		Customer.CustClass, 
		Site.SiteID, 
		Site.SiteName,
		Company.CompanyID, 
		Route.CustType, 
		DailyRouteEntry.Driver,
		Route.LineOfBusiness, 
		ServiceHistory.Route, 
		Worker.Worker,
		DailyRouteEntry.Vehicle, DailyRouteEntry.WorkDate, WorkOrder_vw_Totals.Charges,
		ServiceHistory.Status, WorkflowCode.WorkflowCode, Company.CompanyName, Site.Salesperson, 
		ServiceInfo.TemporaryPermanent


'


	   execute sp_executesql @SQL
			
			       
       FETCH NEXT FROM db_cursor INTO @name 
       
         
END  

CLOSE db_cursor   
DEALLOCATE db_cursor 



 
---------------------------------------------------------------------   
---- Drop Temp Tables
  
Drop table #TempTable


Viewing all articles
Browse latest Browse all 10045

Trending Articles



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