title: A cursor with the name ... already exists - SQL Server 2008
body: <p>I have a trigger that is used to perform some auditing tasks when changes are made to a table. Within this trigger there is a WHILE loop, and in the loop there is a cursor that is declared, used, closed and then deallocated before the next iteration of the loop.</p>
  
  <p>When I call a stored procedure that changes the table and in turn causes the trigger to run, and I do this from within the Management Studio, all works as expected.</p>
  
  <p>However, when this stored procedure is called from within my Java web application, I get an error: "A cursor with the name ...  already exists".</p>
  
  <p>Is there a reason why this stored procedure would work when I execute it manually, and not work when run from the web application?</p>