Attach Database Failed For Server

i am trying to attach external database named ( HaseebProject.mdf) but every time i got an error " An error occurred when attaching the database(s). Click the hyperliên kết in the Message column for details."What"sthe error is there..?? even there is any error message in message field as shown.enter image mô tả tìm kiếm here

When i cliông chồng on add button lớn add database there are two paths in directory for database. i have tried with both but he same error.enter image mô tả tìm kiếm here


*

*

I had this problem as well, I did right cliông xã on (.mdf and .ldf) the file then on the security tab, clichồng on Edit.

In a new window find the users và set permission to lớn full control. If you can"t find users cliông xã on:

add button-->advanced-->Find now-->find users and then click on Ok.if it doesn"t work you can backup from your database và restore it instead of attaching. I have done it & it works.But before restoring make sure that your DB (.mdf và .ldf) shouldn"t exist in Squốc lộ VPS database directory before restoring (it"s up lớn your Squốc lộ server installation path in my case -->C:Program FilesMicrosoft Squốc lộ ServerMSSQL12.SQL2014MSSQLDATA) otherwise you will face khổng lồ an error


Share
Improve sầu this answer
Follow
edited Nov 26 "17 at 11:09
answered Oct 10 "17 at 10:31
*

Mo0rtezaMo0rteza
25466 silver badges1515 bronze badges
1
Add a comment |
7
All of the answers I"ve seen so far are possible suggestions of what could be the issue, but it doesn"t necessarily help you identify the issue that"s preventing you from attaching this database.

The error message you are referring khổng lồ is actually pointing you to a more specific error message for your case. This more specific error message is located in the Message column of the "Attach Database" window that you"ve already opened (you may just need to scroll lớn the right of the "Databases to lớn attach" section và click on the message lớn see it in its entirety.

Bạn đang xem: Attach database failed for server

*


Share
Improve this answer
Follow
edited Aug 22 "19 at 4:32
*

Bhargav Rao♦
43.4k2727 gold badges118118 silver badges130130 bronze badges
answered Aug 8 "19 at 22:07
*

Ryan HarrisRyan Harris
13911 silver badge77 bronze badges
2
Add a bình luận |
2
Navigate lớn the directory containing the database và open theproperties for the thư mục.Go to the Security tab, Edit permissions, Add User.In Locations, select the location that is hosting the VPS.In object names, Enter NT ServiceMSSQL$ (e.g. NTServiceMSSQL$MSSQLSERVER).Set Permissions khổng lồ full control and save.This will give your Squốc lộ Server instance full permissions for the target directory.


Share
Improve sầu this answer
Follow
answered Nov 25 "17 at 0:42
BradBrad
16144 silver badges1414 bronze badges
Add a comment |
1
Right-cliông xã on the MyDataBase.MDF fileSelect Properties -> Go lớn Security tab -> Select Edit -> Select Add -> Select Advanced -> Select Find Now -> Selecte User Administrator & User EveryoneSet permissions to lớn full control for bothCliông chồng OKClear MyDataBase_log.LDF fileCopy MyDataBase.MDF file lớn this location:

(C:Program FilesMicrosoft SQL ServerMSSQL11.MSSQLSERVERMSSQLDATA)

Run Squốc lộ Server Management Studio as an administrator

Attach MyDataBase.MDF tệp tin from this address:

(C:Program FilesMicrosoft SQL ServerMSSQL11.MSSQLSERVERMSSQLDATA)


Share
Improve this answer
Follow
edited Aug 10 "18 at 10:05
Prashant Pimpale
9,20477 gold badges3434 silver badges7272 bronze badges
answered Aug 10 "18 at 5:23
ahm3dlikeahm3dlượt thích
1111 bronze badge
Add a phản hồi |
1
If you already have a database with the same name, delete it before you try lớn attach the .mdf tệp tin. My issue was that they were named the same.

Xem thêm: Tuyển Cộng Tác Viên Đánh Máy Thời Gian Làm Việc Linh Hoạt, Tuyển Ctv Đánh Văn Bản

Ryan Harris mentioned looking at the error message, this helped me a lot. So look at that first, you might have sầu a different issue.

Squốc lộ message


Share
Improve sầu this answer
Follow
answered Aug 5 at 20:58
Hunter DarrHunter Darr
1111 bronze badge
Add a phản hồi |
0
I had the same issue. The problem was the disk which I was transferring the database tệp tin. So if you are copying the database file from one computer to another computer make sure the removable disk is not corrupted. Always try a second removable disk. And also don"t forget lớn run SSMS as administrator.


Share
Improve sầu this answer
Follow
answered May 3 "18 at 16:30
Elham mê KohestaniElyêu thích Kohestani
2,71922 gold badges1717 silver badges2828 bronze badges
Add a phản hồi |
0
Use this command lớn attabịt db from .mdf file

USE GOCREATE DATABASE ON ( FILENAME = N"C:SchoolDB.mdf" )FOR ATTACHGO
Share
Improve this answer
Follow
answered Aug 10 "19 at 12:49
Nitin BhadeNitin Bhade
1
Add a phản hồi |
0
I had the same issue. After I expanded the error message, I found that it was saying the .MDF file was compressed.

If your error is similar to this:

Create failed for Database "Compressed_DB". (Microsoft.SqlServer.Smo)An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)The tệp tin "E:Compressed_DB.mdf" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (Microsoft Squốc lộ Server, Error: 5118)Then you can right clichồng the thư mục in which the .MDF file resides, cliông xã "Properties".Clichồng "Advanced" in the General tab, và uncheck "Compress contents to save sầu disk space"