Link to home
Start Free TrialLog in
Avatar of Amarjot Singh
Amarjot SinghFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL Server Restore Script

Evening all!

I was wondering who would be kind enough to assist me with my predicament today!

I am currently migrating an application that has a SQL instance dependance. The instance is local and I already have a script that backs it up, its extremely lengthy so if you have a script that is short and to the point that will back it up, i will take that also!!. My main requirement now is for a script that can restore the backup back into SQL Server. The backup is from a SQL Server 2005 database and the restore will be to a SQL Server 2008 database.

If there is a GUI based script I can use that I can select A)Backup - which will take all of the required information (instance name, permissions, tables etc) and another option B)Restore - which will put it all back.


I'm a SQL noob and need to get this right, which is why I am seeking your assistance!

Any help is appreciated!
ASKER CERTIFIED SOLUTION
Avatar of didnthaveaname
didnthaveaname

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Pretty easy way to detach-attach databases.
Take a look on this article, it has simple 3 steps to completa this operation:
http://www.packtpub.com/article/moving-a-database-from-sql-server-2005-to-sql-server-2008-in-three-steps

Very important note from this article as well: "The simple procedure outlined in this tutorial is adequate if you need to transfer databases from MS SQL Server 2005 to MS SQL Server 2008. If you need to selectively transfer logins, or choose objects to transfer perhaps the Copy Database Wizard may be better suited."

So make sure it's suitable to your case.
Avatar of Amarjot Singh

ASKER

Thanks Mikosha, I think i agree with didnthaveaname though. Detach-Attach introduces far too many risks than I'd be willing to take. I would say that copy would be a better method which decreased risks.

Didnthaveaname - I'll have a read over the MS notes you sent now! Thanks


EDIT:

Sorry guys - i dont think i made myself clear - I am upgrading machines from XP to Win 7 - the databases are being backed up from the XP OS and then restored on the Win 7 OS so I dont think i can use either detach-attach or copy db... i think?
Avatar of didnthaveaname
didnthaveaname

If I am understanding what you were saying, both methods should be independent of the host OS.  For instance, if I were upgrading from SQL 2005 on Server 2003 to SQL 2012 on Server 2012, this would be no problem.  The OS will limit the version of SQL Server that you can install, but beyond that, it shouldn't have any impact on either of our suggestions.  Is that what you were concerned about?
Not necessarily what I meant.

I require a solution that will backup/export the database to a network resource and then once the machine has been rebuilt and SQL server reinstalled, the restore/import will pull from the network resource and place back in place with all or as much of the metadata intact.
Avatar of Anthony Perkins
Either solution (Backup/Restore or Detach Copy Attach) can be used in your case for your user databases.  However, you will not be able to do this with your master database as they are different versions.  So you will have to script out all your logins and if you do it right (include the SID) you should not have any orphaned users.
Thanks guys, I'm going to be working on this from tomorrow onwards.