April 8, 2011 at 10:32 am
Hi ,
Am New using the spatial data type
I have two columns Latitude and longitude in Table A.
All i need is create a spatial column(Geometry POINT data type) next to these two columns
Or
Can i create a new table with only spatial column Inserted from Table A(Lat,Long)
Instead of writing 1000s of Insert statements
Any Ideas how to code
Thanks
April 8, 2011 at 11:45 am
looks like this page has some examples of the conversion; i haven't tried this yet:
http://www.sql-server-helper.com/sql-server-2008/convert-latitude-longitude-to-geography-point.aspx
I'm going to have to throw some time into studying this a bit;
create table x(
myLat decimal(19,6),
myLong decimal(19,6) )
insert into x select 12.4567,34.5678
select [GeoLocation] = geography::Point(myLat, myLong, 4326)
from x
Lowell
April 8, 2011 at 12:19 pm
Lowell,
Thanks for ur reply
Instead of using Insert statements.
I Need to insert the values from another Table
Something like
Declare @sql Varchar(max)
Set @sql = 'INSERT INTO SpatialDemo (SpatialData)
VALUES(''POINT('+Latitude+'+' '+'+Longitude+') From Bikes.bike.bike_location'
-- Print @sql
Exec(@sql)
This is wrong but i need to generate proper dynamic statements
Thanks and regards
April 8, 2011 at 12:34 pm
can you confirm this actually returns something from your side: syntactically, it seems to work on my side:
--INSERT INTO SpatialDemo (SpatialData)
--test the select first:, then uncomment the INSERT INTO
SELECT geography::Point(Latitude, Longitude, 4326) From Bikes.bike.bike_location
Lowell
April 8, 2011 at 1:10 pm
Thanks a lot Lowell
Its working and Now i have something to play around
Is there any way we can use Geometry instead of geography
My work around is Planar and geography is more of vector
Thanks and regards
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply