Questions tagged [attach]

Attaching existing database files to an existing DBMS instance (not performing a restore)

19 questions
17
votes
12 answers

Database cannot be upgraded because it is read-only or has read-only files. Make the database or files writeable, and rerun recovery

I have received a database file and the instructions for loading it is to install SQL Server 2005 and then attach it using SQL Server Management Studio. After installing everything, I tried to attach the MDF file but then it tells me: the directory…
MxLDevs
  • 359
  • 1
  • 5
  • 10
3
votes
3 answers

What is the purpose of attaching a database?

I always see this option called attach database in SQL Server. Why would someone attach a database? Why not just restore a database from the .BAK file? I guess I don't see the purpose of it. What would be the result of attaching it? It's quicker…
user18139
  • 87
  • 1
  • 4
2
votes
1 answer

How do I fix the Failed to retrieve data for attaching mdf file is which not primary database file

I'm using SQL Server 2019 in Windows 10 Enterprise and Administrator user I have an MDF file and I want to attach it, and it has full access in the form of Everyone Full Control , when I try to attach it I get this error : full message : …
2
votes
3 answers

Generate CREATE DATABASE FOR ATTACH for all existing user databases

Does anyone have a TSQL script that can automatically generate the code necessary to attach ALL existing user databases using the CREATE DATABASE FOR ATTACH syntax? example: CREATE DATABASE [mydatabase] ON…
user4659
2
votes
1 answer

Cannot re-attach SQL Server Express database to the same server after detaching?

I migrated a database in a test environment from one server running SQL Server Express 2008 R2 to another running the full version of SQL Server 2012. I did that by detaching the database from the first server, copying over the .mdf and .ldf files,…
1
vote
1 answer

Two SQL Server databases setup with same .mdf and .ldf files

In a SQL Server 2008 R2 instance two databases (the second one being a restore/copy of the first one) have been setup against the same .mdf and .ldf files. How would I go about either deleting the second one or copying/moving the files for the…
Eirik H
  • 113
  • 1
  • 6
1
vote
1 answer

How to move mdf file to other disk drive when it is "Standby / Read-Only" mode?

I am trying to change the location of mdf and ldf file from one disk drive to other disk drive due to storage limit. Currently, the database that I am trying to move to other drive is in "Standby / Read-Only" mode. But, my understanding is that, in…
Java
  • 253
  • 3
  • 10
1
vote
2 answers

Attaching a database (created in SQL Server 2012) to an instance of SQL Server 2014 without upgrading it

I've a database in a production server (SQL Server 2012) and I've a development server (SQL Server 2014). I need to attach the database in the development server but I've realized that once attached it's automatically upgraded to the version 2014 so…
vcRobe
  • 121
  • 3
0
votes
0 answers

CREATE FILE encountered operating system error 5 (Access is denied.) while attempting to open or create the physical file

(I reviewed the comments from this post, but I was not able to resolve my issue). I am trying to attach a mdf file that I placed in other drive, and I got this error: I am aware of the permission issue of the folder that I am pointing the file (to…
Java
  • 253
  • 3
  • 10
0
votes
1 answer

How to remove remaining traces of a detached database from a server?

I had a database Coderr that I no longer wanted. Unfortunately, I detached it instead of dropping it. Now I'm seeing traces of it pop up in SSMS dialogs: I'd like to remove this (and any others that may be lurking). I tried DROP DATABASE [Coderr],…
InteXX
  • 559
  • 2
  • 7
  • 17
0
votes
1 answer

DB2: Working with concurrent DDL operations

We are working on a data warehouse using IBM DB2 and we wanted to load data by partition exchange. That means we prepare a temporary table with the data we want to load into the target table and then use that entire table as a data partition in the…
user2323596
  • 101
  • 1
0
votes
1 answer

What is the implication at attempting an attach without detach?

Sql server attach prerequisite states that a db must be detached before trying to attach it to another instance (https://learn.microsoft.com/en-us/sql/relational-databases/databases/attach-a-database?view=sql-server-ver15#Prerequisites) However this…
variable
  • 3,590
  • 4
  • 37
  • 100
0
votes
1 answer

Missing rows in table after restore database from MDF and LDF with SQL Server 2008

I have got two files, test.mdf and test.ldf, with sizes around 200 Mb and 200 MB. I restore the database using "Attach Databases" options, all is ok, but I found that there are a lot of missing rows in some tables. What can I do? I have all files…
0
votes
1 answer

Attaching database to an existing connection

Is attaching the database supported only by SQLite and MS SQL Server? All other DBMSes can only have one database per connection? Scenario: Let's say there is an archived database with some historical data. The application needs to compare with the…
Igor
  • 247
  • 5
  • 12
0
votes
0 answers

Why does a create database statement return values when called from C#?

I have the following database command: CREATE DATABASE [test1] ON (FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\test1.mdf'), (FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\test1_log.ldf')…
isxaker
  • 87
  • 11
1
2