Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
fixed insert returning wrong id
Browse files Browse the repository at this point in the history
replaced @@IDENTITY with SCOPE_IDENTITY
  • Loading branch information
Jeremy Keczan committed Dec 13, 2017
1 parent f764cfb commit dbc4d96
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var sql = {

insertQuery: function (collectionName, data) {
var tableName = collectionName;
return 'INSERT INTO ' + tableName + ' (' + sql.attributes(collectionName, data) + ')' + ' VALUES (' + sql.values(collectionName, data) + '); SELECT @@IDENTITY AS [id]';
return 'INSERT INTO ' + tableName + ' (' + sql.attributes(collectionName, data) + ')' + ' VALUES (' + sql.values(collectionName, data) + '); SELECT SCOPE_IDENTITY() AS [id]';
},

// Create a schema csv for a DDL query
Expand Down

0 comments on commit dbc4d96

Please sign in to comment.