Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Build a script for CREATE DATABASE/FOR ATTACH

By Neil Jacobson,

It is easy enough to detach and reattach databases in SQL 2000 providing you have less than 16 files to attach.

I manage some very large databases and these sometimes need to be detached and reattached (i.e. for moving a database file from one volume to another).

I have more than 16 files to contend with on these monsters.  Since I hate repetitive typing, I use this script to generate the CREATE DATABASE FOR ATTACH statements for all our databases.

To use it, run it then take the results and run the results. Repeat with those results. The last set of results are the Create Database For Attach statements.

It is good for any number of files.

Total article views: 2442 | Views in the last 30 days: 3
 
Related Articles
FORUM

Attach a suspect database

Attach a suspect database

FORUM

Attaching Database

Problem in attaching database

FORUM

how to attach pdf file database to sqlserver 2005

database attachment

FORUM

ATTACHING DATABASE

HOW TO ATTACH DATABASE USING SQL QUERIES

FORUM

Unexpected Result in sp_send_dbmail file attachment

Unexpected Result in sp_send_dbmail file attachment

Tags
 
Contribute