Sunday, March 25, 2012

Attach & Detach Multiple Databases

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.
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.
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"JosephV" <JosephV@.discussions.microsoft.com> wrote in message
news:AEF01BE7-44DF-4DEC-90B1-285AEDA95069@.microsoft.com...
> 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.
|||Thanks. I'll research your suggestion.
"TheSQLGuru" wrote:

> 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.
> --
> Kevin G. Boles
> Indicium Resources, Inc.
> SQL Server MVP
> kgboles a earthlink dt net
>
> "JosephV" <JosephV@.discussions.microsoft.com> wrote in message
> news:AEF01BE7-44DF-4DEC-90B1-285AEDA95069@.microsoft.com...
>
>
|||Hi
http://dimantdatabasesolutions.blogspot.com/2007/03/detaching-and-attaching-database.html
"JosephV" <JosephV@.discussions.microsoft.com> wrote in message
news:A173C0D1-AB94-4BEA-AC8A-F81E88744A6F@.microsoft.com...[vbcol=seagreen]
> Thanks. I'll research your suggestion.
> "TheSQLGuru" wrote:
sql

No comments:

Post a Comment