 
     @connection.execSqlBatch(request)
 
+  createProc: (callback) =>
+    request = new Request('''
+      CREATE PROCEDURE #proc
+      AS
+        SET NOCOUNT ON;
+
+        begin transaction
+        insert into #temp (id) values(1)
+        commit transaction
+      GO'''
+    , (err) =>
+      @test.ok(!err)
+      callback(err)
+    )
+
+    @connection.execSqlBatch(request)
+
+  execProc: (callback) =>
+    request = new Request('exec #proc', (err) =>
+      @test.ok(!err)
+      callback(err)
+    )
+
+    @connection.execSqlBatch(request)
+
   insert: (callback) =>
     request = new Request('insert into #temp (id) values(1)', (err) =>
       @test.ok(!err)

  selectExpectOneRow: (callback) =>
    @select(callback, 1)

  beginTransaction: (callback) =>
    @connection.beginTransaction((err, transactionDescriptor) =>
      @test.ok(!err)
      @test.ok(transactionDescriptor)

      callback(err)
    , 'abc')

  commitTransaction: (callback) =>
    @connection.commitTransaction((err) =>

      async.series(actions)
    )

exports.transactionCommit = (test) ->
  test.expect(8)

  tester = new Tester(test)
  tester.run([
    tester.createTable
    tester.beginTransaction1
    tester.insert
    tester.commitTransaction
    tester.selectExpectOneRow
    tester.close
  ])

exports.transactionRollback = (test) ->
  test.expect(7)

  tester = new Tester(test)
  tester.run([
    tester.createTable
    tester.beginTransaction1
    tester.insert
    tester.rollbackTransaction
    tester.selectExpectZeroRows
    tester.close
  ])

exports.nestedTransactionCommit = (test) ->
  test.expect(11)

  tester = new Tester(test)
  tester.run([
    tester.createTable
    tester.beginTransaction1
    tester.beginTransaction2
    tester.insert
    tester.commitTransaction
    tester.commitTransaction
    tester.selectExpectOneRow
    tester.close
  ])

exports.nestedTransactionRollbackOuter = (test) ->
  test.expect(10)

  tester = new Tester(test)
  tester.run([
    tester.createTable
    tester.beginTransaction1
    tester.beginTransaction2
    tester.insert
    tester.commitTransaction
    tester.rollbackTransaction
    tester.selectExpectZeroRows
    tester.close
  ])

exports.nestedTransactionInProcCommit = (test) ->
  test.expect(9)

  tester = new Tester(test)
  tester.run([
    tester.createTable
    tester.createProc
    tester.beginTransaction1
    tester.execProc
    tester.commitTransaction
    tester.selectExpectOneRow
    tester.close
  ])

exports.nestedTransactionInProcRollbackOuter = (test) ->
  test.expect(8)

  tester = new Tester(test)
  tester.run([
    tester.createTable
    tester.createProc
    tester.beginTransaction1
    tester.execProc
    tester.rollbackTransaction
    tester.selectExpectZeroRows
    tester.close
  ])
