Restoring the Database backup in SQL Server 2008 R2 - sql-server-2008-r2

I am using SQL Server 2008 R2. While restoring a database backup I'm getting an error
Specified cast is invalid
Any help will be greatly appreciated. Thanks in advance.

This was due to .BAK file corruption during FTP transfer (transfer mode is set to ASCII).
Always, remember to set FTP transfer mode to BINARY while transferring database .BAK file.
try to do this using TSql...
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 should be overwritten.

Related

Export Active Directory data from SQL Server 2008 R2

Is there any way to extract Active Directory data from SQL Server 2008 R2 in order to restore it on another SQL Server 2008?
Thanks in advance
If you mean you need to transfer logins then I always use sp_help_revlogin.

How to set bin path of sql server 2008 r2

I have installed 3 MSSQL Server versions, 2005,2008R2 and 2012. I want to set bin path of SQL Server 2008R2 version.
How to find bin path of SQL Server 2008 R2 version?
I want to set bin path of SQL Server 2008 R2 version. How to find bin path of SQL Server 2008 R2 version?
You don't set Bin path for SQL Server. The BINN directly is set by SQL Server at location(assuming C as System drive)
C:\Program Files\Microsoft SQL Server\MSSQLXX.MSSQLSERVER\MSSQL\Binn
No mater where you install SQL Server the BINN directory would always go to C drive assuming C is your OS drive.
BINN is directory where binary files related to SQL Server are dumped that is internal to SQL Server application and you should NOT change it or try to change it you would mess up the installation.
The default installation directories has been documented by Microsoft BOL team In this Link
This is what I understood from your question, if you want to clarify further edit your question and add more details

SQL server 2008 R2 cannot attach database

Basically I want to attach .mdf file which located in D(you can see it from the picture), But then I got this error.
Any idea why this happened and how to fix it?
There may be two solutions for that
1) You may start the sql server management studio application by right clicking and selecting the "Run as administrator" to run it and then try to attach the database in D:
1) You may put your database in the default directory of your database like C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA etc ....

How to restore SQL Server 2008 R2 backup to a LocalDb 2012

I have a backup of a database (.bak) created ​​in SQL Server 2008 R2.
To test some features, like to import this backup to LocalDB (2012).
When I click on Restore and select the database the following error occurs:
Property MasterDBLogPath is not available for Information 'Microsoft.SqlServer.Management.Smo.Information'. This property may not exist for this object, or may not be retrievable due to insufficient access rights. (Microsoft.SqlServer.Smo)
You need to add the following 3 registry keys (run/regedit):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\MSSQLServer\DefaultData,
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\MSSQLServer\DefaultLog,
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\MSSQLServer\BackupDirectory
With an existing folder name as value (where you have write access), e.g. "C:\Databases".
Please have a look at the excellent walkthrough under http://www.roelvanlisdonk.nl/?p=2896 (which is where I have copied the answer from).

Error: Specified cast is not valid. (SqlManagerUI)

I have a backup from database in SQL Server 2008 R2.
When I want to restore this backup to SQL Server, I get this error:
"Error: Specified cast is not valid. (SqlManagerUI)"
How to I resolve this error?
Thanks.
This would also happen when you are trying to restore a newer version backup in a older SQL database. For example when you try to restore a DB backup that is created in 2012 with 110 compatibility and you are trying to restore it in 2008 R2.
There are some funnies restoring old databases into SQL 2008 via the guy; have you tried doing it via TSQL ?
Use Master
Go
RESTORE DATABASE YourDB
FROM DISK = 'C:\YourBackUpFile.bak'
WITH MOVE 'YourMDFLogicalName' TO 'D:\Data\YourMDFFile.mdf',--check and adjust path
MOVE 'YourLDFLogicalName' TO 'D:\Data\YourLDFFile.ldf'
Sometimes it happens because of the version change like store 2012 db on 2008, so how to check it?
RESTORE VERIFYONLY FROM DISK = N'd:\yourbackup.bak'
if it gives error like:
Msg 3241, Level 16, State 13, Line 2
The media family on device 'd:\alibaba.bak' is incorrectly formed. SQL Server cannot process this media family.
Msg 3013, Level 16, State 1, Line 2
VERIFY DATABASE is terminating abnormally.
Check it further:
RESTORE HEADERONLY FROM DISK = N'd:\yourbackup.bak'
BackupName is "* INCOMPLETE *",
Position is "1",
other fields are "NULL".
Means either your backup is corrupt or taken from newer version.
I had a similar error "Specified cast is not valid" restoring from SQL Server 2012 to SQL Server 2008 R2
First I got the MDF and LDF Names:
RESTORE FILELISTONLY
FROM DISK = N'C:\Users\dell laptop\DotNetSandBox\DBBackups\Davincis3.bak'
GO
Second I restored with a MOVE using those names returned:
RESTORE DATABASE Davincis3
FROM DISK = 'C:\Users\dell laptop\DotNetSandBox\DBBackups\Davincis3.bak'
WITH
MOVE 'JQueryExampleDb' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Davincis3.mdf',
MOVE 'JQueryExampleDB_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Davincis3.ldf',
REPLACE
GO
I have no clue as to the name "JQueryExampleDb", but this worked for me.
Nevertheless, backups (and databases) are not backwards compatible with older versions.