SQL Server 2005 - How to restore multiple backups (.bak) - sql

I need to restore near 40 databases (.bak files) to a new SQL Server 2005 instance.
Manually, from SQL Server Management Studio, takes a long time.
¿How can I restore automaticaly all the .bak files to the new Server?
The new SQL Server instance is empty.
Thanks for the help!

SQL Server backups can be scripted like, literally, everything else. You can find out about it on Google. Search for "SQL Server restore statement".
Let me quote commenter Murph who had a very nice idea:
Its easier than that to get the script - when you do a restore with
SQL Server Manager you get the option to create a script instead of
run the restore, that will give you the basis from which you can build
all the scripts you need.

Related

How can I restore a database in SQL Server 2012 from SQL Server 2012 Express?

I am having problems to restore a database from SQL Server 2012 and SQL Server 2012 Express to my SQL Server 2012 where I need this db to do some tests.
When I select the .bak file it is nothing shown in the 'backup sets to restore' area below. This is the newest backup I have made.
Is there any way to make it happen? even settings that I must have to do?
I have read that there is impossible to restore from the a higher SQL Server version? Is that true?
Best Regards,
Weslley.
What do you see (if anything) when you run this command:
USE [master]
RESTORE HEADERONLY
FROM DISK = N'your-drive-and-path-to-the-backup-file.bak'
WITH NOUNLOAD;
GO
Does that show you anything? Does it cause an error? If so: what error?
Guys thanks very much for the help you gave.
I did not know that when I go to the button Help/About I was seeing the version of the SSMS and not of the DataBase..
So in both case i was trying to restore a database from a higher version, so it could not work properly.

How to get Bak file or MDF without close connection sql server?

i have a database (ms 2005 server). How to get bak or mdf file BUT; it is running windows 2008 server also over 600 stuffs is using this DB. if i get .bak file or mdf. i must close connection. i dislike it. is there any useful methods or method to get BAK or MDF? this method may be a EXE or ms sql property or tool?
You certainly do not need to drop users to make a backup. Just right click your database in SQL Server Management Studio -> Tasks -> Back Up
Even better, setup a regular backup schedule.
Here's further instructions on backing up SQL Server 2005.

backing up sql database from microsoft sql server

i just want to ask if how can i backup my database from sql server 2005 using sql server management studio express? i want a backup it using sql file (.sql and not .bak or .mdf) from creating database (if not exist), tables and even the records on the table..thanks in advance :)
This is not possible with one command. You can script single objects, but I'm not aware of a way to do this in SSMS. We use SQL Compare from redgate here - it's pretty great.
You can try powershell.
Docs here.

Backup DB on Remote SQL Server Express

I need to create a TSQL script to backup a db on a remote SQL Server Express (2005). I have a SQL Server 2005 on another box. Not sure how I can run the script from this SQL Server 2005 to do the backup job.
The script is something like this:
RESTORE DATABASE [myDB] FROM DISK = N'C:\Tmp\myDB.bak' WITH FILE = 1,
NOUNLOAD, STATS = 10
Actually, I tried this SQL script on the remote SQL Server Express by using SQL Server Management Studio Express and it runs OK. The reason I ask this question is that I can schedule a job on SQL Server 2005, but I cannot create a schedule job on the remote SQL Server Express.
Another way, I think, is to create a SQL SP on the SQL Server Express first. Then I'll write a simple console application to connect to the SQL and run the SP as a Windows Scheduled job.
There is no need to do this by TSQL. SQL Server (also Express) includes a utility called sqlmaint.exe, which allows you to perform backup operations on a local or remote SQL server. Simply write a batch file calling sqlmaint with the correct command line parameters (documentation) and put this batch file in Windows Scheduler.
If you still want to do it by TSQL, SQL Server also contains osql.exe, which allows you to execute arbitrary SQL statements on a local or remote server. Again, you can automate it using simple batch files.
EDIT: If you want to call the TSQL script using your own application, it might be helpful to know about your programming language or data access technology of choice.

Restore SQL Server 2008 DB *to* SQL Server 2005

Got myself in a bit of a pickle here ... working on a CMS project, under the assumption that sql server 2008 was greenlighted as the db of choice. Well it wasn't, we now have to backport all of our content out SQL Server 2008 and into SQL Server 2005.
A simple backup/restore procedure yields: "RESTORE HEADERONLY is terminating abnormally. (Microsoft SQL Server, Error: 3241)".
Unfortunately, exporting the data to an excel spreadsheet yields multiple OLE errors which I believe is actually a problem in the db of the cms.
Does anyone out there have other approaches they would like to recommend for this task? Thanks in advance
Use RedGate:
tool for comparing and deploying SQL Server database contents.
You can work with live databases, backups, or SQL scripts in source control. Damaged or missing data can be restored to a single row, without the need for a full database recovery.
SQL Data Compare helps you compare and deploy changes quickly, simply, and with zero errors...
There is no way to do this by default. You can generate scripts for 2008 database on 2008 server and then execute these scripts on 2005 version. Note that you’ll have to manually review scripts and remove all parts that are unique to 2008 version.
Another way is to use third party tools such as Red Gate or ApexSQL Diff (move schema) and ApexSQL Data Diff (move data).
Use the Generate SCripts to create the database and schema and ensure you target SQL Server 2005 and script data.
Rather than do a backup and restore you might try using SQL 2005's Import/Export Data wizard.
http://support.microsoft.com/default.aspx?scid=kb;en-us;314546
http://msdn.microsoft.com/en-us/library/ms140052(SQL.90).aspx
I've just hit the same problem and here is how I worked around it.
The problem was to copy a database from an operational SQL Server 2008 database to a new SQL Server 2005 database.
I scripted the database using Management Studio on the 2008 server. I only scripted the database design, not the data. I should add also that the DB only has tables and indexes, so I haven't tried this with any cleverer objects although I can't think why they wouldn't work.
On the 2005 server I created a new database by hand and then ran the script to set up all the tables and indexes.
The in Management Studio back on the 2008 server I used the Export Data wizard to export the data from the 2008 server to the 2005 server. It's currently running and seems quite happy moving the data.
Once all the data is across I'll have a couple of small things left to do - create the users and set-up the security in the 2005 DB, but all-in-all it doesn't look like a bad way of doing it. It's not quite point-and-click but it's not too strenuous.
So it seems that the Copy Database wizard won't work (I think because the package ultimately runs on the 2005 server and 2005 Management Studio can't talk to 2008) but the Export Data wizard is quite happy moving data ... as long as the DB already exists on the target server.
Hope that's useful.
It's not possible to restore to previous versions in SQL Server
Is there no SQL 2005 backup around? Otherwise you really are limited to export the entire database in 2008, and re-import back into 2005, or the Import/Export wizard in 2008
Or rely on 3rd party tools. e.g. Red Gate Data Compare is able to sync. the DATA between 2 servers/databases
I only use mysql but can you export your data into sql statments, and then import then into sql2005? Just a thought..
I faced a similar problem (sql 2005 to sql 2000), and found that I happened to have a blank database at the older version. I used bcp.exe to copy all the data.
check this link click here
You can create the database script in sql server 2008 and you can use it sql server 2005 and lower version....