Can I close DataReader using T-SQL commands in SQL Server Management Studio 2005

Posted on 2011-10-12
Last Modified: 2013-04-21
I have a job that runs every night that executes SQL commands to import data from a flat text file to a table in my database (after truncating the file).  For some reason, it appeared to get stuck last night.  I went to the Job Activity Monitor and stopped the job (which I probably shouldn't have done).  I want to try to import the data again, but it appears the table is "locked."  If I try to open the table, I get an error message that says "Lock request time out period exceeded." If I look at the table properties using Mgmt Studio, it takes a while to bring them up, then several of the properties say "There is already an open DataReader associated with this Command that must be closed first."  Is there a way to close the datareader?  Do I have to just delete the table and start over?
Question by:EDCTECH
    LVL 28

    Expert Comment

    Have you tried killing all connections and/or restarting the server?

    Author Comment

    I don't want to restart the server because there are other applications running on it.  
    I found the session id for the task that had frozen up.  I tried to Kill that session, and the following message came up: SPID 57: transaction rollback in progress. Estimated rollback completion: 0%. Estimated time remaining: 0 seconds.
    The session still showing as suspended.  Any other ideas?
    LVL 28

    Expert Comment

    If that is the case, I would say refer to this:

    You can restart the SQL service which will have a shorter impact than a full server restart.

    Accepted Solution

    Thank you very much for your assistance.  While I was researching how to restart the SQL Server Instance service, the rollback must have completed and the session was gone.  I was able to open the table to verify that there were no records in in, and I was able to import the data into the table manually using the Import/Export wizard.  Hopefully it will run okay tonight.
    Thanks again.

    Author Closing Comment

    The problem resolved itself without intervention

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now