为什么这个地理数据类型的查询在 SSMS 中有效,但在 SSRS 中无效?

Why this query with geography data type works in SSMS but doesn't work in SSRS?

我有一个在 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 参数,但它没有。我也检查了案例查询。有什么想法吗?

问题已解决! SSRS 没有实现地理类型的参数。所以,我先转换参数,然后再像这样在 STDistance 函数中使用它:

@dest >= cast(@or as geography).STDistance(SpatialLocation)*0.62

感谢大家的帮助!