Reputation: 69
I have the following query. I want to save result in my Temp Table and isWithInCircle
value in variable also, how do this?
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];
Upvotes: 0
Views: 230
Reputation: 3363
Based on my limited understanding of what you are trying to do, but this should work...
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
Upvotes: 1