title: Reusing Deallocated Cursor again for deletion
body: <p>I have declared a Cursor which fetches me all Ticket Ids created on a particular month and I am using it for insertion.</p>
  
  <p>Once Insertion is Success, I am Deallocating the Cursor and Commiting the Transaction. </p>
  
  <p>-->>Now I want to Delete the records based on the Success message. Like If messaage = 'Success', then Delete.</p>
  
  <p>But problem is I have to pass that Ticket Ids to delete.</p>
  
  <hr>
  
  <p>DECLARE @Tickets CURSOR
  BEGIN TRANSACTION INSERTION;</p>
  
  <pre><code>    SET @Tickets= CURSOR READ_ONLY FOR SELECT TICKET_ID FROM TICKETMASTER
  </code></pre>
  
  <p>Then INSERT Query where I am passing Ticket Ids to insert in the table</p>
  
  <p>open @Tickets 
  CLOSE @Tickets 
  DEALLOCATE @Tickets
  SET @message='SUCCESS'  </p>
  
  <h2>COMMIT TRANSACTION INSERTION;</h2>
  
  <p>Now I am Beginning another Transaction for Deletion</p>
  
  <p>BEGIN TRANSACTION DELETION;</p>
  
  <p>Here I want to delete again the rows which I have inserted only when @message is success and I have to pass the Ticket ids to delete.</p>
  
  <p>like Delete from TICKETMASTER Where TICKET_ID = @tickets</p>
  
  <p>--</p>
  
  <p>I don't want to set the cursor again to get the ticket ids. Want to use the same @tickets Cursor for deletion just by opening again.</p>
  
  <p>I have deallocated the @tickets cursor, so Can I reuse it again just by giving</p>
  
  <p>Open @tickets
  if(message='Success')
  delete from TICKETMASTER Where TicketId = @tickets</p>