Jeremy,<div><br></div><div>This seems to be a reasonable requirement. You should create a ticket for this issue at:</div><div><a href="http://trac.osgeo.org/gdal/newticket">http://trac.osgeo.org/gdal/newticket</a>
</div><div><br></div><div>Best regards,</div><div><br></div><div>Tamas</div><div><br></div><div><br><br><div class="gmail_quote">2012/1/12 Jeremy Palmer <span dir="ltr"><<a href="mailto:JPalmer@linz.govt.nz">JPalmer@linz.govt.nz</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm trying to load a CSV file into an existing MSSQL 2008 table using ogr2ogr:<br>
<br>
ogr2ogr -preserve_fid --debug on -append -skip<br>
failures -f MSSQLSpatial "MSSQL:server=xxxx\SQL_SERVER_2008;Integrated Security=true;database=xxxx;tables=test_csv_table_1(shape)" test1.vrt -nln test_csv<br>
_table_1 -s_srs epsg:4167<br>
<br>
The schema I've got is:<br>
<br>
CREATE TABLE [dbo].[test_csv_table_1](<br>
[id] [int] NOT NULL,<br>
[appellation] [text] NULL,<br>
[affected_surveys] [text] NULL,<br>
[parcel_intent] [text] NOT NULL,<br>
[topology_type] [varchar](100) NOT NULL,<br>
[statutory_actions] [text] NULL,<br>
[land_district] [varchar](100) NOT NULL,<br>
[titles] [text] NULL,<br>
[survey_area] [numeric](20, 4) NULL,<br>
[calc_area] [numeric](20, 4) NOT NULL,<br>
[shape] [geometry] NULL,<br>
PRIMARY KEY CLUSTERED<br>
(<br>
[id] ASC<br>
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]<br>
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]<br>
<br>
<br>
This currently fails. The reason being that the SQL generated by ogr2ogr is:<br>
<br>
SET IDENTITY_INSERT [dbo].[test_csv_table_1] ON;<br>
<br>
INSERT INTO [dbo].[test_csv_table_1] (shape, [id], [appellation], [affected_surveys], [parcel_intent], [topology_type], [statutory_actions], [land_district], [titles], [survey_area], [calc_area]) VALUES (geometry::STGeomFromText('POLYGON ((172.7825528 -41.4211097333,172.78229796670001 -41.42127,172.7823694333 -41.4212575333,172.7825528 -41.4211097333))',4167).MakeValid(), 3621203, 'Sec 8 SO 14436', 'SO 14436', 'DCDB', 'Primary', '[Referenced] Stopped Road to be Amalgamated [Tadmor Valley Road, Nelson] New Zealand Gazette 2009 p 186 Stopped and Amalgamated with Land in CT NL72/70', 'Nelson', '464435', 50.0000, 38.3921);SET IDENTITY_INSERT [dbo].[test_csv_table_1] OFF;<br>
<br>
The issue can be resolved if I change my table schema so the id field is an identity column, but I don't want to do this.<br>
<br>
Is it possible to configure (or fix a bug) so the "SET IDENTITY_INSERT" SQL is not executed if the -preserve_fid option is used and the existing table does not have an identity field?<br>
<br>
Cheers,<br>
Jeremy<br>
#####################################################################################<br>
<br>
This message contains information, which is confidential and may be subject to legal privilege.<br>
If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message.<br>
If you have received this message in error, please notify us immediately (Phone 0800 665 463 or <a href="mailto:info@linz.govt.nz">info@linz.govt.nz</a>) and destroy the original message.<br>
LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ.<br>
<br>
Thank You.<br>
<br>
#####################################################################################<br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div><br></div>