Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 create database

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2009-01-05 : 03:04:37
Hi,
When trying to create a database, I get an error which says the file myDatabase.mdf can not be created.
When I look further into the folders, I see there is the .mdf already in the prgram files folder where the database is trying to be created.
Question:
I believe the way around this is;
How can I create a database with the same name so that it point to the existing .mdf ?
Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-05 : 03:17:33
You can attach the existing mdf file...



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2009-01-05 : 03:31:26
Hi,
It seems the error is to do with the fact that I have 64 bit OS and the .mdf is 32bit
The error is:
create file encouontered operating system error 32(error not found) while attempting to open the physical file 'c:\program files\mydatabase.mdf' (Error 5123)

Do I need to convert the existing 32bit .mdf to 64 bit?
Thanks
Go to Top of Page

svicky9
Posting Yak Master

232 Posts

Posted - 2009-01-05 : 08:26:45
May be the Database filepath is wrong..Please check the entire Database file path

Vic

http://vicdba.blogspot.com
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2009-01-05 : 08:36:45
It is correct.
I point the attached database to the location where the .mdf is
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-05 : 09:33:48
Are you trying to attach or ?? Explain all steps what you have done.
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2009-01-05 : 09:45:15
I believe the first post does indeed explain what I have done so far.
I have tried attach and restore. None seem to allow me to create the database.
Thanks
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-05 : 09:48:19
quote:
Originally posted by arkiboys

I believe the first post does indeed explain what I have done so far.
I have tried attach and restore. None seem to allow me to create the database.
Thanks



It doesn't explain about what you are trying to do. Also you don't restore mdf file ,you just attach it. You attach database not create database.
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2009-01-05 : 10:04:09
Hi,
I am trying to create a database called mydatabase.
When doing this in sql 2005 by right click, new database; this is the error I get:
create database failed. some file names listed could not be created. Check related errors. Can not create file 'c:\program files\...\mydatabase.mdf' because it already exists. change the filepath or the file name, and retry the operation.
Note that there is a .mdf file in the above path already and I would

like to use that as the database.
So I try to attached this .mdf file, and I get this error when attaching it:
create file encouontered operating system error 32(error not found) while attempting to open the physical file 'c:\program files\mydatabase.mdf' (Error 5123)

Thanks
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-05 : 10:11:17
The database already exists and mdf file is in use. Use different name if you are creating new database. Also if I am understanding correctly,why need to duplicate your database?
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2009-01-05 : 10:14:42
Yes, the database does exist but I would like to view the objects in object explorer and that is why I am trying to create the same name.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-05 : 10:23:17
Huh!! Can't you expand your database and see objects in object explorer?
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2009-01-05 : 16:55:07
Not the database I would like to create.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-05 : 17:05:47
I am thoroughly confused as to what your issue. So the mdf exists, which means you can NOT create a new database and use that same file name. The only thing you can do is try to attach it, but I see you've already done that and are getting an error. Do you have any valid backups of the database that you can restore?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2009-01-06 : 02:48:55
This is a sample database.
I have an application that I can use which points to it and does indeed populate the database and the application can read from that database.
BUT, I can not view the database in object explorer since I can not create it.
Thanks
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-06 : 12:02:24
Run sp_databases and check if you can see that database in the list. Otherwise Post the full command you use while Attaching database for MDF file.
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2009-01-07 : 02:51:54
No, I do not see that database when running sp_databases.
I do not run a command to attach the database.
As mentioned before, I use the object explorer to right click on databases and attach...
Thank you
Go to Top of Page
   

- Advertisement -