How to use the mssql.MAX function in mssql

To help you get started, we’ve selected a few mssql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / mssql / mssql-tests.ts View on Github external
function test_table2() {
    var table = new sql.Table('#temp_table2');

    table.create = true;

    ([
        { name: 'name', type: { typeName: 'VarChar', length: sql.MAX }, nullable: false },
        { name: 'type', type: { typeName: 'Int' }, nullable: false },
        { name: 'type', type: { typeName: 'Decimal', precision: 7, scale: 2 }, nullable: false }
    ] as any[])
        .forEach((col: sql.IColumn) =>
            table.columns.add(col.name, _getSqlType(col.type), { nullable: col.nullable }));

    [['name', 42, 3.50], ['name2', 7, 3.14]].forEach((row: sql.IRow) => table.rows.add(...row));
}
github DefinitelyTyped / DefinitelyTyped / types / mssql / mssql-tests.ts View on Github external
function test_table() {
    var table = new sql.Table('#temp_table');

    table.create = true;

    table.columns.add('name', sql.VarChar(sql.MAX), { nullable: false });
    table.columns.add('type', sql.Int, { nullable: false });
    table.columns.add('amount', sql.Decimal(7, 2), { nullable: false });

    table.rows.add('name', 42, 3.50);
    table.rows.add('name2', 7, 3.14);
}
github LeanKit-Labs / seriate / src / index.js View on Github external
useMetrics: function( metrics, namespace ) {
		this.metrics = metrics;
		this.metricsNamespace = namespace;
	}
};

_.each( sql.TYPES, function( val, key ) {
	seriate[ key ] = sql.TYPES[ key ];
	seriate[ key.toUpperCase() ] = sql.TYPES[ key ];
} );

_.each( sql.ISOLATION_LEVEL, function( val, key ) {
	seriate[ key ] = sql.ISOLATION_LEVEL[ key ];
} );

seriate.MAX = sql.MAX;

var api = _.assign( seriate, Monologue );

connections.on( "connected", function( info ) {
	api.emit( "connected", info );
} );

connections.on( "closed", function( info ) {
	api.emit( "closed", info );
} );

connections.on( "failed", function( info ) {
	api.emit( "failed", info );
} );

module.exports = api;
github LeanKit-Labs / seriate / spec / integration / seriate.spec.js View on Github external
it( "should expose mssql.MAX", function() {
			sql.MAX.should.equal( require( "mssql" ).MAX );
		} );
github DFEAGILEDEVOPS / MTC / functions / census-import / job.data.service.js View on Github external
SET
  jobStatus_id = (
    SELECT id
    FROM [mtc_admin].[jobStatus]
    WHERE jobStatusCode = @jobStatusCode
  ),
  jobOutput=@jobOutput,
  errorOutput=@errorOutput
  OUTPUT Inserted.id
  WHERE urlSlug=@urlSlug`

  const request = new mssql.Request(pool)
  request.input('urlSlug', mssql.UniqueIdentifier, urlSlug)
  request.input('jobStatusCode', mssql.Char(3), jobStatusCode)
  request.input('jobOutput', mssql.NVarChar(mssql.MAX), jobOutput)
  request.input('errorOutput', mssql.NVarChar(mssql.MAX), errorOutput)
  const result = await request.query(sql)
  return R.path(['id'], R.head(R.path(['recordset'], result)))
}
github DFEAGILEDEVOPS / MTC / functions / census-import / census-import.data.service.js View on Github external
module.exports.sqlLoadStagingTable = async (context, pool, censusTable, blobContent) => {
  if (!pool) {
    await this.initPool(context)
  }
  const table = new mssql.Table(censusTable)
  table.create = true
  table.columns.add('id', mssql.Int, { nullable: false, primary: true, identity: true })
  table.columns.add('lea', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('estab', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('upn', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('surname', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('forename', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('middlenames', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('gender', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('dob', mssql.NVarChar(mssql.MAX), { nullable: false })
  for (let i = 1; i < blobContent.length; i++) {
    const row = blobContent[i]
    table.rows.add(i, row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8])
  }

  const request = new mssql.Request(pool)
  const result = await request.bulk(table)
  return result.rowsAffected
}
github DFEAGILEDEVOPS / MTC / functions / census-import / job.data.service.js View on Github external
const sql = `UPDATE [mtc_admin].[job]
  SET
  jobStatus_id = (
    SELECT id
    FROM [mtc_admin].[jobStatus]
    WHERE jobStatusCode = @jobStatusCode
  ),
  jobOutput=@jobOutput,
  errorOutput=@errorOutput
  OUTPUT Inserted.id
  WHERE urlSlug=@urlSlug`

  const request = new mssql.Request(pool)
  request.input('urlSlug', mssql.UniqueIdentifier, urlSlug)
  request.input('jobStatusCode', mssql.Char(3), jobStatusCode)
  request.input('jobOutput', mssql.NVarChar(mssql.MAX), jobOutput)
  request.input('errorOutput', mssql.NVarChar(mssql.MAX), errorOutput)
  const result = await request.query(sql)
  return R.path(['id'], R.head(R.path(['recordset'], result)))
}
github DFEAGILEDEVOPS / MTC / functions / census-import / census-import.data.service.js View on Github external
module.exports.sqlLoadStagingTable = async (context, pool, censusTable, blobContent) => {
  if (!pool) {
    await this.initPool(context)
  }
  const table = new mssql.Table(censusTable)
  table.create = true
  table.columns.add('id', mssql.Int, { nullable: false, primary: true, identity: true })
  table.columns.add('lea', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('estab', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('upn', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('surname', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('forename', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('middlenames', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('gender', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('dob', mssql.NVarChar(mssql.MAX), { nullable: false })
  for (let i = 1; i < blobContent.length; i++) {
    const row = blobContent[i]
    table.rows.add(i, row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8])
  }

  const request = new mssql.Request(pool)
  const result = await request.bulk(table)
  return result.rowsAffected
}