title: DatabaseError: ('HY000', '[HY000] [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt (0) (SQLExecDirectW)')
body: <p>I am trying to read data from SQL server into pandas data frame. Below is the code.</p>
  <pre><code>def get_data(size):
      con = pyodbc.connect(r'driver={SQL Server}; server=SPROD_RPT01; database=Reporting')
      cur = con.cursor()
      db_cmd = &quot;select distinct top %s * from dbo.KrishAnalyticsAllCalls&quot; %size
      res = cur.execute(db_cmd)
      sql_out = pd.read_sql_query(db_cmd, con, chunksize=10**6)
      frames = [chunk for chunk in sql_out]
      df_sql = pd.concat(frames)
      return df_sql
  
  df = get_data(5000000)
  </code></pre>
  <p>I am getting following error:</p>
  <blockquote>
  <p>pandas.io.sql.DatabaseError: Execution failed on sql 'select distinct
  top 500000 * from dbo.KrishAnalyticsAllCalls': ('HY000', '[HY000]
  [Microsoft][ODBC SQL Server Driver]Connection is busy with results for
  another hstmt (0) (SQLExecDirectW)')</p>
  </blockquote>
  <p>I had executed the function before and interrupted the execution with <code>ctrl+k</code> as I wanted to make a change in the function. Now, after making the change when I'm trying to execute the function I am getting the above error.</p>
  <p>How can I kill that connection/IPython Kernel since I don't know of any IPython Kernel running executing the query in the function?</p>