SQL Server 2012 Database restore error - sql

I am trying to restore a database backup from SQL Server 2008 R2 to SQL Server 2012 Standard. It keeps failing with the error seen here: http://screencast.com/t/UWC58GrVnWI
The web server is: Windows Server 2012
I tried renaming the file.
I tried to restore on another server
on SQL 2012 and it worked fine
I tried to restore on another
server on SQL 2008 R2 and it worked fine.
Considering above symptoms, I strongly feel the database .bak file is good. It only fails on this web server. What might be the reason?

If you read the error message you will find out that it is clear - the location is invalid. Now, if you check the path of folders and know the basics of how windows file systems work.... guess what, you find out that this is exactly true.
Fix the location. Done.

Related

Downgrade from SQL Server 2014 Express to SQL Server 2012 Express

I had SQL Server 2012 Express installed on my PC at work, but we received a file from a client the was created in SQL Server 2014. Please keep in mind, I am newbie, and I only made this mistake about 7 months ago
I tried to install SQL Server 2014 Express as another instance on my PC along with SQL Server 2012. After noticing that my new SQL Server instance did not work and my old SQL Server did not work, I looked online and found that what I did was a step up from what an ape would do. Always read before attempting an install.
After un-installing SQL Server 2014 I tried to relaunch SQL Server 2012, but it would not connect to my instance that I was able to just before.
I now get this error:
Cannot connect to STID02\SQLEXPRESS.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (.Net SqlClient Data Provider)
I have also read this thread Can't connect to SQL Server 2014 Express and found that the SQL Server service is stopped and I cannot start it, and the SQL Server Agent Service is stopped and won't start either.
I have not been effected by this until recently, I need to do some testing with DB's but I need my local instance to do the testing. I would appreciate any advice, as I am still new to SQL Server and most computer related things I would be very thankful to those how can dumb it down extremely low.
Thank you -Anthony
In short, uninstall everything, then reinstall the version you want to use.
Some configuration files must have been overwritten by SQL Server 2014. Don't worry, it can be fixed.
First: do you need any of your existing databases? I assume not as you haven't been using SQL Server for the last 7 months. If you do need some of the databases you'll find the .mdf, .ldf files in you SQL Server installation folder somewhere in the DATA folder.
Then: Uninstall SQL Server 2012 - note that since you've corrupted your current installation it might happen that some registry entries will be bad and/or services or libraries won't be removed. In that case fix the registry entries using some tool, like CCleaner, and try again to remove those programs/services.
Last step: reinstall whichever version you want. If you needed your previous databases overwriting the new mdf/ldf files should do the trick (of course while the server is not running). You can check the server's state from the SQL Server Configuration Manager or from Services.

SQL Server 2008 R2 database detaches when windows server restarts

I have a weird problem, I have a database and it was working just fine until now, every time I restart my server, the database seem to disappear. After extensive research I found out that the database just detaches, so I have to attach it again after the server restarts. I can't find a solution to this, has anyone come across it?
I did many virus scans, but nothing, so It can't be a virus.
I have also tried repairing the sql and that didn't work.
I have tried to take this database and added to my test environment, and it seem to work fine.
It is not the database itself, I'm guessing something in SQL Server that is corrupt or a virus? I have SQL Server 2008 R2 on a Windows Server 2008

SQL Server 2005 mdf file on 2012

I have a SQL Server 2005 .mdf file I need to install on a server. Can I simply install SQL Server 2012 Express and attach the .mdf file without any issues, or should I stick to 2005 Express to eliminate any issues that may arise?
I should also add it needs to support a ASP.NET 3.5 website.
Cheers
If you have all files (mdf, ldf and potentially multiple ndf) and the database was cleanly shut down, you won't have an issue attaching to 2012.
If you have only the mdf it might work but it could also fail.
Either way, first take a backup of the files you have.
That being said, make sure you don't use any features that changed between 2005 and 2012 (see http://technet.microsoft.com/en-us/library/ms143532.aspx for details)

SQL 2005 express with 2008 express compatibility

I installed VS 2008 without SQL 2005, then I installed SQL 2008, then I needed 2005 express so I reinstalled VS checking the SQL feature.
The installation went OK, however I still cannot open mdf files from VS.
I think there is no 2005v instance installed.
When I dbl-click an mdf file in VS I get the following message:
Connections to SQL Server Files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL: http:go.microsoft.com/fwlink/?linkID=49251.
Update
I tried to attatch it, it doesn't work.
When I tried to attach it to SQL 2008 it doesn't work, when I try to attach it to SQL inside VS, I get the following error message:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I suspect that SQL 2005 doesn't have any instance at all.
I opened SS manager and I didn't see any installed instances.
I don't know how to install an instance, or else if there is a way to open with 2008 tell me.
Any help will be really appreciated!
You don't just "open" an mdf file in Visual Studio - you need to "attach" the file to your SQL Server instance, then access it by creating a SQLConnection (System.Data.SQLConnection) from your VS application. See here for more info on attaching databases (note the FOR ATTACH option), and here's a good intro on accessing SQL Server data using a SQLConnection.
Oh, and if you should happen to see anything about "user instances", pretend you didn't. It was supposed to make auto-attaching databases easy (in fact, attaching databases isn't all that hard anyway). Microsoft is warning that the feature will be discontinued in later releases of SQL Server, so you're better off just learning the "right" way to do it.

Importing Sql Server 2005 database into Sql Server express 2008

Is there any way to import a database backup from 2005 into 2008 express edition. What I've had to resort to is doing a script the database, then import all the data through DTS. Whenever I tried to import straight from a backup file it says something about not being to import into a new version of sql server or I'll get the below error.
title: Microsoft SQL Server Management Studio
Specified cast is not valid. (SqlManagerUI)
SQL 2005 backups should be restored on 2008 without problem (have done that myself many times). What exact error message did you got about versions?
The other error (Specified cast is not valid) seems to be Management Studio error, not server error. Have you full rights on 2008 server?
Look at this question - any-reason-to-have-sql-server-2005-and-2008-installed-on-same-machine - there are talked both about restoring SQL2005 backups and about attaching SQL2005 data files.
(Of course you cannot attach production databases. To attach non-production databases just detach them, make file level copy of these and attach copies to new server. Orginal files need to attach to original server too :))
I imagine that you are in a development process where your data will have to be regularly copied to you SQL 2008 server.
You can then think of configuring a replication between the SQL 2005 server (publisher) and SQL Server Express 2008 (suscriber). Depending on your requirements, you have the choice between snapshot or merge replication. If no update is done on the suscriber side, go for snapshot.
Once you want to have your 2008 server running independantely from the publisher, just delete the replication.
A valid SQL Server 2005 Express backup file should be able to be restored to SQL Server 2008 Express. If the SQL Server 2005 backup is from the Standard or Enterprise versions, you might hit problems restoring it to Express. The user context that the backup was created from should not affect the ability to restore that backup.
One thing you can do is to try running the restore operation as a verification, without actually trying to run the restore. That will tell you if the backup file is valid or not. You can use this syntax:
RESTORE VERIFYONLY
FROM yourbackupfile.bak
If possible, I would also suggest trying to simply detach the original database from 2005 and then attaching the file at the 2008 edition.
While I have only tried this with the standard edition myself, it has worked perfectly with the compatibility mode keeping the database set to 2005.
Have you tried running the Upgrade Advisor http://www.microsoft.com/download/en/details.aspx?id=11455 - it might be able to highlight problems for upgrading the original database.