refactor update/insert query to support additional features

  - added logic to handle corner cases regarding autoIncrement values
  - added support for OUTPUT variables (mssql)
  - added support for identity wrapping (related to point 1)
Merge pull request #2609 from mbroadst/refactor-update-insert-query

refactor update/insert query to support additional features