我的查询在SSMS中运行良好但在SSRS中不起作用。这是在SSMS中:
declare @or geography = 0xE6100000010CAE8BFC28BCE4474067A89189898A5EC0
declare @dest int =1500
select FirstName+' '+LastName As CustomerName, SpatialLocation as CustomerLocation from Person.Address PA
left join Person.BusinessEntityAddress PBA ON PBA.AddressID=PA.AddressID
left join Sales.Customer SC ON SC.CustomerID = PBA.BusinessEntityID
left join Sales.Store SS ON SS.BusinessEntityID=SC.StoreID
left join Person.Person PP ON PP.BusinessEntityID = PBA.BusinessEntityID
WHERE CustomerID IS NOT NULL
AND @dest >= (@or.STDistance(SpatialLocation)*0.62)
我在SSRS中使用以下内容:
select FirstName+' '+LastName As CustomerName, SpatialLocation as CustomerLocation from Person.Address PA
left join Person.BusinessEntityAddress PBA ON PBA.AddressID=PA.AddressID
left join Sales.Customer SC ON SC.CustomerID = PBA.BusinessEntityID
left join Sales.Store SS ON SS.BusinessEntityID=SC.StoreID
left join Person.Person PP ON PP.BusinessEntityID = PBA.BusinessEntityID
WHERE CustomerID IS NOT NULL
AND @dest >= (@or.STDistance(SpatialLocation)*0.62)
我希望它接受查询并创建两个@dest和@or参数,但它没有。我也检查了查询的情况。有什么想法吗?
答案 0 :(得分:1)
问题解决了! SSRS没有实现类型为geography的参数。所以,我首先在STDistance函数中使用它之前先抛出参数,如下所示:
@dest >= cast(@or as geography).STDistance(SpatialLocation)*0.62
感谢大家的帮助!