First of all please refer the screenshot:
What is the use of Logical name and why do we use it?
I attached the mdf file which is not in sql path. This connection succeeded.
Additionally given the logical name, now connections throws the error:
Error: Unable to open the physical path "" operation system error 32,
Cannot attach the file "" as database ""
I googled for this, but no one suggest the perfect solution.
I tried this in Administrator mode, and Windows authentication.
On a specific data folder, you cannot have the same .mdf file
But with different .mdf or .ndf file names you can create data files with same names for different databases on a SQL Server instance
Could you please check if your target database, do you have a data file with name "AttachFile" before you do the restore?
Related
I'm new to ODI & trying to create my first mapping between csv file and database table. Getting below error when selecting resource name in the data store.
The directory XXXX specified in your schema does not exist
I verified that the directory provided in physical schema is correct. The file is placed in local machine where ODI is also installed.
I placed my file in different paths, nothing works.
Physical schema should only read C:\xxx\yyy
Earlier I gave the full path including the file name in physical Schema (like C:\xxx\yyy\zzz.csv) which caused the error.
The datastore that you create in the relative model will be called zzz.csv
I am currently doing a project in backing-up SQL Server database. My question is how can I find whether the specified .bak file is present in the DEFAULT BACKUP FOLDER or not.
Till now what I have learnt is to check whether a file is present or not, I can find that out using:
EXEC master.dbo.xp_fileexist 'D:\Backup\dbbackup.bak'`
I also found out that, RESTORE VERIFYONLY FROM DISK = 'FileName', but it returns a message, the thing is I want a value in table as result, so that I can access it via java's ResultSet.
But the issue for me is how can I find whether the file is present are not, without giving the file path, but only giving the file name, assuming the file is located in DEFAULT BACKUP FOLDER
Also, can I know how to check the integrity of that backup file?
I have a .MDF backup of a database. I need some information from this .MDF.
When I try to attach this .MDF, it requires the log file with which it shipped.
I don't need the log file, but it insists on the .LDF file.
I tried to point it to the same log file with which it shipped, but I am getting the error:
(Since it is in use by the current version of the database.)
I am unable to attach it to a different server because it was originally on a SQL Server 2012, and that is my only SQL Server 2012 server.
How do I reattach the .MDF without the .LDF?
I am adding a text version in case somebody else is searching for a solution to this issue:
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "D:\SQL Logs....Custom_log.ldf". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)".
File activation failure. The physical file name "D:\SQL Logs....Custom_log.ldf" may be incorrect.
The log cannot be rebuilt because there were open transactions/users when the database was shutdown, no checkpoint occurred to the database, or the database was read-only. This error could occur if the transaction log file was manually deleted or lost due to a hardware or environment failure.
Msg 1813, Level 16, State 2, Line 1
Could not open new database 'TestDb'. CREATE DATABASE is aborted.
I don't know if this is relevant, but I actually do not need to attach .MDF file if I don't have to. I only need to read one table from there.
if you use 2012
use "FOR ATTACH_FORCE_REBUILD_LOG"
CREATE DATABASE [XXXdatabasname] ON
( FILENAME = N'databaseXXXFilePath.mdf' )
FOR ATTACH_FORCE_REBUILD_LOG
You can attach an MDF file without it's corresponding LDF file. To do this, I would use sp_attach_single_file_db
I am trying to use the technique suggested in the blog entry below (exhibit 2) to attach adventureworks.mdf without the ldf (many complain about microsoft not downloading ldf with the mdf - does anyone know where to download the mdf and ldf together??) and after the query runs for ten seconds (indicating I got the file path to the mdf right) I get the following error message:
exhibit 1: error message
File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\AdventureWorks2008R2_Log.ldf" may be incorrect.
New log file 'C:\Users\Gary\Downloads\AdventureWorks_log.LDF' was created.
exhibit 2: blog entry
http://blog-rat.blogspot.com/2009/04/how-to-attach-mdf-without-ldf-into-sql_13.html
exhibit 3: code
USE master
GO
CREATE DATABASE AdventureWorks
ON PRIMARY (FILENAME =
N'C:\Users\Gary\Downloads\AdventureWorks2008R2_Data.mdf')
FOR ATTACH_REBUILD_LOG
GO
This is just a warning and has nothing to do with AdventureWorks per se, just with attaching an mdf without a log. Didn't you find that the database was created and available for use, in spite of the message?
As for the download it's meant to be a single mdf file for simplicity. Since it's just as easy to create a new log as it would be to attach an empty log file.
I had SQL Server 2005 on my pc and had created a few databases through it. Due to some problem, I had to reinstall it but now when i give the command "create database mydb" it says
"Cannot create file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\myDb.mdf' because it already exists. Change the file path or the file name, and retry the operation."
And when i give "use mydb" command it says
Could not locate entry in sysdatabases for database 'mydb'. No entry found with that name. Make sure that the name is entered correctly.
What should I do so that it can locate my databases?
I faced the same issue.
We need to use Square brackets for database name
ie
use [database]
instead of
use database
Hope it helps.
You can re-attach the database files (assuming that your current installation is at at least the same service pack/patch level as you previously had it).
You can attach the database using either Management Studio, or using CREATE DATABASE
When you re-installed the instance, it won't delete any existing database files and when you are creating a new database its complaining that the file already exists in the default path.
Go to the location C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\ and manually delete the myDB.mdf and .ldf files and next go ahead with creating a new database.
HTH
Sometimes I simply just get this issue because I didn't change the primary available database by pressing Ctrl+U into the new DB I created. Often helps to check.