File Will Not Attach To SQL Reason File Is Not Primary File
May 10, 2007
I have a customer they are running raid 5 on a windows 2000 server one of the drives went bad. The customer replaced the drive and raid rebuilt the drive, every thing seamed to be fine but there is one database file that cannot be attached to SQL. The file is 15G so I know there is information the error states that the file is not a Primary file. Any clue on how to fix this?
Greetings, I have just arrived back into the country (NZ) and back into ASP.NET. I am having trouble with the following:An attempt to attach an auto-named database for file (file location).../Database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. It has only begun since i decided i wanted to use IIS, I realise VWD comes with its own localhost, but since it is only temporary, i wanted a permanent shortcut on my desktop to link to my intranet page. Anyone have any ideas why i am getting the above error? have searched many places on the internet and not getting any closer. Cheers ~ J
I have used the copy database wizard, but I realized I had forgotten to shrink the transaction log file. So I canceled the wizard. My database, detached by the wizard, has now disappeared. The mdf file is still there, but when I try to attach it manually I get the "create file encountered operating system error 5 while attempting to open the physical file..." error.
Why shrinkfile empty file does not redistribute data evenly in the primary file group with multiple files:
Please run the script attached to see what the end result is.
This is what I set up last night on my test machine.
1) Create database [FGTest] size 200MB 2) Create table called TEST on primary 3) Insert 40MB of data into test 4) Create another file group called temp in primary size 200MB 5) Shrinkfile('FGTest',emptyfile) so that all data is transfered from FGTest into temp file group. 6) Add another 2 files called DATA2 and DATA3. Both are 200MB. 7) We now have 3 empty files that I want data distributed evenly on. FGTest, DATA2 & DATA3 8) Shrinkfile('temp',emptyfile) to move all the data from temp over the 3 file groups evenly
I would expect at this stage to have the following:
FGTest = 13MB, DATA2 = 13MB, DATA3 = 13MB
(40MB of data over 3 files should be about 13 MBish in each file)
What I actually end up with is this:
FGTest = 20MB DATA1 = 10MB DATA2 = 10MB
It looks as though SQL Server is allocating 50% of all data to the original file and then 50% evenly over the remaining files in PRIMARY.
I built an app, works fine. Had the development environment working fine (VS2005 (SP0) and SQL Server Express). It had been stable for months, no problem.
Then I had to reinstall XP Pro...(finally threw too many conflicting programs into it, I guess...)
I managed to get VS2005 reinstalled ok. However, when I opened and compiled my existing app in VS2005, using Cassini, I got the dreaded error:
An attempt to attach an auto-named database for file <file string> failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
I also get this error for the compiled copy of the app on the same machine, running on IIS. (Where it also previously worked fine).
I appreciate that there are zillions of posts on this issue. I'm hoping that someone might know why this should happen in this particular case.
The thing that's different about this case is that the app was working fine; I have the app deployed on a demo machine and also on a remote server as well as on the development machine.
The only thing that changed is that there was this fresh install of SQL Server Express.
I tried using >> sp_configure user instances enabled','1';RECONFIGURE <<< in SSMSEE, which took, but didn't help.
So something is different in SSE. Since the app is stable everywhere else, I REALLY don't want to go through and adjust the connection strings...MUCH better to figure out what SSE needs to be happy with the existing connection strings...as it was before.
Any suggestions would be appreciated.
Thanks!
EDIT----TRIED SOME THINGS:
Changed folder and file permissions to allow ASPNET full access to the .mdf's and log files (though never had to do this before on the development machine.) No change...
Can see the table contents within the .mdf through SSMSE, and also through Server Explorer in VS2005.
So because the problem happens with both IIS and Cassini, I'm assuming it's got to be an issue between ASPNET and SSE.
EDIT --- TRIED SOME MORE THINGS:
I dimly remember that when I had this problem before, it was that the error message was too "dumb". It wasn't my file that had the permissions problems, it was that the SSE System Databases had to have permissions with respect to ASPNET.
I tried to set that up but I'm a complete newb on this area, so I don't know if I did it right. In SSMSE I created a Login for MyComputer/ASPNET, and gave it all permissions and roles, and then made it an owner for the four system databases...but no joy.
Any pointers on this last piece would be helpful.
EDIT - MORE INFO
The error details
[SqlException (0x80131904): An attempt to attach an auto-named database for file <filestring>.MDF failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +739123 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1956 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +170 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +349 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181
I know allot of folks are having this problem and I tried lots of things but nothing works. I understand the problem is coping the SQL Express on another server is the problem - I just not sure what to do?
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
This is the last statement on the Stack Trace:
SqlException (0x80131904): An attempt to attach an auto-named database for file e:wwwdata81d0493fwwwApp_DataTestDatabase.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +735091
I checked my server forum and they said I had to name a database: Example: Database=(unique name);
But this didn't work either.
I just tried a simple web project that has only one database and one table in SQL Express with one sqldatasource and one datagrid. It works fine on my pc but when I use the copy function in Visio Studio 2005 Pro - I can't run the site on the remote server: www.myjewelrydirect.com
I tried coping the database manually. I tried disconnecting the database before I copy it. Below is my connection statement:
At one of our SQL2005 servers we've got a really strange problem. The transaction logfile of one of our databases is suddenly disappearing without a reason. From that moment on the event log (application) is being filled up with SQLserver event 9001
Event Type: Error Event Source: MSSQL$SQLEXPRESS Event Category: (2) Event ID: 9001 Date: 16/04/2007 Time: 12:31:40 User: N/A Computer: PBVSRV Description: The log for database 'Putboringen' is not available. Check the event log for related error messages. Resolve any errors and restart the database.
Currently have a single hard coded file path to the SSRS config file which parses the file and provides the reporting services web service url. My question is how would i run this same query against 100s of servers that may or may not share the same file path as the one hard coded ?
Is there a way to query the registry to find the location of the config file of any server ? which could be on D, E, F, H, etc.
I know I can string together the address followed by "reports" and named instance if needed, but some instances may not have used the default virtual directory name (Reports).
Am I going about this the hard way ? Is there a location where the web service url exists in a table ? I could not locate anything in the Reporting service database. Basically need to inventory all of my reporting services url's.
I have MS SQL server database with two files 1- x_data.mdf, 2- x_log.ldf The database become suspect and i have no space problem. now the problem is that the log file become corrupted because when i stop the database service I tray to copy the log file into another place but I can't Now the result is that I have one data file x_data.mdf and how can I solve the problem and the question is how can I back the data again when I have a data file without a log file Thanks
I'm in a BIG BIG trouble... A co-worker tried to help me out with the huge database huge log file. So he first detach my db, and deleted the log.ldf file... now, i tried to attach it back....ERROR... could someone help me out ... please..
I have "SQL Server Express" as well as SSMS-E installed on the same machine. I am trying to get SSMS-E to connect to a database (i.e., an .MDF file) that resides in a folder on the desktop.
After establishing a connection to my "SQL Server Express" instance within SSMS-E, I right-click on "Databases", in the "Object Explorer" window and select "Attach..." and click the "Add..." button. The resulting dialog box opens in the directory: "C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLData" where I see several MDF files. But as I said, my MDF is not in this directory - it's on the desktop.
If I try to navigate to the proper directory on the desktop I see no MDF files. In fact, I cannot even navigate past my username -- that is, I cannot even navigate to the desktop, let alone folders on the desktop. I don't know why.
Of course I *could* put the MDF file in the SQL-E approved directory but shouldn't I just be able to navigate to it using SSMS-E? Incidentally, I *AM* able to connect to the database on my desktop if I use Visual Studio and I specify "UserInstance=true". Not specifying "UserInstance=true" results in this error:
An attempt to attach an auto-named database for file C:Documents and SettingsRobinDesktopMyCompany.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Can someone explain what might be causing the problem with SSMS-E, and, for that matter, why it's necessary to specify "UserInstance=true" in Visual Studio?
Thanks so much. I hope these are not too many questions.
I have Sql Server in one pc and I want to attach one databse that is in another computer that doesnt have SQL Server. Sql Server doesnt permit UNC path when attaching database files. Is there anyway to workarounf this. Is Trace Flag 1807 of any use?
I am very inexperienced with the Administration side of SQL Server 2005.
I have been given a .bak file which I need to restore onto my SQL Server. The database .bak file was created on another PC and I cannot seem to restore/recover the .bak file onto my SQL Server.
I got a mdf file from my co-workerwho just stopped SQL server and delete ldf fileand give me a mdf file.if it was detached, it would work finebut it was just copied.Is there any way to attach this mdf file?I tried sp_attach_db and sp_attach_single_file_dband both failed.thanks,
We have a DB on sql server 2000 64 bit and the build is 2187.
The database consisted of two transaction log files and several data files at the time we took backup. However, the backup taken was a cold backup (backup of files through OS). In this backupset, one transaction log file was skipped due to some error...... Now I want to restore the database for referring to some history data. Will I be able to attach the database with all MDF and one of the transaction log files.??
I heard this kind of recovery is not possible. If anybody can post some solution , I would be grateful...!!
Dear All... I want my database file to be attached to remote server database when i published my site Notes : Remote Server Database:SqlServer2000 .net Version:1.1
hello all.I have a database file in sqlserver 2005 mode, i set it's compatiblity to sqlserver 2000 (80) but i cant attach it in sqlserver 2000.My host only support sqlserver 2000!I need any help to convert or attach it!Thank all!
I was having problems on myt PC so i did a fresh installation. However I had backed up my SQL database (I only have the MDF file and not the log file).
I have tried restoring and attaching options but nothing works :(
I also get the error saying
"Can not open backup device.... Device error or device off-line. See the SQL server error log for more details. RESTORE database is terminating abnormally".
Please this is urgent. WIll be VERY grateful for your urgent reply.
I was having problems on myt PC so i did a fresh installation. However I had backed up my SQL database (I only have the MDF file and not the log file).
I have tried restoring and attaching options but nothing works :(
I also get the error saying
"Can not open backup device.... Device error or device off-line. See the SQL server error log for more details. RESTORE database is terminating abnormally".
Please this is really urgent. Will be VERY grateful for your urgent reply.
Dim strComputer Dim objRegistry Dim strKeyPath Dim strValueName Dim strValue Dim arrValues Dim intValue Dim strpath Dim strpath2 Dim strDBServerName Dim objSQLServer
strComputer = "."
Set objRegistry = GetObject("winmgmts:\" & strComputer & " ootdefault: StdRegProv")
In Access 97, I am trying to attach to a table in my SQL Server 2000db.I use File/Get Data, which displays all the SQL tables including theone I can't attach to. (I can attach to all the other SQL tables.)But, when I select that table I get a message that tells me the nameis invalid. I don't understand this because it gives me the name inthe Get Data dialog, and I don't have to enter it manually.Any ideas?Thanks,Bob C.
I build a WebApp which i use the default DataBase that come with the App_Data folder. I have Users and roles into that folder with all my tables regarding my new App. Why i cant make it work under IIS on my webserver ? When i open it with Visual Studio everything works but outside of it nothing. An attempt to attach an auto-named database for file c:inetpubwwwrootSurveyApp_Dataaspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. Data Source=.SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf; I look arround and cant find a thing on how to fix my issue. I try deleting the Folder under my User Account for SQL Express and nothing happend.
I've read through all the posts in this fourm that are related to the problem I'm getting with this error message on my main form, but none of the fixes seen to solve the problem. So I hope someone can get me pointed in the right direction.
I'm running visual studio 2005 professional, and SQL Server 2005 Express Edition and this is a desktop application. I added the db file to the solution with the Add New Data Source wizard, I can create the datasets and preview the data correctly.
An attempt to attach an auto-named database for file C:Program FilesMicrosoft Visual Studio 8Common7IDEdbInventory.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
When I run the program the exception is throw in the Settings.Designer.vb code, Public ReadOnly Property for the connection string. The InnerException is this...
{"An error occurred loading a configuration file: Could not find a part of the path 'C:Documents and Settings<UserName><ApplicationName>.vshos_StrongName_1sdf1e34hkn1hqmkn2bgjjwstusfj2sg1.0.0.0user.config'. (C:Documents and Settings<UserName>Application Data...<ApplicationName>.vshos_StrongName_1sdf1e34hkn1hqmkn2bgjjwstusfj2sg1.0.0.0user.config)"}
This folder doesn't exist anywhere on the system, any ideas....
Hi,I recently installed VS Web Developer Express Ediition and SQL Server Express and I'm doing the How To tutorials and I can't finish the basic data access walkthrough:http://msdn2.microsoft.com/en-US/library/tw738475.aspxBecause I get an error like this (link for complete error below): An attempt to attach an auto-named database for file C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLData est.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLData est.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.Source Error:An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.http://pastecode.com/6196When I am setting up the data source for the gridview tool, everything works fine and the test query works fine, but then when I try to actually test the output in the browser with Cntrl+F5 I get this error. I have been trying for 48 hours to find a solution on my own. I have googled, I have searched everything and I just am at a point where I think I need to ask someone for help. Please help.
having exhaustively searched the forum and tried everything over the pas few days im still recieving :Error Caught in Application_Error eventError in: http://mysite.com/site1/index.aspxError Message: An attempt to attach an auto-named database for file E:Inetpubwwwrootmvate.comWapCmsApp_Dataaspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.Stack Trace: at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) at System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) at System.Web.Profile.SqlProfileProvider.GetPropertyValuesFromDatabase(String userName, SettingsPropertyValueCollection svc) at System.Web.Profile.SqlProfileProvider.GetPropertyValues(SettingsContext sc, SettingsPropertyCollection properties) at System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider) at System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName) at System.Configuration.SettingsBase.get_Item(String propertyName) at System.Web.Profile.ProfileBase.GetInternal(String propertyName) at System.Web.Profile.ProfileBase.get_Item(String propertyName) at System.Web.Profile.ProfileGroupBase.GetPropertyValue(String propertyName) at ProfileGroupUser.get_ClientID() at InfoPage.Page_PreInit(Object sender, EventArgs e) at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Page.OnPreInit(EventArgs e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)help and suggestions appreciated
Hi I have a problem when I want to open a page with the database record. This page is created in Visual Web Developer 2005 Express. When I try to open a page I get the following error message even though the connection between the database is ok: An attempt to attach an auto-named database for file C:InetpubwwwrootmembershipApp_Dataaspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file C:InetpubwwwrootmembershipApp_Dataaspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. I have a computer with Windows XP Professional running IIS 5.1 and ASP.NET 2.0. Also I have SQL Express on my machine. Does any one know how to resolve it.Thanks
I've just created my first projects using Visual Studio 2005 and SQL 2005 Express. This is the basic;
One windows service is created that updates a database. The windows service running under "Local system" account One windows application where a user can see data (and change) from the database A common business and dataaccess layer/project is used by both applications Connection string to the database: "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|DataDatabase.mdf;Integrated Security=True;Connect Timeout=60;User Instance=True"
Both application is located in the same directory. When the computer starts the windows service starts and works perfectly. But when a user starts the windows applications the following error is reported "An attempt to attach an auto-named database for file..A database with the same name exists, or specified file cannot be opened, or it is located on UNC share".
It look likes that only one of my application can connect to the database at a time!
Is it possible to use separate applications to connect to the same database file?