Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Spatial data type and Varchar(100)
Message
De
20/11/2011 15:42:24
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Spatial data type and Varchar(100)
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01529320
Message ID:
01529320
Vues:
73
I am working with spatial data type in a table. I have the Latitude and Longitude fields. One field serves for the spatial data type field Geography and is defined GeographyTemporary Varchar(100).

So, basically, with the Latitude and Longitude fields, I have the values. Then, from there, I can populate the GeographyTemporary field with this:
DECLARE @Latitude Float
DECLARE @Longitude Float
DECLARE @Numero Int

SET @Latitude=43.704414
SET @Longitude=-79.431849
SET @Numero=452

UPDATE Client
 SET Latitude=@Latitude,Longitude=@Longitude,
 GeographyTemporary='POINT('+CONVERT(VARCHAR(100),Longitude)+' '+CONVERT(VARCHAR(100),Latitude)+')'
 WHERE Client.Numero=@Numero 
So, this places a value like this in the GeographyTemporary field:

POINT(-79.43185 43.70441)

The GeographyTemporary field is defined Varchar(100). If I change it to Char(100), it gives an error in the UPDATE line after I adjust the syntax for the type CHAR(100) in both locations where the CONVERT() occurs in the SET line. Why is it that Varchar(100) would work and not Char(100)?

Also, why is it needed to define Varchar(100) on that field if the maximum lenght of the POINT definition would be 27 characters? Could Varchar(27) be sufficient?

For informational purposes, GeographyTemporary is used so I can use it later on to dump into the spatial data type such as this:
DECLARE @Numero Int

SET @Numero=452

UPDATE CLIENT
 SET Geography=geography::STGeomFromText(GeographyTemporary,4326)
 WHERE Client.Numero=@Numero 
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform