Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favourite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved 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: 2358 | Views in the last 30 days: 7
 
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

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones