Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Spatial data type and Varchar(100)
Message
 
To
20/11/2011 16:14:25
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01529320
Message ID:
01529324
Views:
36
This message has been marked as a message which has helped to the initial question of the thread.
>>Because both CONVERT() exceeds the defined length of the field.
>>
>>UPDATE ... SET ...
>>           GeographyTemporary='POINT('+CONVERT(CHAR(100),Longitude)+' '+CONVERT(CHAR(100),Latitude)+')'
>>
>>Will give you total length of 208 and the field is defined as CHAR(100).
>
>Thanks, so basically, if I would want to use a Char field type, I would need to define it 208. When using Varchar(100), its maximum length is much greater than 100 then. Do you know what it is? Or, if I would wish to define it to a lower value, to support this, would there be a better field declaration than Varchar(100)?

No, when you define it as Varchar(100) you still can enter only 100 chars maximum.
If you want to use CHAR(100) you just need to change the convert and use varchar() there. Then it will work also.
GeographyTemporary -> CHAR(100)

-- That should work:
UPDATE ... SET ...
           GeographyTemporary='POINT('+CONVERT(varchar(100),Longitude)+' '+CONVERT(varchar(100),Latitude)+')'
Because I doubt the Longitude or Latitude can exceed 100 chars each when you convert them.
When you convert something to VARCHAR SQL Server converts it and remove all trailing spaces. When you convert it to CHAR() SQL Server add trailing spaces to match the length of the field.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform