Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
So i'm trying to copy a database I made in sql, but when I try to it doesnt allow me, it keeps saying that the file is already in use, when it isnt. Anyone know how I check to make sure its running?
Posted
Updated 24-Feb-21 23:47pm

As you want to copy a Database so you know where to find it and name and type of the server.
ok to do that first of all you have to detach the database from the SQL server
there are two ways to do that
1. Open the Managament studio for SQL and then connect to the specified Server.open the database node and right click on the database choose Task->Detach. now you can copy the database.but after this you have again attach to the database.
2. go to Start Menu -> SQL Server -> Configuration Tools ->SQL Server Configuration Manager. This will open a new window for you. right click on SQLSERVER(SQLEXPRESS or the Name Of The Server) And Select Stop. New You can copy the Database. After Copying Again Right Click On The SQLSERVER(Name Of The Server) And Start The Service.
if this will not help you with the problem let me know.
Best Regards.
 
Share this answer
 
v3
Comments
programmer1234 8-May-11 14:15pm    
Yes the second option worked, thanks.
Tarun.K.S 8-May-11 14:35pm    
Vote for the answer too.
Tarun.K.S 8-May-11 14:36pm    
5 for excellent solution.
skantg 9-May-11 4:53am    
My five for to the point solution.
lilian87 25-Dec-11 11:29am    
5++.. thanks for the solution.. :)
Are you absolutely sure that nothing is currently connected to your database? I had this problem but it turned out that a Windows Service was using it unbeknownst to me.

Use this query for a list of connections to databases

SELECT DB_NAME(dbid) as database_name, nt_domain, nt_username, hostprocess
FROM sys.sysprocesses
WHERE dbid > 0


The hostprocess field is the Windows Process ID which you can then look up in the Task Manager.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900