MSSpatial (when connecting to SQL Server) set varchar primary keys as FID integer
|Reported by:||robe||Owned by:||tamas|
I haven't tested this on lower and maybe this is the first time I've tried to query a table that didn't have an integer for primary key.
If my table has a primary key and that column is say a varchar(50), then ogr_info and friends map it to FID but set it as an integer, so all the values end up coming back as 0. So to work around the issue I always have to take off the primary key.
I thought it may be a general ODBC issue, but I tried it on an MS Access db with a table that has a varchar field and it doesn't try to map it to FID.
For perspective here is an example OGR info output from a SQL Server 2008 R2. I get the same behavior with both ODBC and MSSpatial driver
That pgName field is the primary key and if I remove the primary key, then it comes thru as a regular old field.
Layer name: dbo.PersGroups Geometry: Unknown (any) Feature Count: 11 Layer SRS WKT: (unknown) FID Column = pgName pgRights: String (0.0) pgTemplates: String (1000.0) pgRecordSchedule: String (2000.0) pgParentName: String (50.0) OGRFeature(dbo.PersGroups):0 pgRights (String) = *AllRights pgTemplates (String) = (null) pgRecordSchedule (String) = (null) pgParentName (String) = (null)
Change History (15)
comment:4 Changed 16 months ago by
|Summary:||MSSpatial and ODBC (when connecting to SQL Server) set varchar primark keys as FID integer → MSSpatial (when connecting to SQL Server) set varchar primary keys as FID integer|