How to attach a database? (1 Viewer)

deletedT

Guest
Local time
Today, 05:13
Joined
Feb 2, 2019
Messages
1,218
I'm trying to attach a database in SQL Server Management, but I'm receiving this error.

2020-04-21_0-21-57.jpg


I right clicked Databases and select Attach from menu. As soon as I select the mdf file I receive this error.
Any kind of help is much appreciated.

Edit: The sentence in Japanese means : Access is denied.
 

AccessBlaster

Registered User.
Local time
Yesterday, 22:13
Joined
May 22, 2010
Messages
5,828
Hi Tera,

I suspect you do not have creation rights. You might have an existing DB that you can edit, but you might not be able to create a NEW one. Hope this makes sense.
 

deletedT

Guest
Local time
Today, 05:13
Joined
Feb 2, 2019
Messages
1,218
Hi Tera,

I suspect you do not have creation rights. You might have an existing DB that you can edit, but you might not be able to create a NEW one. Hope this makes sense.
I have full rights over the server. Just tried and was able to add new databases.

Thanks
 

deletedT

Guest
Local time
Today, 05:13
Joined
Feb 2, 2019
Messages
1,218
Thanks for thinking loud.
Since the database is not attached , it's not listed in Databases. Should I create a new Database and import from backup?

Thanks
 

AccessBlaster

Registered User.
Local time
Yesterday, 22:13
Joined
May 22, 2010
Messages
5,828
Sorry I am not an expert and hopefully someone will chimes in. But I have gone this route back in the day.

1587398489985.png
 

deletedT

Guest
Local time
Today, 05:13
Joined
Feb 2, 2019
Messages
1,218
Thanks. Will try to see what happens.
Meanwhile I posted a question in General forum. I appreciate if you take a look there too.

thanks again.
 

Minty

AWF VIP
Local time
Today, 05:13
Joined
Jul 26, 2013
Messages
10,355
When you say attach I'm not sure I understand what you are trying do.
is the MDF file in use? You might need to take it offline.
Can you take a back up and restore it to your server?
 

deletedT

Guest
Local time
Today, 05:13
Joined
Feb 2, 2019
Messages
1,218
I take a backup every 6 hours.

This is the long story.
I had to add several major and critical changes to a database in sql server. This changes needed several design changes in main tables.
I tried to use ...Copy Database .... to make a copy of the database and work on the copy first as a test.
While Sql Server Management was trying to copy the database, I received an error message telling Management studio failed to copy the database.
Well...with this error, the database was gone.
Since the mdf file stills exists, I was trying to attach it again.

Hope it makes sense
 

isladogs

MVP / VIP
Local time
Today, 05:13
Joined
Jan 14, 2017
Messages
18,186
I'm answering on my tablet so don't have SQL Server available to give details at the moment
Normally you would restore from a .BAK file not the .MDF and from memory you have to do 'restore with replace'.
 

Minty

AWF VIP
Local time
Today, 05:13
Joined
Jul 26, 2013
Messages
10,355
I know hindsight is always simple after the event, but you should probably have simply restored the backup to a new database name as a development copy, tested on that and then scripted your changes.
From your description, I'm not sure the MDF file will be in a suitable state to attach as it wasn't probably detached in the first place.
 

deletedT

Guest
Local time
Today, 05:13
Joined
Feb 2, 2019
Messages
1,218
I'm answering on my tablet so don't have SQL Server available to give details at the moment
Normally you would restore from a .BAK file not the .MDF and from memory you have to do 'restore with replace'.
I wasn't going to restore. I intended to attach a .mdf file to a sql server.
Thanks.
 

deletedT

Guest
Local time
Today, 05:13
Joined
Feb 2, 2019
Messages
1,218
I know hindsight is always simple after the event, but you should probably have simply restored the backup to a new database name as a development copy, tested on that and then scripted your changes.
From your description, I'm not sure the MDF file will be in a suitable state to attach as it wasn't probably detached in the first place.

Well, I ended up to do the same.

Thanks
 

SQL_Hell

SQL Server DBA
Local time
Today, 05:13
Joined
Dec 4, 2003
Messages
1,360
Bit late to the party here, but that attach DB error looks to be folder level permissions or invalid path.
 

Users who are viewing this thread

Top Bottom