Detached NAS Mdf/ndf Files Locked And Won't Reattach
Oct 22, 2007
Hi
I have a database consisting of multiple files on a remote server.
Both servers have the same user (bob) which is in the administrator group.
The directory that the mdf/ndf files exist on is shared as "nas" with full rights given to the user bob.
They are both in the same workgroup.
SQL server is running as this user (not ideal I know but server and services will be locked down later)
The script I used to create the database uses the following line to enable remote database files:
-- Enable the use of network drive for DB files
DBCC TRACEON(1807)
GO
I used SSMS to detatch the database and then modified my create script by removing database sizes and adding "FOR ATTACH" at the end. (I have also tried using sp_attach_db but no use)
So the script looks like this:
CREATE DATABASE [dbname] ON PRIMARY
( NAME = N'DBName', FILENAME = N'\123.45.67.89
asDBName_FG.mdf' , MAXSIZE = UNLIMITED, FILEGROWTH = 10GB ),
-- Filegroups for the Alerts Table and Indexes.
FILEGROUP [FG_DBFile2]
( NAME = N'DBFile2_FG', FILENAME = N'\123.45.67.89
asDBFile2_FG.ndf' , MAXSIZE = UNLIMITED, FILEGROWTH = 5GB ),
FILEGROUP [FG_AlertsIndexes]
( NAME = N'DBFile3_FG', FILENAME = N'\123.45.67.89
asDBFile3_FG.ndf' , MAXSIZE = UNLIMITED, FILEGROWTH = 5GB )
LOG ON
( NAME = N'DBName_log', FILENAME = N'\123.45.67.89
asDBName_log.ldf' ,MAXSIZE = 13GB , FILEGROWTH = 0%)
FOR ATTACH
GO
When I run the script I get the following error:
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Msg 5120, Level 16, State 101, Line 5
Unable to open the physical file "\123.45.67.89
asDBName_FG.mdf". Operating system error 5: "5(error not found)".
I know the permissions are ok as I can map a drive without being prompted.
SQL server is running as the user bob which is the same user I log onto the server as.
I am running Windows 2003 Server R2 Standard Edition on server with SQL Server 2005 SP2.
The NAS box is running SQL Server R2 Storage Edition.
One thing I noticed was that the mdf/ndf files on the NAS box are locked as if SQL is still using them, i.e. I cannot rename them, move them, alter any properties etc. I just get "Access Denied".
I've tried rebooting both servers but still no luck. I've also tried stopping SQL server then renaming the files, but again "Access Denied".
I know there has been a problem in the past detaching and attaching db files on a NAS, but the Hotfix is included in SP2, which I am using.
I hope I have included enough info but if I've missed anything, it can be provided.
(Event Log basically replicates what the error message says.)
Any help or ideas would be greatly appreciated.
Thanks
Steve
View 2 Replies
ADVERTISEMENT
Nov 11, 2007
Hello all,
I'm using SQL 2005 Express edition. I'm currently connecting to the database file directrly (from ASP.NET) and that db file is not attached to the server.
My question is this:
What is the difference ? Will the performance improve if the db is attached and I connect to it throught the server ? I'm really not sure what the difference is.
Thanks
View 3 Replies
View Related
Oct 10, 2007
I have detached the database via sp_detach_db in a job, (I was trying to use a job to detach the database, then make copies of the mdf file, then attach the databases as different copies, somehow the job failed due to file locked) I tried to delete the physical files, but they were still locked. I tried several times, two of them I was able to delete the mdf files, but not the ldf file. The other one both mdf file and ldf file can not be deleted. I was not able to see the database via Management studio.
Can anyone help?
Thanks
View 3 Replies
View Related
Aug 19, 2015
I am using SQL 2012 SE. I am trying to move .mdf and .ndf files after a database is detached. Here is my code that is just to copy the mdf file. I am testing it against this file now and if it worked then I would do the move ldf file the same way.
EXEC master.dbo.sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
EXEC master.dbo.sp_configure 'xp_cmdshell', 1
RECONFIGURE WITH OVERRIDE
DECLARE @cmd nvarchar(4000)
[Code] ...
The only message is I see while the query is executing is :Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install.
If I manually copy over the file it takes 30 seconds since the file is only 2GB and the script takes 45 minutes and still executing.
View 7 Replies
View Related
Oct 10, 2006
I have a situation where I want to copy a SQLExpress mdf file, after having read some metadata from it, but I find that an exclusive lock persists on the file for about 5 minutes after closing... the lock is held by "sqlservr.exe" This lock prevents me from copying the file. It seems that I may be able to fix this by calling sp_detach_db after closing the connection (does this seem reasonable?) but I am unsure what the database name (dbname) is that I need to pass to sp_detach_db.
To make this a little more concrete, here is the connection string I use... "Data Source=.SQLEXPRESS;AttachDbFilename=C: estdataDVDCollectionDatabase.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True'" so in that case what would be the dbname?
Note that I need to do this through API (in a .NET application)
View 7 Replies
View Related
Mar 24, 2008
When I develop I sometimes forget and try to open the database file with the MS SQL Express Manager even though the web application I am devloping is still using it ... error lock occurrs and thats fine .... but what is the best way to unlock the files again? .... often I find myself having to restart the workstation because of this and thats sounds a bit like overdoing it .... there should be an easier way to unlock locked db files ...without having to restart the workstations.... is there ?
/Johan
View 3 Replies
View Related
Jul 20, 2005
Hello,A utility I was running caused our database's log file to run out ofhard drive.So, I detached the database, deleted the log file, and tried toreattach.SQL server fails to reattach because it cant find the log file. (Whyit cant just create a new default one is beyond me...but...)EXEC sp_attach_single_file_db @dbname = 'sgvault',@physname = 'c:Program FilesMicrosoft SQLServerMSSQLDatasgvault.mdf''Could not open new database 'sgvault'. CREATE DATABASE is aborted.Device activation error. The physical file name 'C:ProgramFilesMicrosoft SQL ServerMSSQLdatasgvault_log.LDF' may beincorrect.Do you know how I can fix this dilemma? Thanks!
View 2 Replies
View Related
May 18, 2001
Today we turned off SQL Server 7, copied the MDF file (a five-month, 245MB project) to the network, reformatted and installed Windows 2000 SBS with SQL Server 2000.
Lo and behold, SQL Server 2000 refuses to attach the MDF file, claiming it cannot find the accompanying LDF (no longer in existence). Using sp_attach_single_file_db did not help, nor did creating a database of the same name on the server, detaching it, and trying to swap the old MDF file for it.
Please help... if I have to get out a hex editor to get this database attached, I'm ready, but nothing I've tried works so far, and this is very important data--I can't believe the log file is THAT important, especially after committing anything left while shutting down the service.
View 1 Replies
View Related
Mar 5, 2008
I feel that I have done something stupid here.I used SSMSE to detach my database so that I could create a copy - no problem here.But then in SSMSE I right-clicked Databases, chose attach and expected to see my original database. But there are no databases shown in the attach window!I have tried to find the original database in SSMSE but nothing I do allows me to see it. However, Windows Explorer shows me that the files are still where they were when I detached them.Please help - this is driving me crazy.ThanksChris
View 2 Replies
View Related
Aug 22, 2007
After reboot, some db were detached, some not.
How come?
View 3 Replies
View Related
Mar 5, 2008
I feel that I have done something stupid here.
I used SSMSE to detach my database so that I could create a copy - no problem here.
But then in SSMSE I right-clicked Databases, chose attach and expected to see my original database. But there are no databases shown in the attach window!
I have tried to find the original database in SSMSE but nothing I do allows me to see it. However, Windows Explorer shows me that the files are still where they were when I detached them.
Please help - this is driving me crazy.
Thanks
Chris
View 1 Replies
View Related
Nov 1, 2006
Hello,
I currently have an application that uses a Access/JET database for a desktop application. The application is single-user and outside of a few corrupt MDBs occasionally, the setup is working fine.
I am thinking about switching out from using the Access database to using a SQL Server Express detached database. I'm not sure if this is a "proper" usage of a detached database, but I've verified that I can access and query a detached one...
Is this something that is recommended? Are there any performance issues associated with it (I believe the detached would be faster than the JET database.) What kind of maintainence would be needed for the SQL Server file? (I currently have a "Repair and Compact" option for the Access file...anything along those lines needed?) Is there anything else I should be aware of?
Thank in advance!
View 4 Replies
View Related
Mar 9, 2008
I had to detach a databse for a project. I am now having trouble trying to find this database. It is no longer listed in the Sql Server management studio with the other databases that haven't been detached.
Is the database moved to some other folder when it is detached? Where is this database now?
thanks
View 19 Replies
View Related
Oct 1, 2007
Dear All,
i've detached my database. how to attache thesame again?
Vinod
Even you learn 1%, Learn it with 100% confidence.
View 10 Replies
View Related
Nov 11, 2007
Hello all,
I'm using SQL 2005 Express edition. I'm currently connecting to the database file directrly (from ASP.NET) and that db file is not attached to the server.
My question is this:
What is the difference ? Will the performance improve if the db is attached and I connect to it throught the server ? I'm really not sure what the difference is.
Thanks
View 5 Replies
View Related
Oct 13, 2006
I want to manage my sql express .mdf database file (e.g. set Roles) but I seem to only be working with a temporary instance of my database when I attach to .sqlexpress and manage in SQL Server Management Studio Express (SSMSE). The Role I set is gone when I detach and re-attach.
If I try to manage my file in Visual Studio under Server Explorer, I do not see the "Roles" folder to modify roles.
Any help is appreciated.
View 3 Replies
View Related
Jul 25, 2006
I have a T-SQL script which deataches and attaches the database. Now here is what I want to do:
I
want to create a SQL Server Job and schedule it to run at a particular
time of the month to Detach all the databases on my local machine and
*Copy all the deatched databases over a network machine* and then
Attach those Database.
All this should be done in T-SQL. I
already have the T-SQLs for Attaching and Detaching. All I need is to
know the T-SQL (example) which will copy the *Detached Databases* from
mu local computer to my Network Computer. How do I achieve that?
Thanks
View 7 Replies
View Related
Nov 29, 2007
I ran into a problem today where I had to pull a backup file from an older tape. The file was originally is a backup that was stored in a device like :
EXEC sp_addumpdevice
'disk', --type
'c2000_BackupDevice', --logical name
'\UNCPathackupFile.bak' --physical location
I put the file from the tape on a File Server and then tried to create a new backup device pointing to the file. That's easy enough, but when I try to restore from it I get an device error saying it's offline.
How can I get that device attached to my server and then extract the backup files stored inside it?
Please advise b/c this is an interesting problem I hadn't anticipated and it argues that I should change my backup strategy .
Thanks for any advice/experience you can provide,
alex8675
View 2 Replies
View Related
Aug 21, 2007
Hi experts,
I have sql express installed on my machine and i'm using visual studio to create database files. After i've build a connection to my database file thru Server Explorer (choose Add attach files) i opened Management Studio Express and found that the new database has been attached to sqlexpress database engine----technically speaking it's under the user instance which i use to run my visual studio. right?? that's totally fine.My question is, after i'v closed the connection in visual studio, that attached database file still exist.I want it to be detached immediately after i've closed the connection in visual studio.How can i do that?
I've searched through internet and was told that sp_config can solve this problem by setting the user instance time out. I ran sp_config against my database but did not find that item. Could anybody give me some directions? thanks in advance.
View 2 Replies
View Related
Jun 6, 2006
Hello everybody,
I have an ASP.NET 2.0 website running on a windows server 2003 - sql express management studio installed. Today I had to make some changes in my database, add some columns, and so on...
So I put the app_offline.htm into the root of the web application, so the IIS unloaded the application domain, attached it in the sql management studio, made the changes I had to do and detached the db. Ok - then I removed the app_offline.html from the root of the application and looked at my internet explorer telling me that the user NT_network... cannot login...
What did I do wrong? I attached it, detached it, and at once something went wrong...
I tried everything, at least I copied the whole application to another directory and.... It worked fine again!
So, can anybody help me, I don`t know what I did wrong or rather how to make changes in my sql express for the future, not having trouble with any security issues...
regards
Simon
View 5 Replies
View Related
Apr 10, 2007
I am using the desktop sqlexpress 2005 and I was experimenting with the account setting and I accidentally disabled my access. I am using windows authentication and there is no password, just the windows login name.
How can I reactivate the login for this connection. Any help is greatly appreciated.
View 1 Replies
View Related
Apr 14, 2008
I am writing in regard to this post: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=52798
Which I found while searching for a best-practice way to implement record locking in my application.
In the above referenced post the user asks “How can I tell if a row is locked?�, and the reason for asking is that the user wants to implement logic similar to this:
Select a row for editing.
If the row has been locked by a different user, display the information as read only.
Otherwise, lock the row and allow the user to edit (allow others to read).
My questions are exactly the same as the original poster of the above thread. I was surprised to see that the general response to the post was the user was taking a wrong approach and that sql server is unable to work as the user requested. I think the approach is both correct and desirable (I used it extensively as a foxpro programmer) and I would like further confirmation that sql server does not support it.
One of the things I don’t understand is the interaction between transactions and locks. Is it not possible to lock a row without initiating a transaction? Bottom line, my goal is this:
Select a row for editing.
If the row has been locked by a different user, display the information as read only.
Otherwise, lock the row and allow the user to edit (allow others to read).
However I get there is fine with me.
View 12 Replies
View Related
May 12, 2008
Hi to all,
I need help about access to mdf file. I don't know when, but sometime my application, build with vbnet, return an error on mdf database access, that is access denied, also winxp return on the mdf file the message "process cannot access the file because it is being used by another process" if I try to delete the mdf file. I can delete the file only if I stop the procss sqlservr.exe from taskmanager. I don't use instruction to open and close database, I use dataset, datatable and sql build in datatable.
Someone can say me why sqlservr.exe don't unlock the mdf file when I close my application?
Thanks..
View 5 Replies
View Related
Jan 10, 2002
Hi,
When I am deleting records from a table, I am not able to select or insert records from the table. This particular table needs to be used by more users and very frequently used.
Could anyone please help with ideas.
Thanks in advance
John Jayaseelan
View 5 Replies
View Related
Feb 23, 2001
I am having an interesting problem that has got me completely baffled. I restored a database from the .bak file of another database on my server to use as a test DB for an App. upgrade before upgrading the live side. The problem I have run into is that the application will not allow login into the DB unless the Trusted Connection user has dbo privs. The DB is not set for dbo use only acoording to sp_dboption. It is not this way on the live side and tech support for the app. and I both think it has to strictly do with something in the SQL permissions. Any Ideas on what could have happened? Is the restored DB hanging onto something from the original DB that could be causing this? The connection works great on the live side on the older version, and I have seen it work in the newer version as well. Any takers?--Dallas
View 2 Replies
View Related
Jul 6, 2006
I have a problem that i can't log on sql server as the account is lock out. I don't know why it is locked out as this is the first time i log on. Anybody has this experience? Thank you very much!
View 4 Replies
View Related
Sep 6, 2006
I just brought SQL Server 2005 up on Windows Server 2003 a few days ago. Everything was going great up until a few minutes ago. I tried to connect using the Management Console and get the message
Login failed for user 'sa' because the account is currently locked out. Your administrator can unlock it.
It's the administrator that's locked out!
Do I have to reinstall SQL Server all over again?
View 2 Replies
View Related
Jun 19, 2008
My 'sa' account is locked out and the BUILTINAdministrators account does not have the sysadmin role. I removed the sysadmin role from BUILTINAdministrators for security reasons and before I could create a new account with the sysadmin role I fat fingered the sa password and locked it out. How can I get myself out of this mess.
Any help would be welcomed.
View 10 Replies
View Related
Dec 18, 2007
My mdf and ldf files were locked by windowsXP. Iam not using these files in anywhere of my two instances of databases.
Even after stopping SQL SERVER 2005 iam not able to cut or copy those files.
How to recover this files.
View 5 Replies
View Related
Jul 23, 2005
HelloI have a stand alone Java application that uses SQL Server 2000 on thesame machine. Sometimes, when we run the applications and follow acertain steps, the SQL server locks some of the table. At that point oftime, if we try to query Select * on those table, in Query Analyzer, itjust keep spinning and doesn't return anything. That tells me that thetables are locked. If I close the application then it frees up theconnection and those tables are accessible again.My question is how do I find out how and what query/update causes thetables to be locked. Is there a tool (some kind of a profiler) that cantell me what was the last insert/update/delete quesry was run before itgot locked?Please help me.
View 2 Replies
View Related
Aug 27, 2007
My sql server just dissalowed every connection attempt made. All the allowed users were denied permission, including the computer's admins. I changed the permissions and tryed everything I could think of but it wont let me back in. Can someone help ASAP?
View 1 Replies
View Related
Jul 7, 2006
Hi Champs,
Is there a way to recover from a account lockout in SQL2005?
I cannot connect to "Database Engine" in "SQL Server Management Studio",
error: login failed...18456. Access denied.
And I also cannot start the "SQL Server agent service"
Any possebility to recover without reinstall?
/Many thanks
View 3 Replies
View Related
Mar 20, 2006
I have been using SQL2000 for a number of years and the company I work for needs a new system so I decided to install SQL2005.
I installed SQL2005 without any problems and set a complex password for SA. I tried to log on and had to make several atempts as I remmebered the password after the SA account got locked out with the following message:
Login failed for user 'sa' because the account is currently locked out. The system administrator can unlock it. (Microsoft SQL Server, Error: 18486).
The problem I have is I cannot log onto SQL at all as it is not logging on with windows authentication either!
How do I unlock the SA account or do I have to reinstall SQL?
Thanks
Brian
View 28 Replies
View Related