我有以下查询。我想将结果保存在我的临时表中,并在变量中保存isWithInCircle
值,这是怎么做的?
declare @source geography = geography::Point(30.221101852485987, 71.575927734375, 4326), @target geography = geography::Point(29.9358952133724, 71.817626953125, 4326);
declare @radius_in_miles int = 100;
declare @radius_in_meters float = @radius_in_miles * 1081.7316;
select @target.STBuffer(@radius_in_meters).STContains(@source) AS [isWithinCircle],
@target.STDistance(@source) AS [distance_in_meters],
@target.STBuffer(@radius_in_meters).STDisjoint(@source) AS [isPastCircle];
答案 0 :(得分:1)
基于我对你要做的事情的有限理解,但这应该有用......
IF OBJECT_ID('tempdb..#MyTempTable', 'U') IS NOT NULL DROP TABLE #MyTempTable;
declare @source geography = geography::Point(30.221101852485987, 71.575927734375, 4326), @target geography = geography::Point(29.9358952133724, 71.817626953125, 4326);
declare @radius_in_miles int = 100;
declare @radius_in_meters float = @radius_in_miles * 1081.7316;
declare @isWithinCircle int;
select @target.STBuffer(@radius_in_meters).STContains(@source) AS [isWithinCircle],
@target.STDistance(@source) AS [distance_in_meters],
@target.STBuffer(@radius_in_meters).STDisjoint(@source) AS [isPastCircle]
into #MyTempTable;
select @isWithinCircle = isWithinCircle from #MyTempTable
select @isWithinCircle