As Tomas Takac has commented you can use the
Select @g =
syntax.
DECLARE @g geography;
select @g= geography::Point([Lat], [Long], 4326)
FROM FencePointsBAHA FB
WHERE (Lat <> 0) AND (Long <> 0) and FenceIDFK=16
;
Ensure the where condition returns only one record, other wise the last record will populate the @g.
But the set will also work with a select statement:
DECLARE @g geography;
SET @g= (select geography::Point([Lat], [Long], 4326) as SAME_GEOM
FROM FencePointsBAHA FB
WHERE (Lat <> 0) AND (Long <> 0) and FenceIDFK=16)
;
When using the set method, ensure only one record is returned.
I usually use the select way to populate the variable if it is getting populated via a table record.
Hope that helps out.