Wednesday, November 16, 2011

The database is in single-user mode, and a user is currently connected to it

PROBLEM:
You get one of the following errors in Microsoft Sql Server Management Studio when trying to access database
  • Database is already open and can only have one user at a time.
  • Changes to the state or options of database cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.

SOLUTION:
You need to kill all database sessions and get the database out of single-user mode


use master
GO
-- the following query lists all database sessions
select d.name, d.dbid, spid, login_time, nt_domain, nt_username, loginame
from sysprocesses p inner join sysdatabases d on p.dbid = d.dbid
where d.name = 'db_name'
GO
-- kill session using SPID number
kill 52
GO
exec sp_dboption 'db_name', 'single user', 'FALSE'
GO


If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!


40 comments:

  1. You saved my job just now!!

    ReplyDelete
  2. good fix... thank god... :-)

    ReplyDelete
  3. You saved me today

    ReplyDelete
  4. Thanks, its very useful :-)

    ReplyDelete
  5. Damn bro, you are awesome. worked like a charm

    ReplyDelete

  6. Parking software condominium
    email blast to tenants
    Guest parking
    Software for parking enforcement, parking violations and parking management”
    World-wide-web solutions in a group retain the most important data fiscal information and other very sensitive and exclusive information will be transported and located. Property or home Operators condo supervisors, Panel Associates, professional property or home and linked to overseeing was able car parking setting.
    You need dependable, progressive in addition to successful software program to handle your current businesses auto parking in addition to customer passes. You desire a built-in process that enables to be able to easily tracking check in addition to alter exactly where persons park your car in addition to have. Entrance functions achieve all this together with effective however convenient to use process agreed upon to guarantee the safety measures of your campus in addition to lots. A era your current campus lots auto parking structure sub-sections together with custom made place assignments, Car or truck Registration together with in decal allocation in addition to rebirth procedure, Auto parking Citations in addition to accounts receivable functions.

    ReplyDelete
  7. Thanks For sharing nice article about database development services.
    Database Development Services in India

    ReplyDelete

  8. I enjoying your post. You definitely have some great insight and great stories.


    Financial Advice Horsham


    find a financial advisor

    ReplyDelete
  9. This post still helped me!

    ReplyDelete
  10. but it says script cannot be executed.. because the connection is not there.
    what should i do? help needed asap

    ReplyDelete
  11. Beverly D. VillafaneJanuary 9, 2019 at 4:19 AM

    This problem is related to database corruption. Use the sp_who stored procedure to kill the processes that are active in the database. If it doesn’t solve your problem then try T-SQL commands in SSMS. Use below commands:

    USE master;
    GO
    ALTER DATABASE youdbname
    SET SINGLE_USER
    WITH ROLLBACK IMMEDIATE;
    GO

    In this situation, if T-SQL command doesn’t’ not work properly it means there is high corruption in SQL database file. So, to restore the corrupted database file I have go through below resources and analyze that Stellar repair for MS SQL is the best solution to fix database corruption issues.

    Visit here: https://www.geckoandfly.com/27550/repair-recover-corrupt-sql-database/

    ReplyDelete

  12. It seems you are so busy in last month. The detail you shared about your work and it is really impressive that's why i am waiting for your post because i get the new ideas over here and you really write so well.


    It seems you are so busy in last month. The detail you shared about your work and it is really impressive that's why i am waiting for your post because i get the new ideas over here and you really write so well.

    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training

    ReplyDelete
  13. Resources like the one you mentioned here will be very useful to me ! I will post a link to this page on my blog. I am sure my visitors will find that very useful
    python Online training in chennai
    python training institute in marathahalli
    python training institute in btm
    Python training course in Chennai

    ReplyDelete
  14. I have gone through your blog, it was very much useful for me and because of your blog, and also I gained many unknown information, the way you have clearly explained is really fantastic. Kindly post more like this, Thank You.
    apple service center chennai
    apple service center in chennai
    apple mobile service centre in chennai
    apple service center near me

    ReplyDelete
  15. Its help me to improve my knowledge and skills also.im really satisfied in this microsoft azure session.microsoft azure training in bangalore

    ReplyDelete
  16. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving.uipath training in bangalore

    ReplyDelete
  17. Really it was an awesome article,very interesting to read.You have provided an nice article,Thanks for sharing.blue prism training in bangalore

    ReplyDelete
  18. This is really an awesome post, thanks for it. Keep adding more information to this.openspan training in bangalore

    ReplyDelete
  19. Wow its a very good post. The information provided by you is really very good and helpful for me. Keep sharing good information.

    Become an Expert In DBA Training in Bangalore! The most trusted and trending Programming Language. Learn from experienced Trainers and get the knowledge to crack a coding interview, @Bangalore Training Academy Located in BTM Layout.

    ReplyDelete
  20. Very interesting, good job and thanks for sharing such a good blog.

    Best SAP S4 HANA Training in Bangalore for SAP, Real Time Experts Training Center provides the sap training project with trainers having more than 5 Years of sap training experience; We also provide 100% placement support.

    ReplyDelete
  21. Very correct statistics furnished, Thanks a lot for sharing such beneficial data.
    katmovies
    ............................................................

    ReplyDelete
  22. This comment has been removed by the author.

    ReplyDelete
  23. Snapdeal Winner List here came up with an Offer where you can win Snapdeal prize list 2020 by just playing a game & win prizes.
    Snapdeal winner name2020 also check the Snapdeal lucky draw2020

    ReplyDelete
  24. Thanks for sharing the great usefull blog
    Shopclues lucky draw 2020| Shopclues winner 2020|Get to Know Shopclues Lucky Draw Winner 2020. Call Shopclues Helpline Phone Number+91-9835565523 for Shopclues Online Shopping Lucky Draw.
    Shopclues online lucky draw winner
    Shopclues winner 2020
    shopclues car lucky draw

    ReplyDelete
  25. All the points you described so beautiful. Every time i read your i blog and i am so surprised that how you can write so well.
    devops training in chennai | devops training in anna nagar | devops training in omr | devops training in porur | devops training in tambaram | devops training in velachery

    ReplyDelete
  26. Good Post! , it was so good to read and useful to improve my knowledge as an updated one, keep blogging.After seeing your article I want to say that also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.

    aws training in pune

    ReplyDelete
  27. Database, Devops and software development great article very informative. Thanks for sharing, keep updating us with such articles.

    Data Science Training in Pune

    ReplyDelete