Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 为什么此地理数据类型的查询在SSMS中有效,但不';你不在SSR工作吗?_Sql_Sql Server_Ssrs 2012 - Fatal编程技术网

Sql 为什么此地理数据类型的查询在SSMS中有效,但不';你不在SSR工作吗?

Sql 为什么此地理数据类型的查询在SSMS中有效,但不';你不在SSR工作吗?,sql,sql-server,ssrs-2012,Sql,Sql Server,Ssrs 2012,我有一个查询在SSMS中运行良好,但在SSRS中不起作用。以下是SSMS中的: declare @or geography = 0xE6100000010CAE8BFC28BCE4474067A89189898A5EC0 declare @dest int =1500 select FirstName+' '+LastName As CustomerName, SpatialLocation as CustomerLocation from Person.Address PA left

我有一个查询在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)
我在SSR中使用以下内容:

 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未实现类型为geography的参数。因此,在STDistance函数中使用参数之前,我首先强制转换参数,如下所示:

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

谢谢大家的帮助

看起来SSRS无法识别您的参数。尝试在SSRS中为这两个变量设置一些默认值,看看是否得到任何结果。我刚刚尝试过,但它不起作用。这是来自存储过程还是嵌入到SSRS中?它是一个嵌入数据集。当你说它不起作用时,你是否收到任何特定错误?