- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个查询,可以在 SSMS 上运行时提取准确的数据,但是当我使用具有完全相同查询的 SSRS 创建报告时,它会丢失来 self 使用的两个临时表之一的结果。
DECLARE @from int --= @fromparameter
DECLARE @to int --= @toparameter
/*
For debug
*/
set @from = 0
set @to = 50
/*
================================================================================
Build a temp table with all accounts that have a move out date within params
================================================================================
*/
IF OBJECT_ID('tempdb.dbo.#tempProperty', 'U') is not null drop table #tempProperty
select
sa.spark_AccountNumber
,sa.spark_PropertyIdName
into
#tempProperty
from
SparkCRM_MSCRM.dbo.spark_account sa
where
sa.spark_AccountNumber IN (
select distinct
sa.spark_AccountNumber
--,sa.spark_TenantMoveinDate
--,sa.CreatedOn
--,DATEDIFF(day,sa.spark_TenantMoveinDate,sa.CreatedOn) as [Difference]
from
SparkCRM_MSCRM.dbo.spark_account sa
where
sa.spark_TenantMoveinDate BETWEEN dateadd(DAY,@from,getdate()) AND dateadd(DAY,@to,getdate())
)
/*
================================================================================
--create CTE with all accounts per property
================================================================================
*/
--;with RowRanked (AccountNumber,Name,Rowrank,MoveinDate,MoveOotDate,SProperty,PProperty)
--AS
--(
IF OBJECT_ID('tempdb.dbo.#temp', 'U') is not null drop table #temp
SELECT
sa.spark_AccountNumber [Account Number]
,sa.spark_name [Account Name]
,ROW_NUMBER() OVER(PARTITION BY sa.spark_PropertyIDName ORDER BY COALESCE (sa.spark_TenantMoveinDate, sa.spark_agreementdate) DESC) [rowRank]
,COALESCE (sa.spark_TenantMoveinDate, sa.spark_agreementdate) [Tenant Move In Date]
,sa.spark_TenantMoveoutDate [Tenant Move Out Date]
,sa.spark_PropertyIdName [Property ID]
,p.spark_name [Property Name]
into #temp
FROM
SparkCRM_MSCRM.dbo.spark_property p
LEFT JOIN
SparkCRM_MSCRM.dbo.spark_account sa
on sa.spark_PropertyId = p.spark_propertyId
WHERE
sa.spark_PropertyIdName IN (SELECT spark_PropertyIdName from #tempProperty)
--)
/*
================================================================================
build final dataset
================================================================================
*/
select distinct
sa.spark_AccountNumber [Account Number]
,sa.spark_name [Name]
,concat (
sa.spark_HouseNumber ,' ',
sa.spark_HouseName ,' ',
sa.spark_Address1 ,' ',
sa.spark_Address2 ,' ',
sa.spark_Address3 ,' ',
sa.spark_Address4 ,' ',
sa.spark_Postcode
) [Address]
,sa.spark_Email [Email]
,sa.spark_HomePhone [Landline]
,sa.spark_Mobile [Mobile Number]
,COALESCE(a3.Name,a2.Name,a1.Name) [Letting Agent Partner]
,sa.spark_tariffidName [Tariff]
,sa.spark_PPMTariffName [PPM Tariff]
,pm.Option_Label [Payment Method]
,sa.spark_Balance [Account Balance]
,sa.spark_IntendedMoveOut [Date of Likely Move Out]
,sa.spark_TenantMoveoutDate [Current Tenant Move Out Date]
,rr.[Account Number] [New Account Number]
,rr.[Tenant Move In Date] [New Account Move In Date]
,case
when pc.spark_CallDriver is not null
then 'Yes'
else
'No'
end [Arrangement to Pay]
,ds.Option_Label [Stops]
from
SparkCRM_MSCRM.dbo.spark_account sa
--inner join
-- DBS.dbo.Meter m
-- on m.cust_ref = sa.spark_AccountNumber collate DATABASE_default
-- and m.meter_status = 2
left join
SparkCRM_MSCRM.dbo.spark_property sp
on sp.spark_propertyid = sa.spark_propertyid
left join
SparkCRM_MSCRM.dbo.account a1 --branch
on sp.spark_PartnerId = a1.accountid
left join
SparkCRM_MSCRM.dbo.account a2 --brand
on a1.parentaccountid = a2.accountid
left join
SparkCRM_MSCRM.dbo.account a3 --partner
on a2.parentaccountid = a3.accountid
left join
SparkCRM_Custom.dbo.GetCRMOptions('spark_account', 'spark_paymentmethod') pm
ON pm.Option_Value = sa.spark_paymentmethod
left join
SparkCRM_Custom.dbo.GetCRMOptions('spark_account','spark_DebtorStatus') ds
on ds.Option_Value = sa.spark_DebtorStatus
left join
SparkCRM_MSCRM.dbo.PhoneCall pc
on pc.spark_Account = sa.spark_accountId
and pc.spark_CallDriver = 101
left join
#temp rr
on rr.[Property ID] = sa.spark_PropertyIdName
and rr.Rowrank = 1
where
coalesce(
sa.spark_IntendedMoveOut
,sa.spark_TenantMoveoutDate
)
BETWEEN
dateadd(DAY,@from,getdate()) AND dateadd(DAY,@to,getdate())
and
sa.spark_name not like '%occupier%'
当我在 SQL Server Management Studio 中运行查询时,这会返回数据,但将其复制到 SSRS 报表生成器中似乎会从 #temp 表中删除任何结果。您会注意到,我最初对第二个表使用 CTE,但我尝试使用临时表,以防 SSRS 与 CTE 发生冲突。
任何帮助将不胜感激!
最佳答案
您应该避免在 Reporting Services 中使用 #temp 表,如果没有其他原因,如果人们尝试同时运行报表,将会导致各种麻烦。
您最好创建一个您的报告可以调用的存储过程。这将允许您根据需要应用索引和其他性能修改,并且其行为与在 SSMS 中独立运行查询完全相同
关于sql-server - 查询结果与 SSRS 结果不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33647350/
我有一个大型 SSRS 2008 服务器报告项目(超过 200 个报告)。目前我公司的策略已经改变,我们希望将这些服务器报告转换为客户端报告。 所有服务器报告都使用存储过程(或在某些情况下来自 SQL
我有一个 SSRS 2008 R2 报告,它在表格中使用了这个表达式: =Lookup(Fields!DataSet1Date.Value, Fields!DataSet2Date.Value, Fi
我在 SSRS 报告上有一个 tablix,它从存储过程中获取数据。 当没有数据存在时,我试图向用户显示一条消息,例如“**此报告没有数据* ”。我可以通过在 **NoRowsMessage 中指定此
我试图让这个专栏聊天的标 checkout 现在专栏基地,就像下面的第二张图片一样。然而,该解决方案并不完全有效,因为它歪曲了其余信息。 有没有人知道实现这一目标的适当方法,这不是直截了当的,这很令人
如何获取 SSRS 报告以显示网页 View ? 当我转到 SSRS 报告页面时,它没有显示网页 View 。它显示了数据源、数据集和报告文件夹的列表。 进入报告文件夹后,我可以通过单击它们来调用报告
我正在寻找一种方法来从我的 SSRS 报告中获取版本信息。我有几个环境,希望能够比较在这些环境中部署了哪个报告版本。在 SSIS 中,这非常容易,因为每个 SSIS 包在修改和保护后都会获得一个新版本
我有一个作为 SSRS 报告后端运行的存储过程(它对值进行透视和反透视)。用户提供 2 个输入(BeginRange 和 EndRange)。 结果会根据用户输入而变化,因此我也需要在报告中反射(re
我一直在网上寻找一种在 SSRS (2008 R2) 中完全组合数据集的方法。 基本上,我需要创建一个由多个不同数据集(都具有如下相同的列)组成的表和图,这些数据集是从多个 sql 服务器检索的(防止
我有一份包含多个数据集的报告。不同数据集中的不同字段用于报告的不同位置。 在报告的一部分中,我需要使用两个不同数据集中的字段进行计算。这在表达式中可能吗? 我可以以某种方式在表达式中引用该字段所在的数
我在 Business Intelligence Studio 2008 中内置了一个 RDL 报告,但遇到了不需要的分页符问题。 我有一个数据集,其中包含一个带有一些汇总数据的单表。我已经添加了一个
解决方案 SSRS - How to build a simple multi-column report? 表示报表属性下有一个布局选项卡。我已经用谷歌搜索了这个主题,并且在多个地方都提到了相同的菜
我在 Sql Server Reporting Services (SSRS) 2008 R2 中运行报表时遇到问题。 在设置站点、创建一些用户并上传一些报告之后,我选择了一个要运行的报告,输入我的参
我有一个包含多个行组的矩阵的 SSRS (2008 R2) 报告。我需要扩展所有其他组,同时只有一个切换项。我隐藏所有必要的组,并在我需要的文本框中设置切换项。它在 VisualStudio 中运行良
我在 SSRS 中有报告,我可以使用以下表达式交替行颜色: =IIF(ROWNUMBER(NOTHING) MOD 2, "LightSteelBlue","WhiteSmoke") 这很好用。但是,
啊啊! 受不了,我自己也想不通...... 我在报告中的数字格式中使用了它: '€' #,0.00;('€' #,0.00) 格式为 € 1,212.89 这不完全是我想要的,因为我想要 € 1.21
我有一个简单的 SSRS 报告,显示一个表中的数据。我想要做的是在下拉列表中显示与该表不同的列表,供用户选择。如果我只使用一个数据集,我可以让它显示,但它会多次显示该列中的值。 示例 Bob Bob
SSRS 2008 已经运行了很长时间。 我们已经在同一台服务器上安装了 SSRS 2012,它似乎有点破坏了 SSRS 2008 共享点模式。 所有 .rdl 和 .rsds 文件不再与服务器“关联
我们正在从 Crystal Reports 迁移我们的报告至 SSRS .在 Crystal 报表中,我们使用 变量 至 动态 生成我们的文件名,以便当报告通过电子邮件发送时,文件具有报告名称和执行日
我想将一些文本加粗并加下划线,如果我的数据库中的字段值为“HD” 我的意思是,我在数据库中有两个文件。文本 1 和标题。我在报告中显示 Text1,如果 Header 的值为“HD”,则 Text1
我正在使用 BIDS 和 SQL Server Reporting Services (SSRS) 2008 R2 来构建报告。我希望每个类别都显示为单独的表格/网格。 重要提示:列(CELERY、E
我是一名优秀的程序员,十分优秀!