Tuesday 24 May 2016

SQL Server - Automated restore script

I am often in a situation when I need to restore a few databases at a time, this being either to push to development, for DR testing or for ad hoc restores.

Using the GUI to do this for more than a few databases at a time can be very cumbersome so I started on a script to alleviate some of this.

My goals for this script are:

- Able to quickly generate restore scripts for multiple databases
- Automate regular DR testing

You simply point the script at your backup directory and it will give you the scripts to run to restore your databases (Fulls, Diffs and Logs) to the most recent backup.

The script uses the undocumented master.sys.xp_dirtree to get the files from disk without the need to use xp_cmdshell.

The script is still in its infancy and has a long way to go but in its current form it will print the restore scripts to the screen.

Updated script - now works with SQL Server versions up to SQL Server 2019

Comments, suggestions and improvements are welcome.
Google Drive Link
Database Restore generator v0.4.sql

Wednesday 18 May 2016

Import BDE Paradox Database into SQL Server (Or anything really)

Import BDE Paradox Database into SQL Server (Or anything really)

I was recently asked to take a look at a Paradox Database with the aim of migrating it over to SQL Server.

You will first need to make sure you have the BDEInfoSetup Utility installed (Download can be found here http://www.willneumann.net/2008/09/bdeinfosetup-utility-download/).

Once installed you will need to create a DSN

- Navigate to C:\Windows\SysWOW64
- Open odbcad32.exe
- Create DSN using the "Microdoft Paradox Driver (*.db)" and point it to the folder that contains all of your *.db files

Once done you can use SSIS to push the data anywhere you need.


While this is great in that I am able to access all of the tables when there are 100 plus tables to migrate this becomes time consuming.

I stumbled across a great article written by Jerome (https://psycodedeveloper.wordpress.com/2013/01/25/c-application-to-import-paradox-data-to-sql-server/) who created a nice C# application that will import everything into SQL Server.