From SQL Server 2014 to SQL Server 2019 - No backupset selected to be restored - backup

From a Windows Server 2012 / SQL Server 2014, I backed up a database to a NNNN.bak file on a network drive. When I log in to my new Windows Server 2019 / SQL Server 2019 and try to restore that, I get the famous
No backupset selected to be restored
error on the upper-left corner of the screen when I select a NNNN.bak.
I tried several things like checking/adding the file extension .BAK, restore from a local drive, different checkboxes in "General", "Files", "Options" menu.
Important: with the same exact conditions 5 other databases got restored and the other four are not cooperating within the same week.
I checked my user permissions inside databases and both SQL servers. I am an administrator with almost all privileges.
I tried restore verifyonly... and restore header... etc

Using the network path provided by the company R:\erts..\nnn... failed. restore succeeded using server on the same network with \\Qdata...\nnn.. path as shown in the screenshot.

Related

Repair Suspected TFS database

i am using this T-SQL to repair my TFS suspected database
EXEC sp_resetstatus [TFS_Projects];
ALTER DATABASE [TFS_Projects] SET EMERGENCY
DBCC checkdb([TFS_Projects])
ALTER DATABASE [TFS_Projects] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ([TFS_Projects], REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE [TFS_Projects] SET MULTI_USER
but when i use this T-SQL i will get error
Database 'TFS_Projects' cannot be opened due to inaccessible files or insufficient memory or disk space.
how can i repair my SQL database?
i am using SQL Server 2012
UPDATE 1:
this error will Occurred in line :
DBCC checkdb([TFS_Projects])
UPDATE 2:
i have 20GB free on hard drive that my mdf and ldf on it
UPDATE 3:
i can not chek Autogrow becuase when i right click on db the error will appear
mdf and ldf is not readonly
and i am loged in by windows administartor, and loged in sql server by sa
1) If possible add more hard drive space either by removing of unnecessary files from hard drive or add new hard drive with larger size.
2) Check if the database is set to Autogrow on.
3) Check if the account which is trying to access the database has enough permission to perform operation.
4) Make sure that .mdf and .ldf file are not marked as read only on operating system file system level.
Found here: http://blog.sqlauthority.com/2007/08/02/sql-server-fix-error-945-database-cannot-be-opened-due-to-inaccessible-files-or-insufficient-memory-or-disk-space-see-the-sql-server-error-log-for-details/
i update my answer becuase old answer is dangerous and will damage TFS database!
this answer is from microsoft : http://msdn.microsoft.com/en-us/library/jj620932.aspx
To back up your databases
Launch TFSBackup.exe.
The TFSBackup.exe tool is in the Tools folder where you installed Team Foundation Server. The default location is C:\Program Files\Microsoft Team Foundation Server 12.0\Tools.
In Source SQL Server Instance, enter the name of the SQL Server instance that hosts the TFS databases you want to back up and choose Connect.
In Select databases to backup, choose the databases to back up.
Need help? List of TFS 2010 databases on MSDN; List of TFS 2012 databases on MSDN.
In Backup Databases to, enter the name of a network share that is configured with read/write access for Everyone, or accept the default location in the file system of the SQL Server you connected to in step 2.
Note Note
If you want to overwrite backups stored in this network location, you can choose Overwrite existing database backups at this location.
Choose Backup Now.
The Backup tool reports progress on each database being backed up.
Choose Close.
Restore your data
To restore your TFS data
Launch TFSRestore.exe.
The TFSRestore.exe tool is in the Tools folder where you installed Team Foundation Server. The default location is C:\Program Files\Microsoft Team Foundation Server 12.0\Tools.
In Target SQL Server Instance, enter the SQL Server instance you will use as the data tier and choose Connect.
Choose Add Share and enter the UNC path to the network share that is configured with read/write access to Everyone where you stored the backups of your TFS data. For example, \servername\sharename.
If the backup files are located on the file system of the server that is running TFSRestore.exe, you can use the drop down box to select a local drive.
Note Note
The service account for the instance of SQL Server you identified at the start of this procedure must have read access to this share.
In the left hand navigation pane, choose the network share or local disk you identified in the previous step.
The TFS Restore Tool displays the database backups stored on the file share.
Select the check boxes for the databases you want to restore to the SQL Server you identified at the start of this procedure.
Important note Important
For SharePoint, you must only restore the WSS_Content database. Do not restore the WSS_AdminContent or WSS_Config databases. You want the new SharePoint Foundation versions of these databases, not the ones from the previous version of SharePoint or from a SharePoint installation running on any other server.
Choose Overwrite the existing database(s) and then choose Restore.
The Database Restore Tool restores your data and displays progress reports.
Choose Close.
Probably your database is corrupt either due to an unexpected server restart or filesystem corruption. You can use CheckDB to check for issues & remove the suspect status. However, the best bet is to restore it from a working backup.
Some reasons for when this happens are
Database is corupted
database files are being "opened" or held by some process (operating system, other program(s)...)
Not enough disk space for SQL Server
Insufficient memory (RAM) for SQL Server
Unexpected SQL Server shutdown caused by power failure
How to repair a suspect database

SQL Server Database is not getting attached again

I tried to detach my SQL Server 2008 R2 database for creating a duplicate of it, meanwhile connections to that database were active from Visual Studio (2010). So SQL Server denied to detach. After closing Visual Studio, I tried again and my database was successfully detached.
After detaching my database I tried to copy both files (.mdf and .ldf) to another folder as a duplicate copy, but I could not do so because I was getting error that says
You require permission from the computer administrator to make changes to this file
I am using Windows 7 and my account is Administrator. I also tried to attach my database again to SQL Server (running it with administrator permission) but I got the following error:
Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
Additional Information:
An exception occurred while executing a Transact-Sql statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
CREATE FILE encountered operating system error 5 (Access is denied,) while attempting to open or create the phyical file'C:/Mywor/MyDataBase.mdf'.
(Microsoft SQL Server, Error: 5123)
Please help me if someone know how to handle this problem.
Here are couple things you can try:
Stop SQL Server service and see if you can copy files (to stop SQL service go to SQL Server Configuration manager)
Try to copy some other database files in that directory and see if that works (make sure permissions for both files are exactly the same)
Try to copy .mdf and .ldf files in original SQL Server data directory (you can find it in SSMS -> Instance properties ->Database Settings
If you’re not using windows explorer for copying files make sure you run it as admin (right click -> Run as administrator)
This is a permissions issue on the database files directory, or the files themselves. Just because you're logged on as an administrator doesn't mean that Windows 7 allows you to do anything you want without whinging at you first. Also, the SQL Server service account may not have the appropriate permissions on the file/folder.

"This database file is not compatible with the current instance of SQL Server"

I am currently reading through a book about MVVM and I need to use the Northwind database for the next section. Unfortunately, when I try to add Northwind to my project, I get the following error:
"An error occurred while connecting to the database. The database might be unavailable. An exception of type 'Microsoft.Data.ConnectionUI.SqlDatabaseFileUpgradeRequiredException' occurred. The error message is: 'This database file is not compatible with the current instance of SQL Server.'"
I haven't installed an SQL Server, just Visual Studio 2012. The book instructs me to add the .MDF file to the project, set it as an Entity Data Model, and then to generate from database. It's on the next screen where I get the error. I use NORTHWND.MDF as the data connection and the entity connection string is as follows:
metadata=res:///Model1.csdl|res:///Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\NORTHWND.MDF;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"
In the book, this reads:
metadata=res:///Model1.csdl|res:///Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=True;UserInstance=True"
I have tried using both data sources and neither work.
Also of note, the sample code that goes along with the book doesn't work either. It compiles and launches, but in the server explorer, NORTHWND.MDF has an 'x' in the icon and upon launch none of the data is there.
When I attempt to upgrade the database, I get an error saying:
"Database '...\NORTHWND.MDF' cannot be upgraded because its non-release version (539) is not supported by this version of SQL Server. You cannot open a database that is incompatible with this version of sqlservr.exe. You must re-create the database..."
If anybody could give me any tips on how to get this working, I would certainly appreciate it.
my simple way:
go to VisualStadio 2012
In Server Explorer Windows
open Data Connections
Right click on ASPNETDB.MDF
click on Modify Connection...
a new windows open for you ... you just click OK
if other windows open for you click Yes
FINISH ( be Happy ) :D
If we are trying to attach .mdf file in SQL Express mode in our development project and while adding .mdf file in App_Data folder we are getting exception like below :
"The database file is not compatible with the current instance of sql server...."
Then we can go to Server explorer window → go to Data connections → go to "your database" → right click on Modify connection → check the Data sources and Database file name, then use windows Authentication and press OK.
It works for me.
one way to potentially fix it is, install Sql Server 2012 Express and use database connection to sql server. Do not use local database. That might work. Just a suggestion.
Also as an extra note, you might want to download SQL Server 2012 Management Studio (I believe it comes with the above download as a component that you have select). With Management Studio Installed, you can test the database connectivity separately, create tables, run queries etc. This will make troubleshooting a lot easier.
Visual Studio doesn't install any database server by default so you can't connect to one. The MDF file is just the file where SQL Server stores its data, it's not a standalone database.
You have to install some version of SQL Server 2012 Express for both connection strings to work.
The first connection string uses the LocalDB feature which is essentially a minimal installation of SQL Server 2012 Exrpess (~ 35 ΜΒ). You can only connect to LocalDB from your machine which makes it useful only for development purposes.
The second connection string connects to an actual instance of SQL Server Express, called SQLExpress, installed on your local machine. The second connection string attaches the MDF file to the server as a User Instance, which means that the file is released when you stop using it.
The SQL Server Express downloads range from 130 MB to 1.3 GB depending on which version you download (minimal to full with advanced services).
Northwind database is not readily compatible with 2012, the compatible version of Northwind database for sql server 2012 can be downloaded from the below link, and after downloading .mdf file we can easily attach it with sql server 2012. I have found the following and it helped me, hope it will help you. How to Attach Northwind Database in Sql Server 2012
First go to data connection as on pic:1
2.Then browser your mdf file press ok and it will automatically convert the database.
picture:01
picture:02
Modify connection may solves the problem, but I am not sure whether the type of this database file is changed.
I have found a way to solve this problem if you have installed the database Server corresponding to the database file. You just need to change the default database Server of your visual studio.
On the menu, choose Tools-> Options -> Database tools, then on the data connections enter the SQL server Instance name corresponding to your database file which you have installed,then press Ok.
Next step is also important, it is necessary to click 'refresh' or delete the database filename in Data Connection and reopen the file, the file will be added to Data Connection again and open successfully.
This is what worked for me:
On the Add Connection dialog box, click Advanced.
Scroll down to the bottom and look for a field called Data Source.
Change it from (localdb)\MSSQLlocalDB to .\SQLEXPRESS.

Cannot attach database SQL Server 2012 error 5

When I type this:
CREATE DATABASE AdventureWorks2012
ON (FILENAME = 'C:\Users\sohm\Desktop\Pohm\AdventureWorks2012_Data.mdf')
FOR ATTACH_REBUILD_LOG ;
I get this:
File activation failure. The physical file name
"C:\Users\sohm\Desktop\AdventureWorks2012_Data_log.ldf" may be incorrect.
Msg 5123, Level 16, State 1, Line 1
CREATE FILE encountered operating system error 5 (Access is denied.) while attempting to
open or create the physical file 'C:\adventuredb\AdventureWorks2012_Data_log.ldf'.
Msg 1813, Level 16, State 2, Line 1
Could not open new database 'AdventureWorks2012'. CREATE DATABASE is aborted.
I know it has to do with permissions. I have the administrator account. I have read a million posts but nothing has worked so far. Also when I try to change the folder containing the mdf file, to full control but it keeps reverting back to read-only.
You should run SSMS as an administrator.
Also it is possible that you might be running query as an 'sa' user(sql server authentication).
Try running the query with windows Authentication.
SHORT VERSION
For allowing MS SQL server 2012 to attach the database files you must grant full access to the mdf and ldf files to:
NT Service\MSSQLSERVER
Full Access
LONG VERSION
SQL Security has been updated a lot in 2012 handling of files.
http://technet.microsoft.com/en-us/library/ms189128.aspx
If you look at the existing attached databases and there security you will probably see that there only are 2 roles allowed with full access. MSSQLSERVER and Administrators, when attached SQL Removes all other roles from the files.
Trying to set the MSSQLSERVER from the fil security Permission will not work.
Looking at your services.msc overview you will in a default install see that NT Service\MSSQLSERVER also runs the SQL server servics.
The service account is not visible, the same issue as with IIS AppPools, a sub group has been created by the system and "hides" the accounts from auto discovery, probably to try and secure the accounts but in my view just obscures the setup.
Regards Jan
Open the SQL Server Management Stdio in Administrator mode(Right click -> Select Run as Administrator. If it asks for User name and password enter your Administrator user name password). Then select Windows Authentication click ok, and now try to attache it will attache without any error.
This has nothing to do with YOUR account. SQL Server is trying to write to that folder under the context of the service account that is running SQL Server. You can see who this is by going to the Services applet and seeing who the instance runs as (probably NT AUTHORITY\SYSTEM or whatever). You can override that or you can place your MDF files in the data folder, which SQL Server already has inherent access to, instead of placing them in this other location on your C:\ drive.
Another way to solve this is to change all the SQL Server services to Local System Account instead of services. Start -> Run ->Services.msc -> Scroll down to SQL Server, you should see five services that start with SQL Server. Right-Click, Properties, Log On, change to Local System Account. Repeat for all the rest of the SQL Server Services and restart them all.
Try This
Go to the folder where you have stored mdf file.
Select file -> Right click -> click on mdf give full permissions to file for logged in user Security.
If still issue persist and it might me because of corrupted transaction logs, you may use tool SQL Database Recovery Tool Repairs to repair your corrupted mdf file.
Figured it out. I went to sql server configuration manager and right clicked SQL Server Service. Then I added my Windows Admin account to run the service and now it works.

Use mdf file that was created with visual studio 2008 on another computer

I created a database with Visual Studio 2008 and I have a file in c:\data.mdf how I can use it on another computer?
I can't use this database, I installed SQL Server Express 2005 - that install is on the first machine.
To move a database from one location to another,
you need to
1. Detach from your source database server: Since you are using Visual Studio 2008 on your source machine, go to Server Explorer - Right click on Databases - Click on Detach.
2. Copy MDF & LDF file to target machine
3. Attach MDF file to your destination database server: Repeat step 1 on target machine's SQL Server, and Instead of Detach - Choose Attach and select the relevant MDF file.
You do not access an mdf file directly, you always go through the server.
To 'tell' Sql Server about the database:
Goto the Object Explorer window.
Right click Databases.
Select Attach...
Then Add...