def mssql_transaction_count(engine_or_conn: Union[Connection, Engine]) -> int:
    """
    For Microsoft SQL Server specifically: fetch the value of the ``TRANCOUNT``
    variable (see e.g.
    https://docs.microsoft.com/en-us/sql/t-sql/functions/trancount-transact-sql?view=sql-server-2017).
    Returns ``None`` if it can't be found (unlikely?).
    """
    sql = "SELECT @@TRANCOUNT"
    with contextlib.closing(
            engine_or_conn.execute(sql)) as result:  # type: ResultProxy  # noqa
        row = result.fetchone()
        return row[0] if row else None
def mssql_transaction_count ( engine_or_conn : Union [ Connection , Engine ] ) -> int : sql = "SELECT @@TRANCOUNT" with contextlib . closing ( engine_or_conn . execute ( sql ) ) as result : row = result . fetchone ( ) return row [ 0 ] if row else None
For Microsoft SQL Server specifically: fetch the value of the ``TRANCOUNT``
    variable (see e.g.
    https://docs.microsoft.com/en-us/sql/t-sql/functions/trancount-transact-sql?view=sql-server-2017).
    Returns ``None`` if it can't be found (unlikely?).