• ** There has been a recent site upgrade. Please clear your browser cache to avoid issues. **
  • New forum feature - post voting and best solution

    Check out this thread for the details: https://www.access-programmers.co.uk/forums/threads/new-forum-feature-post-voting-and-best-answer.314134/

    This new feature looks great to me! :)

  • We now have 3 forum themes

    Go for the default (light) theme, Shades of Grey or Shades of Blue. I just added the Blue one.

    The thread about it is here: https://www.access-programmers.co.uk/forums/threads/new-forum-theme-shades-of-blue.314136/

How to attach a database? (1 Viewer)

deletedT

Guest
Local time
Today, 19:43
Joined
Feb 2, 2019
Messages
1,220
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

Custom title here:
Local time
Today, 12:43
Joined
May 22, 2010
Messages
2,663
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, 19:43
Joined
Feb 2, 2019
Messages
1,220
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, 19:43
Joined
Feb 2, 2019
Messages
1,220
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

Custom title here:
Local time
Today, 12:43
Joined
May 22, 2010
Messages
2,663
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, 19:43
Joined
Feb 2, 2019
Messages
1,220
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, 19:43
Joined
Jul 26, 2013
Messages
7,370
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, 19:43
Joined
Feb 2, 2019
Messages
1,220
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

CID VIP
Local time
Today, 19:43
Joined
Jan 14, 2017
Messages
13,956
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, 19:43
Joined
Jul 26, 2013
Messages
7,370
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, 19:43
Joined
Feb 2, 2019
Messages
1,220
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, 19:43
Joined
Feb 2, 2019
Messages
1,220
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, 19:43
Joined
Dec 4, 2003
Messages
1,347
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