Attach (open) mdf file database with SQL Server Management Studio [closed] - sql-server

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
How can I open a *.mdf file of a database created with Visual Studio 2010, into SQL Server Management Studio?
I tried to attach it by myself, but I cannot navigate to that file for (I guess) some security reason.

I had the same problem.
system configuration:-single system with window 7 sp1 server and client both are installed on same system
I was trying to access the window desktop. As some the answer say that your Sqlserver service don't have full access to the directory. This is totally right.
I solved this problem by doing a few simple steps
Go to All Programs->microsoft sql server 2008 -> configuration tools and then select sql server configuration manager.
Select the service and go to properties. In the build in Account dialog box select local system and then select ok button.
Steps 3 and 4 in image are demo with accessing the folder

I found this detailed post about how to open (attach) the MDF file in SQL Server Management Studio:
http://learningsqlserver.wordpress.com/2011/02/13/how-can-i-open-mdf-and-ldf-files-in-sql-server-attach-tutorial-troublshooting/
I also have the issue of not being able to navigate to the file. The reason is most likely this:
The reason it won't "open" the folder is because the service account
running the SQL Server Engine service does not have read permission on
the folder in question. Assign the windows user group for that SQL
Server instance the rights to read and list contents at the WINDOWS
level. Then you should see the files that you want to attach inside of
the folder.
(source: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/c80d8e6a-4665-4be8-b9f5-37eaaa677226/cannot-navigate-to-some-folders-when-attempting-to-attach-mdf-files-to-database-in-management?forum=sqlkjmanageability)
One solution to this problem is described here: http://technet.microsoft.com/en-us/library/jj219062.aspx I haven't tried this myself yet. Once I do, I'll update the answer.
Hope this helps.

Copy the files to the default directory for your other database files. To find out what that is, you can use the sp_helpfile procedure in SSMS. On my machine it is: C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA. By copying the files to this directory, they automatically get permissions applied that will allow the attach to succeed.
Here is a very good explanation :
How to open MDF files
.

I don't know about the older versions but for SSMS 2016 you can go to the Object Explorer and right click on the Databases entry. Then select Attach... in the context menu. Here you can browse to the .mdf file and open it.

I don't know if this answer can be found on the links above, but I just run SQL Management Studio as Administrator and it worked.

Related

Problems with installing Microsoft SQL Server 2014 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I am getting following error while trying to install Microsoft SQL Server 2014.
If anyone knows how is this fixed I'd be grateful for help.
Screenshot of the error
TITLE: Microsoft SQL Server 2014 Setup
Error reading from file C:\Users\aldin\Downloads\SQLEXPR_x64_ENU\x64\setup\sql_engine_core_shared_msi\PFiles32\SqlServr\120\DAC\bin\hcx5y0yq.dll. Verify that the file exists and that you can access it.
Click 'Retry' to retry the failed action, or click 'Cancel' to cancel this action and continue setup.
Thanks in advance
I see that many of you put (-) on this question, I am currently learning about databases, tried installing sql server 3 times, 3rd time same error, restarted my laptop and did everything again, nothing changes.
The file really might not be there. Or it might be corrupt. The first thing to try is to get a new copy of the media. Unblock it after the download if required.
https://www.microsoft.com/en-US/download/details.aspx?id=42299
When you run it, it will want a location to extract the files. Put it in a location to which you have full access. The setup dialog will open automatically. If not, run the setup.exe in the top level of the folder you extracted. This might be all that you need.
There is a "Tools" option for "Installed SQL Server features discovery report" that might be of use. If other editions of SQL 2014 are already present, they can be a problem...but not the problem you have yet. (I never install express because it can cause issues installing DEV or STD editions. It might become an upgrade instead of an install.)
The SQL 2019 DEV edition is free and can be found at https://www.microsoft.com/en-us/sql-server/sql-server-downloads. The discovery report in 2019 will be more inclusive (all versions up to 2019).
Check the "C:\Program Files\Microsoft SQL Server\120\Setup Bootstrap\Log" to see if there is more info in the log files. The Summary.txt file will be the short version for the last run of setup.exe. Sometimes there will be instructions on what to do (e.g., uninstall and retry).
Also check the Event Logs for messages that might relate to the install.
Sometimes a virus checker can quarantine valid files.
If it really is permissions, then try taking ownership (recursively) of the install media.
There are endless reasons for things to fail. I hope it's just bad media.

Not able to attach database backup file .bak into SQL Server 2008 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
I have a database backup file named iyym.bak. How can I attach the database to my SQL Server 2008?
I tried inside SQL Server Management Studio the following:
right click on data base folder in object explorer
selected attach
click add button.
When I am trying to add the backup error showing iyym.bak is not a primary database.
I have used the same version of SQL Server to take the backup too.
How can I attach this back?
A .bak file isn't supposed to be ATTACHED. It's a backup file that you RESTORE.
Try something like the following:
RESTORE DATABASE [DbNameGoesHere] FROM DISK ='C:\PathtoBackup\Backup.bak'
Here's the MSDN article that has all the switches and arguments:
https://msdn.microsoft.com/en-us/library/ms186858.aspx?f=255&MSPPError=-2147217396
You cannot Attach an SQL Server Backup File.
Instead, you need to create a new empty database, and them restore the backup on top of it. Just make sure to replace the MDF and LDF Path a file name to match your new DB files, and to check the option WITH_Replace.

How do I create a SQL server so I can connect to server management [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
The title might be a little confusing so I am going to explain my problem in detail so please read all of this before you all go quickly shut down this question for being a copy.
I got two problems, one is that I don't know how to make a server for Microsoft SQL SMS. As in when I start it up I have no idea what to type into the connection thing because when I try to do a simple localhost for server name it gives me an error. All the tutorials online act like I should already know what to do up to that point so skip over it without explaining how to set up a server.
Now I know it is a server management tool for databases, but I received a .bak file from my supervisor that contains all the data outlines and all that good stuff.
So pretty much I want to know how to take this .bak file and somehow create a server or something so I can use this data. If this is unclear I am more than willing to expand upon this. I realize my question was not as clear and people quickly shut it down claiming it was the same as other questions.
You need to install an instance of SQL Server (it's not clear to me that you have done that). You can use the free SQL Server Expres Edition unless:
the data file(s) consume more than 10GB
the database uses features that require a higher SKU (Standard/Enterprise)
We have no idea whether either of those conditions are true. If they are, then you can buy the Developer Edition for about $50 (feel free to shop around), assuming you are not planning to install this on a server and use it in production.
I am suggesting SQL Server 2012 only because it is the latest supported release. You can choose to use SQL Server 2008 or any other version, but your best chance at compatibility with this backup file you've been given is if you are restoring it to a version that is later or equal to the version where it was backed up.
This site is not the place for step-by-step instructions on installing an instance of SQL Server (you can find those elsewhere). Once you have an instance of SQL Server installed, then you need to find out what your database looks like. Usually your backup file will be created on a server where the database itself was installed in physical folders that do not match your own machine. So I suggest either finding out the default path by inspecting the output of this query (which tells you where the master data file is located):
SELECT physical_name FROM sys.master_files
WHERE database_id = 1 AND [file_id] = 1;
Or creating a very simple folder called c:\databases\, giving the Everyone account modify privileges.
Then run the following (below I've assumed the backup is in c:\databases\ and that's where you want the data files; if that differs, adjust accordingly):
RESTORE FILELISTONLY FROM DISK = 'c:\databases\whatever.bak';
This will return a resultset like:
LogicalName PhysicalName
------------- ------------
Whatever C:\...\whatever.mdf
Whatever_log C:\...\whatever_log.ldf
You need to build a RESTORE DATABASE command something like the following, based on the result above:
RESTORE DATABASE foo FROM DISK = 'c:\databases\whatever.bak'
WITH MOVE 'Whatever' TO 'c:\databses\whatever.mdf',
MOVE 'Whatever_log' TO 'c:\databases\whatever_log.ldf';
Now you can connect to the database using Management Studio. The server name you specify in the connection dialog will depend on what edition of SQL Server you installed, and whether you used a named instance or a default instance. You can tell whether it is a named instance or not by looking in the Services applet (Control Panel > Administrative Tools). There you should see at least one instance of SQL Server, and it will be followed either by (MSSQLServer) or (InstanceNameYouChose). Here I have three named instances of SQL Server (the named instances are SQL2005, SQL2008, and SQL2012):
If you have a named instance, then you would connect in Management Studio using:
.\InstanceNameYouChose
So for example, to connect to my SQL2008 instance, I would say:
.\SQL2008
or
ServerName\SQL2008
or
(local)\SQL2008
or
LOCALHOST\SQL2008
or
127.0.0.1\SQL2008
etc. etc.
If you have a default instance then you don't need the slash and the subsequent name, it would just be:
.
or
ServerName
or
(local)
or
LOCALHOST
or
127.0.0.1
etc. etc.

Database error occurred (SQL error 18054) when mapping local directory in TFS [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm using VS2010 as a client for a TFS instance. I created a workspace, and need to map a TFS directory to a local directory - let's call the local directory "D:\aaa\bbb\ccc\ddd". When I navigate to "Manage Workspaces" and click "edit" to change the local directory to this path, I am presented with the following error: 1
This error occurs when I try to map: "D:\aaa", "D:\aaa\bbb", "D:\aaa\bbb\ccc".
Now, if I create a folder called: "D:\aaa\bbb\ccc1\ddd", the mapping works, and I do not receive this error.
Can anyone help? I've been pulling my hair out for about a day over this.
Thank you.
[EDIT01: I tried mapping all other folders under the D:\ drive, and only one other folder fails the mapping. I receive the same error as with "D:\aaa\bbb\ccc\ddd" ]
SQL Errors
First of all, you should not be receiving SQL Error 18054 (or any SQL errors) from TFS.
You should have your TFS administrator connect to the SQL server that hosts the master DB for your TFS server and run the following query:
select * from master.dbo.sysmessages where error > 50000
If this is a TFS2010 server, your TFS administrator may be able to use TFSConfig PrepSql to re-install the error messages.
If this is a TFS2008 server, your TFS administrator will need to open Add/Remove programs and run a repair on TFS.
Your actual problem
This sounds obvious at first, two
local paths cannot point to the same
place in the repository for the same
workspace. However, the one that
catches a lot of folks un-aware is
that you cannot have two repository
paths mapped to one local path on the
same computer.
In TFS, you cannot have two folders with overlapping mappings. Since D:\aaa\bbb\ccc\ddd is a sub-folder of D:\aaa, then you cannot add it.
One thing you can do though, is cloak folders so that they aren't part of the workspace mappings. In your case, you might want to map D:\aaa and add a cloak for all the other subfolders in that directory, except for D:\aaa\bbb.

SQL server 2008 backup error - Operating system error 5(failed to retrieve text for this error. Reason: 15105) [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Can anyone help me, I'm trying to backup a database located on localhost\SQLEXPRESS but i keep getting the following error:
Backup failed for Server 'localhost\SqlExpress'. (Microsoft.SqlServer.SmoExtended)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.0.2531.0+((Katmai_PCU_Main).090329-1045+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Backup+Server&LinkId=20476
ADDITIONAL INFORMATION:
System.Data.SqlClient.SqlError: Cannot open backup device 'C:\backup.bak'. Operating system error 5(failed to retrieve text for this error. Reason: 15105). (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.0.2531.0+((Katmai_PCU_Main).090329-1045+)&LinkId=20476
Can anyone explain what I'm doing wrong here ??
thanks
It looks like the SQL Server doesn't have permission to access file C:\backup.bak. I would check the permissions of the account that is assigned to the SQL Server service account.
As part of the solution, you may want to save your backup files to somewhere other that the root of the C: drive. That might be one reason why you are having permission problems.
I've faced this error when there was not enough free space to create a backup.
Assuming that the *.bak file is on the same machine as the SQL Express instance it might be a permissions issue.
If you download procmon http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx you can filter on that file path, look for ACCESS_DENIED errors and if any are there you can see the account name that's failing get to access.
I got this error too.
The problem turned out to be simply that I had to manually create the full directory structure for the file locations of the MDF & LDF files.
Shame on SQL-Server for not properly reporting the missing directory!
I've got the same error. I have been trying to fixing this by setting higher permission to account running SQL Client service, however it didnt help. The problem was that I run MS Sql Management studio just within my account. So, next time... assure that you are running it as Run as Administrator, if using Win7 with UAC enabled.
Yes, it is security issue. Check folder permissions and service account under which SQL server 2008 starts.
I had this error. Nothing worked for me until I opened the SQLServer log file in the "MSSQL10_50" Log folder. That clearly stated which file could not be overwritten. It turned out that the .mdf file was being written into the "MSSQL10" data folder. I made sure that folder had the same SQLServer user permissions as the "MSSQL10_50" equivalent folder. Then it all worked.
The issue here is that the error detail is logged but not reported, so check the logs.

Resources