Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server / March 2008

Tip: Looking for answers? Try searching our database.

Attach & Detach Multiple Databases

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JosephV - 07 Mar 2008 15:43 GMT
SQL Server 2000 Standard

I need to move multiple databases (about 20) from the C partition to the E
partition. I'm familiar with sp_detach_db and sp_attach_db scripts and is OK
for a handful of databases but tedious with 10 or more databases. My manager
suggested "looping" or something like that. In other words he wants a method
to move these databases in an efficient script. I looked into using SSEUTIL
but that gives me a "mssql$sqlexpress is not installed" error message,
looking for SQL Server Express 2005. I'm sure what I'm asking isn't something
new.
TheSQLGuru - 07 Mar 2008 19:19 GMT
check out master.dbo.sysaltfiles for file paths.  then you can dynamically
create the detach/attach scripts using sysdatabases and sysaltfiles.

think like this:

select 'sp_detach ... ' + name + '
go'
from sysdatabases

I use such constructs all the time to create scripts to execute.

Signature

Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net

> SQL Server 2000 Standard
>
[quoted text clipped - 11 lines]
> something
> new.
JosephV - 07 Mar 2008 19:54 GMT
Thanks. I'll research your suggestion.

> check out master.dbo.sysaltfiles for file paths.  then you can dynamically
> create the detach/attach scripts using sysdatabases and sysaltfiles.
[quoted text clipped - 22 lines]
> > something
> > new.
Uri Dimant - 09 Mar 2008 13:39 GMT
Hi
http://dimantdatabasesolutions.blogspot.com/2007/03/detaching-and-attaching-data
base.html


> Thanks. I'll research your suggestion.
>
[quoted text clipped - 27 lines]
>> > something
>> > new.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.