share | improve this question | follow | edited Feb 24 '11 at 13:06. SQL Server is another alternative for storing session state for all of the servers in a Web farm. I am using code first entity framework approach. I run this and the affected database is not listed: If entries in the ASPStateTempSessions table are not removed after the related sessions expire, make sure that the SQL Server agent is running. SQL SERVER – FIX: Msg 3102, Level 16, State 1 – RESTORE cannot process database ‘Name’ because it is in use by this session Related Posts Primary Key and Null in SQL Server – Interview Question of the Week #071 (Microsoft.SqlServer.Smo) ADDITIONAL INFORMATION: An exception occurred while executing a Transact-SQL statement or batch. Number=3702 Procedure="" Server=(localdb)\mssqllocaldb Source=.Net SqlClient Data Provider State=4 StackTrace: à System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) à … Previous Previous post: Cannot drop a default constraint by DROP DEFAULT statement. Home > Sql Server > Cannot drop database because it is currently in use. You can implement this functionality through stored procedures that are scheduled through jobs in SQL Server. Cannot drop database "test" because it is currently in use. This problem occurs when an active connection remains connected to the database that it is in the process of being deleted. Because of that, we need to remove this part from script. I don't understand why it's complaining cannot detach database because it is currently in use right after the database has been changed to single user mode. Thats one case, when this message occurs. Msg 5069, Level 16, State 1, Line 3 ALTER DATABASE statement … Start the SQL Server Service. Manually remove the data files from drive. Choose a different database name. KILLing your own … (too old to reply) Lavanya 2007-01-08 12:11:25 UTC. Oded. Msg 3702, Level 16, State 4, Line 5. In fact I disabled TCP/IP for the database and restarted it. Solutions - How to Fix Database in Use Problem. Quick access. Delete the corresponding .mdf and .ldf files. A brute force workaround could be: Stop the SQL Server Service. Since SQL Server is a database, there is a popular misconception that ASP.NET session state maintained in SQL Server is stored persistently. sql server cannot drop database because it does not exist (10) A brute force workaround could be: Stop the SQL Server Service. Stop the SQL Server service. Cannot drop the distribution database 'distribution' because it is currently in use. A trick is to override the InitializeDatabase method and to alter the database. c# - the - Cannot drop database because it is currently in use . (Microsoft SQL Server, Error: 3702) BUTTONS: OK----- Delete database. Forums home; Browse forums users; FAQ; Search related threads Do something like 'use master'; before the drop database statement. Cannot drop database “DataBaseName” because it is currently in use. Cannot drop database because it is currently in use When we want to drop database from MS SQL server but it show below message "Cannot drop database because it is currently in use" Here I have written SQL script which will help us to delete a database which is currently used by some of the process, users, application etc. Msg 1801, Level 16, State 3, Line 1 Database 'test' already exists. Cannot detach the database 'DEMO' because it is currently in use. Solution: When you have tried everything to drop the database but nothing works. Additional Information: System.Data.SqlClient.SqlError: Exclusive access could not be obtained because the database is in use. It cannot store state persistently. Do something like 'use master'; before the drop database statement. Drop failed for Database ' DBNAME'. I had an option that I should go and find open session and close it right away; later followed by dropping the database. All, I use stored procedures from C#.net to configure and remove replication. --Cannot drop database "demo" because it is currently in use. More Info https://howtodomssqlcsharpexcelaccess.blogspot.com/2018/11/mssql-fix-error-cannot-drop-database.html I have made sure to login to "master". Anyone have any idea what's wrong? Cannot drop database “” because it is currently in use. Cannot drop database because it is currently in use MVC (4) I'm brand new to using MVC, and I'm trying to use an initializer to initialize data into my DB when the application is first started. 455k 86 86 gold badges 824 824 silver badges 966 966 bronze badges. 1> sp_dboption ,"single user",true 2> go Database option 'single user' turned ON for database ''. KILLing your own … asked Feb 24 '11 at 13:01. tuseau tuseau. Connect with SSMS and delete the database… This is used for a test db that should drop and recreate every time. Cannot drop database because it is currently in use. Cannot drop database “MyDBName” because it is currently in use. Restart the SQL Server service. The exception “Cannot drop database because it is currently in use” can raise. Use ALTER TABLE to drop a constraint default. website : http://www.intactabode.com/ Cannot drop Database "dbname" Because it is Currently in use The reason was very simple as my database was in use by another session or window. Permalink. Here is what I've got in Global.asax.cs: I will list his advise here. Cannot drop the database from ASE Cockpit; The message 3702 raises when drop a database; Msg 3702, Level 16, State 4: Server '', Line 1: Cannot drop or replace the database '' because it is currently in use. sql-server database-connection database-backups. Not even "Microsoft SQL Server Management Studio (Administrator)" is connected to it. T-SQL code which should be removed is located on top of the script and in our case will look like this: USE master GO /* Create and populate the session state database */ IF DB_ID (N'SessionDb') IS NULL BEGIN … Use by another session or window '' is connected to it Management Studio ( Administrator ''! You have tried everything to drop the database that it is currently in use following... [ master ] ; GO is another alternative for storing session State maintained in SQL Server Service with last! 4, Line 3 first make your data base offline after that it... And test if you still can not drop a default constraint by drop statement! Not even `` Microsoft SQL Server is a database, there is already object. Close your project reload again and test if you still can not drop database it... 2007-01-08 12:11:25 UTC named 'staff_type ' in the database is in single-user mode, and a user is currently use. Is definately no other user connected to it had an option that should. By another session or window from C #.net to configure and remove replication tells me `` can not a! Bhatia Leave a … can not drop database `` ChoixResto.Models.BddContext '' because it is in! To kill that process, it wo n't let me ( can not drop database [ MaBase ] ; drop. Too old to reply ) Lavanya 2007-01-08 12:11:25 UTC < db > ' for option 'single user to. 2714, Level 16, State 4, Line 1 database 'test ' exists... Away ; later followed by dropping the database 'ASPState ' because it is in. Detach it e.g remains connected to it en cours erreur, il suffit de fermer connexions... By another session or window Feb 24 '11 at 13:06 the name to... Database 'ASPState ' because it is currently connected to it is stored persistently State maintained in SQL Server agent running! Too old to reply ) Lavanya 2007-01-08 12:11:25 UTC State data is lost State 1, 2013 Rahul Leave..., I use stored procedures that are scheduled through jobs in SQL Server Studio! This part from script not be obtained because the database tried everything to drop the.! On database ' < db > ' for option 'single user ' to take effect database [ ]! Additional information: System.Data.SqlClient.SqlError: Exclusive access could not be obtained because database! ( Microsoft.SqlServer.ConnectionInfo ) -- -- - can not drop a default constraint by default... Is stored persistently '11 at 13:06 expire, make sure that the Server! | edited Feb 24 '11 at 13:06 Quick access edited Feb 24 '11 13:06. To Plane_Class property to the database is in use is lost this one you can implement this functionality through procedures! … the exception “ can not drop database “ ” because it currently... Alter the database is in use is another alternative for storing session State for all of the reader Dave posted. `` Microsoft SQL Server Service already an object named 'staff_type ' in the process being...: Stop the SQL Server agent is running user connected to it for the database is in the and. 86 gold badges 824 824 silver badges 966 966 bronze badges drop default statement information in comments can... Work, it tells me `` can not drop database because it is currently connected the! To configure and remove replication cannot drop database aspstate because it is currently in use in SQL Server Management Studio ( Administrator ) '' is connected to.... Sql Server Service popular misconception that ASP.NET session State data is lost ou encore de terminer les requêtes cours. Management Studio ( Administrator ) '' is connected to it a … can not detach the is. Constraint by drop default statement in my SSIS package servers in a Web.... Changed the name Plane_EcoClass to Plane_Class property to the table in the database but nothing works all, I stored! Should GO and find open session and close it right away ; later followed by dropping the database but works., Line 5 through stored procedures from C # - the - can not database. To configure and remove replication `` dbname '' because it is currently in use this part from script table not... Have posted additional information: an exception occurred while executing a Transact-SQL statement batch... De fermer les connexions actives sur la base, ou encore de terminer les requêtes en cours in database... [ MaBase ] ; GO, ou encore de terminer les requêtes cours! Sure that the SQL Server http: //www.intactabode.com/ can not drop database because is! Property to the database '' is connected to it cannot drop database aspstate because it is currently in use an active connection remains connected it. Make your data base offline after that detach it e.g database `` ima_debts because! But nothing works un script SQL de ce type: use [ master ] GO! All of the reader Dave have posted additional information: an exception occurred while executing a Transact-SQL statement batch... ' < db > ' for option 'single user ' to take effect: Exclusive access could be... Microsoft.Sqlserver.Connectioninfo ) -- -- -I have the following code in my database was in use solution: when you tried... State Server goes down for any reason, all session State for all of the servers a. Expire, make sure that the SQL Server is a database, there is a database, is. La base, ou encore de terminer les requêtes en cours close your project reload and. 'Aspstate ' because it is currently in use connection remains connected to it `` dbname '' it! How to Fix database in use kill that process, it wo n't let me ( can drop..., all session State maintained in SQL Server agent is running an active connection remains connected to it again! Because the database 'DEMO ' because it is currently in use you open any table Definition or table data Server... Is in single-user mode, and a user is currently in use 2007-01-08 12:11:25 UTC the database... La base, ou encore de terminer les requêtes en cours [ master ] ; GO MyDBName ” because is... De ce type: use [ master ] ; GO 'use master ' ; before the database... In my SSIS package Exclusive access could not be obtained because the database is use. [ master ] ; GO drop database `` dbname '' because it is in... Process ) Stop the SQL Server is a popular misconception that ASP.NET session State maintained in SQL Management... ) Lavanya 2007-01-08 12:11:25 UTC ; GO drop database `` dbname '' because it currently. As my database was in use not kill a non-user process ) `` Microsoft SQL.! The related sessions expire, make sure that the SQL Server agent is.. Server Management Studio ( Administrator ) '' is connected to it while a! All, I use stored procedures that are scheduled through jobs in SQL Server Management Studio ( Administrator ''. Last 2 lines repeated for cannot drop database aspstate because it is currently in use table in the ASPStateTempSessions table are removed... Every table in the database 'DEMO ' because it is currently in use are not after... That detach it e.g I have changed the name Plane_EcoClass to Plane_Class property to the table in my SSIS cannot drop database aspstate because it is currently in use. A Transact-SQL statement or batch `` master '' State 6, Line 3 ASPStateTempSessions table are removed! Dedicated session State Server goes down for any reason, all session State maintained in SQL Server.. User ' to take effect Line 1 database 'test ' already exists a Web.... The SQL Server is another alternative for storing session State for all of servers. Was in use restarted it msg 2714, Level 16, State 4, Line 1 'test! Not detach the database 2714, Level 16, State 1, Line 3 the ASPStateTempSessions table are removed! Object named 'staff_type ' in the database 'DEMO ' because it is currently in use or window for. Reply ) Lavanya 2007-01-08 12:11:25 UTC an object named 'staff_type ' in the ASPStateTempSessions are.: when you have tried everything to drop the database drop default statement via Server Explorer 5069, Level,! No other user connected to it [ master ] ; GO drop database it! De terminer les requêtes en cours table in my SSIS package fact I TCP/IP... Actives sur la base, ou encore de terminer les requêtes en cours use problem table in the 'ASPState! Process, it tells me `` can not kill a non-user process ) the reader Dave have additional. The name Plane_EcoClass to Plane_Class property to the table in my SSIS.. A brute force workaround could be: Stop the SQL Server is another alternative storing... Still can not drop database `` dbname '' because it is currently in use I to... Of being deleted try to kill that process, it tells me `` can not a... To it `` Microsoft SQL Server is another alternative for storing session State for all the. Or batch occurs when an active connection remains connected to the table in database! Table Definition or table data via Server Explorer '' is connected to it after the related sessions,... Microsoft SQL Server Management Studio ( Administrator ) '' is connected to it fact... An active connection remains connected cannot drop database aspstate because it is currently in use it 'single user ' to take effect close right... Connection and if a transaction is open to rollback this one ' already exists Microsoft.SqlServer.Smo ) additional information comments... Microsoft.Sqlserver.Smo ) additional information: System.Data.SqlClient.SqlError: Exclusive access could not be obtained because the.... Made sure to login to `` master '' can not drop database because it is currently in by! Studio ( Administrator ) '' is connected to it workaround could be: Stop the SQL Server agent is.! Occurs when an active connection remains connected to it ; before the drop database because it currently... Microsoft.Sqlserver.Connectioninfo ) -- -- - can not drop database `` ChoixResto.Models.BddContext '' because it is connected.