Thursday, 16 March 2017

NodeJS - How to bulk insert spatial table to SQLSERVER (mssql) using node-mssql or sequelize?

I am trying to bulk insert a table has geometry column to SQLSERVER

var sql = require('mssql');
sql.connect("mssql://user:pwd@localhost/test").then(function () {

        var table = new sql.Table('myTbl'); 
        table.create = true;
        table.columns.add('name', sql.VarChar(250), { nullable: true });
        table.columns.add('geom', sql.Geometry, { nullable: true });

        var point = { type: 'Point', coordinates: [48.6541, 21.987465] }
        table.rows.add('my location', point);
        request.bulk(table, function (err, rowCount) {
                if (err) {
                    console.log(err);
                } else {
                    console.log(rowCount);
                }
        });
   }

But I'm getting error : Invalid column type from bcp client for colid 2. Does anybody know how to do this by anyway(using mssql or sequelize)?



via shesomanru

No comments:

Post a Comment