From dbc4d96d4734e6873335b8d998247c5704cbc3df Mon Sep 17 00:00:00 2001 From: Jeremy Keczan Date: Wed, 13 Dec 2017 09:12:02 -0500 Subject: [PATCH] fixed insert returning wrong id replaced @@IDENTITY with SCOPE_IDENTITY --- lib/sql.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sql.js b/lib/sql.js index 58fd61b..bc37452 100644 --- a/lib/sql.js +++ b/lib/sql.js @@ -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