Ошибка specified cast is not valid sqlmanagerui

I am using SQL Server 2008 R2 Standard (version 10.50.1600.1) for my production website and
SQL Server Express edition with Advanced Services (v10.50.1600.1) for my localhost as a database.

Few days back my SQL Server crashed and I had to install a new 2008 R2 Express version on my localhost. It worked fine when I restored some older versions taken from Express edition but when I try to restore database from .bak file which is taken from production server it is causing the following error:

Error: Specified cast is not valid. (SqlManagerUI)

and when I try to restore the database using command

Use Master
Go
RESTORE DATABASE Publications
FROM DISK = 'C:\Publications.bak'
WITH MOVE 'Publications' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS2008R2\MSSQL\DATA\Publications.mdf',--adjust path
MOVE 'AlPublications_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS2008R2\MSSQL\DATA\Publications.ldf'

It generates a different error

Msg 3154, Level 16, State 4, Line 1
The backup set holds a backup of a database other than the existing ‘Publications’ database.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

I have cross checked the versions. They all seem matching to me as shown in the image below

Previously I was able to restore a database from standard version to express edition but now it fails. I deleted the database and tried to recreate it. That fails, too.

I am not sure what I am doing wrong. I would appreciate help in this regarding

Issue was resolved as it seems .bak file was corrupt. When I tried it with a different file it worked.

Summary

This Error Message Article explains the Microsoft SQL Server Management Studio error message “Specified cast is not valid. (SqlManagerUI)” and details how to fix the underlying problem that caused it to appear.

Explanation

This message appeared when a client tried to restore a SQL backup file made from another instance of SQL using a newer version.

Solution

SQL is generally not backwards compatible.  The original back up file must be recreated in the same version of SQL that will restore it.

Error First Appeared: Windows 7 running Microsoft SQL Management Studio 2008R2

Dave Klement

Principal at Efficient Business Systems

Follow us on Social Media

Specified Cast Is Not Valid. (Sqlmanagerui) With Code Examples

Hello everyone, in this post we will look at how to solve Specified Cast Is Not Valid. (Sqlmanagerui) in programming.

The GUI can be fickle at times. The error you got when using T-SQL is because you're trying to overwrite an existing database, but did not specify to overwrite/replace the existing database. The following might work:

Use Master
Go
RESTORE DATABASE Publications
  FROM DISK = 'C:\Publications_backup_2012_10_15_010004_5648316.bak'
  WITH 
    MOVE 'Publications' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS2008R2\MSSQL\DATA\Publications.mdf',--adjust path
    MOVE 'Publications_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS2008R2\MSSQL\DATA\Publications.ldf'
, REPLACE -- Add REPLACE to specify the existing database which should be overwritten.

By examining various real-world cases, we’ve shown how to fix the Specified Cast Is Not Valid. (Sqlmanagerui) bug.

Which is not valid SQL database?

DECIMAL is not a valid SQL type because it is nothing but numeric only in SQL.

How do I fix no Backupset selected to be restored?

Steps to Fix SQL Server No Backupset Selected to Be Restored Error

  • Download and Launch the SQL BAK File Recovery Tool.
  • Click Open, and then click Browse to load the SQL Server .bak file.
  • Select SQL .bak file version, if you don’t know the exact version, simply click on Auto Detect option.

How do I determine SQL Server version?

Finding the SQL Server version with query We can use the @@VERSION function to find out all version details of the SQL Server instance. The @@VERSION function returns a one-line string output and this output also provides all the necessary information about the SQL Server.08-Oct-2019

Which is the valid data type in SQL?

Because Characters, Numeric, and Float are all valid SQL types. If you are willing to learn SQL and wish to get certified in SQL, have a look at the SQL certification course from Intellipaat.23-Mar-2021

Which of the following is not a valid date and time data type in SQL?

Which of the following is not a valid Date and Time data type? Explanation: datestamp is not a valid Date and Time data type. Timestamp exists but datestamp does not exist in SQL.

How do I restore my database?

A. Restore a full database backup

  • In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.
  • Right-click Databases and select Restore Database
  • On the General page, use the Source section to specify the source and location of the backup sets to restore.

How do I restore a local SQL Server database?

Procedure

  • Log in to the computer on which you want to restore the database.
  • Open Microsoft SQL Server Management Studio.
  • In the left navigation bar, right-click on Databases and then click Restore Database.
  • In the Source section, select Device and click the button with three dots.

Returns a result set containing all the backup header information for all backup sets on a particular backup device in SQL Server. Note.02-Sept-2022

How do I connect to a local SQL Server?

Connect to the SQL Server using SSMS Next, from the Connect menu under the Object Explorer, choose the Database Engine… Then, enter the information for the Server name (localhost), Authentication (SQL Server Authentication), and password for the sa user and click the Connect button to connect to the SQL Server.

How do you check if SQL is installed on a server?

Click Start, point to All Programs, point to Microsoft SQL Server, point to Configuration Tools, and then click SQL Server Configuration Manager. If you do not have these entries on the Start menu, SQL Server is not correctly installed.14-Sept-2022

Follow us on Social Media

I am using SQL Server 2008 R2 Standard (version 10.50.1600.1) for my production website and
SQL Server Express edition with Advanced Services (v10.50.1600.1) for my localhost as a database.

Few days back my SQL Server crashed and I had to install a new 2008 R2 Express version on my localhost. It worked fine when I restored some older versions taken from Express edition but when I try to restore database from .bak file which is taken from production server it is causing the following error:

Error: Specified cast is not valid. (SqlManagerUI)

and when I try to restore the database using command

Use Master
Go
RESTORE DATABASE Publications
FROM DISK = 'C:\Publications.bak'
WITH MOVE 'Publications' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS2008R2\MSSQL\DATA\Publications.mdf',--adjust path
MOVE 'AlPublications_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS2008R2\MSSQL\DATA\Publications.ldf'

It generates a different error

Msg 3154, Level 16, State 4, Line 1
The backup set holds a backup of a database other than the existing ‘Publications’ database.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

I have cross checked the versions. They all seem matching to me as shown in the image below

Previously I was able to restore a database from standard version to express edition but now it fails. I deleted the database and tried to recreate it. That fails, too.

I am not sure what I am doing wrong. I would appreciate help in this regarding

Issue was resolved as it seems .bak file was corrupt. When I tried it with a different file it worked.

This question is related to
sql-server
sql-server-2008
database-restore

The answer is


Could be because of restoring SQL Server 2012 version backup file into SQL Server 2008 R2 or even less.


Finally got this error to go away on a restore. I moved to SQL2012 out of frustration, but I guess this would probably still work on 2008R2. I had to use the logical names:

RESTORE FILELISTONLY
FROM DISK = ‘location of your.bak file’

And from there I ran a restore statement with MOVE using logical names.

RESTORE DATABASE database1
FROM DISK = '\\database path\database.bak'
WITH
MOVE 'File_Data' TO 'E:\location\database.mdf',
MOVE 'File_DOCS' TO 'E:\location\database_1.ndf',
MOVE 'file' TO 'E:\location\database_2.ndf',
MOVE 'file' TO 'E:\location\database_3.ndf',
MOVE 'file_Log' TO 'E:\location\database.ldf'

When it was done restoring, I almost wept with joy.

Good luck!


Below can be 2 reasons for this issue:

  1. Backup taken on SQL 2012 and Restore Headeronly was done in SQL 2008 R2

  2. Backup media is corrupted.

If we run below command, we can find actual error always:

restore headeronly
from disk = 'C:\Users\Public\Database.bak'

Give complete location of your database file in the quot

Hope it helps


Понравилась статья? Поделить с друзьями:
  • Ошибка p245a land rover freelander 2
  • Ошибка sparse file not allowed
  • Ошибка rfw lock
  • Ошибка spare low pressure
  • Ошибка spn 520243 шакман