AttachDB helps to make simple administration tasks on SQL Server databases without SQL Server enterprise manager. It also checks that SQL Server has latest service pack installed. Utility can be used with command line arguments in bat files and setup scripts. Supports browsing for file on remote server.
AttachDB require Visual Basic 6.0 runtime, ADO 2.1 or later and mscomctl.ocx activeX control (typically this is a part of VB6 runtime). If you running AttachDB on operation system earlier then Windows XP or Windows 2003 - you can install using full setup. Else it is enough just to copy AttachDB.exe to any folder on your local disk.
Working with AttachDB
At first start AttachDB tries to connect to your local SQL server with sa login and empty password or using NT security, if it fails - dialog to enter proper login and password will appear. After utility connects to SQL server it read its version and display service pack version installed. If SQL server has non-recent service pack version installed - its version will appears in red. If SQL server is not running or connection is very slow - connection procedure can tame some time. For local server timeout settings is 5 sec, for remove server - 30 seconds.
After connection to SQL Server established - you can either select existing database in combo box, or enter new database name to attach it or restore.
Attach/Detach. You can attach database with both database files- mdf and ldf or providing only one mdf file, then textbox with path to ldf file should be empty. While detaching - you can find where files are store if you click on a button with error. If database in use during detach process - you can disconnect all users with corresponding button.
Backup/restore - you can backup and restore database, database log and both. If database in use during backup or restore process - you can disconnect all users with corresponding button.
Run script - this function used to run T-SQL script from text file on selected database.
DB settings - you can change database recovery model and shrink database.
In case you operate with big databases and this takes more then 30 seconds - you have to set bigger command timeout in corresponding textbox.
Working from command line
AttachDB supports following command-line arguments:
- /StartSQL - Start SQL server on local machine
- /Server MySQLServer - specifies which SQL server to use
- /Database MyDatabase - specifies database. This is required for any option besides
- /MDFPath "C:\File.MDF"
- /LDFPath "C:\File.LDF"
- /DatabaseExist - return 1 if Database exists on server
- /NoAutoUpdate - disable auto update over internet