Reputation: 14280
Why does this work
select geography::STGeomFromText('POINT(-77.010996 38.890358)',4326)
but this doesn't
declare @Latitude decimal(9,6) = 38.890358
declare @Longitude decimal(9,6) = -77.010996
select geography::STGeomFromText('''POINT(' +
cast(@Longitude as nvarchar(15)) + ' ' +
cast(@Latitude as nvarchar(15)) +')''',4326)
What am I missing, they seem to be effectively the same thing.
Upvotes: 0
Views: 4401
Reputation: 52645
Get rid of the extra quotes at the begining and end
declare @Latitude decimal(9,6) = 38.890358
declare @Longitude decimal(9,6) = -77.010996
select geography::STGeomFromText('POINT(' +
cast(@Longitude as nvarchar(15)) + ' ' +
cast(@Latitude as nvarchar(15)) +')',4326)
Upvotes: 4