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 FilesMicrosoft SQL ServerMSSQL10_50.SQLEXPRESS2008R2MSSQLDATAPublications.mdf',--adjust path
MOVE 'AlPublications_log' TO 'C:Program FilesMicrosoft SQL ServerMSSQL10_50.SQLEXPRESS2008R2MSSQLDATAPublications.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.
- Remove From My Forums
-
Question
-
Hello, I have the following code:
if (dataTable.Columns.Count > 1) { strXML = ChartFileNameandPath(chartType) + @"?dataXML=<graph caption='Report ; Summary' subcaption='" + ReportName(reportType) + "' xAxisName='Line Number' yAxisName='Pounds made' rotatelabels='1' slantlabels='1' showNames='1' showvalues='0' numberPrefix='$' exportenabled='1' exportAtClient='1' exportHandler='fcExporter1' exportFormats='PNG=Save as PNG' >"; //Getting the Subtotal of PoundsMade based on the Line Number column //C# linq query if (reportType == ReportEnums.Clientsdata) { var query = from row in dataTable.AsEnumerable() group row by row.Field<string>("ClientName") into grp orderby grp.Key select new { Clientname = grp.Key, TotalAmountSpent = grp.Sum(r => r.Field<int>("TotalAmountSpent")) //error here, specified cast is not valid }; foreach (var grp in query) { strXML = strXML + "<set name='" + grp.Clientname.ToString() + "' value='" + grp.TotalAmountSpent.ToString() + "'/>"; } }
I get a error «Specified cast is not valid»
Part of my store procedure where I’m grabbing it from is:
SELECT ClientName, Mem_Name, Mem_Address, Mem_city, Mem_state, Sum(mv.AmountSpent) as TotalAmountSpent, (Sum(mv.AmountSpent)/ (CAST(s.TotalBusinessSales as decimal)) * 100) as PercentAmountSpent
My question is: Am I getting an error because of TotalAmountSpent is an alias?
Thanks,
N
Answers
-
TotalAmountSpent = grp.Sum(r => r.Field<int>(«TotalAmountSpent»)) //error here, specified cast is not valid }; foreach (var grp in query)
….
I get a error «Specified cast is not valid»Hello Nonabona,
Which Kind of Exception are you getting, a SQL or an InvalidCast-Exception? What data type do the column «AmountSpent» have? Amount of money is in common a decimal (money) and in your code you try to get it as an integer value; that could
cause «cast is not valid» error.
Olaf Helper
[ Blog] [ Xing] [ MVP]
-
Marked as answer by
Wednesday, October 8, 2014 5:58 PM
-
Marked as answer by
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
Hey guys,
today I have an issue with SQL Server and to keep it short and simple: I’m getting the error message «specified cast is not valid» when trying to restore an SQL Database backup to a new and clean database.
Now I’ve read that this error usually pops up when you’re trying to restore a 2012 backup to SQL Server 2008. I don’t quite really understand it, but maybe you guys can simply confirm that the Server’s OS is also playing a role in this game, because the server’s OS was upgraded from Windows Server 2008 R2 to Windows Server 2012 R2, but it still has SQL Server 2008 R2 installed. Is the OS upgrade the cause for this or am I misunderstanding things?
I’ve created the .BAK file via Veeam Backup and Replication and chose a restore point from the beginning of this month, so the server’s OS was already 2012 R2 at that time, so the only solution would be to install SQL Server 2012, right?
Thanks in advance!
SQL Server 2012 Business Intelligence SQL Server 2014 Business Intelligence — duplicate (do not use) SQL Server 2014 Developer — duplicate (do not use) SQL Server 2014 Enterprise — duplicate (do not use) SQL Server 2014 Standard — duplicate (do not use) More…Less
Symptoms
Assume that you use Microsoft SQL Server 2012 Integration Services (SSIS 2012) or SSIS 2014. When you try to load an XML document that has DateTime data type and contains time zone information, you receive the following error message:
[XML Source 1 [9]] Error: The error «Specified cast is not valid.» occurred while processing «XML Source 1.Outputs[r].Columns[<ColumnName>]».
Note The SSIS XML source component sets the data type of the column as DT_DBTIMESTAMP. It does not contain time zone information. In advanced editor, when you try to change the data type of the column for both External Columns and Output Columns to preserve the time zone information, you encounter the previously mentioned error message.
Resolution
The issue was first fixed in the following cumulative update of SQL Server.
Cumulative Update 1 for SQL Server 2014 SP1 /en-us/help/3067839
Cumulative Update 6 for SQL Server 2014 /en-us/help/3031047
Cumulative Update 5 for SQL Server 2014 /en-us/help/3011055
Cumulative Update 4 for SQL Server 2012 SP2 /en-us/help/3007556
Status
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the «Applies to» section.
Need more help?
Want more options?
Explore subscription benefits, browse training courses, learn how to secure your device, and more.
Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.