Search This Blog

Tuesday, October 14, 2008

How to detach All user databases ?

SQL 2005

===========

select 'EXEC sp_detach_db @dbname = N'''+RTRIM ( name)+''','''+'true''' from sys.sysdatabases where dbid>6 and name not like 'distribution'





SQL 2000

==========

select 'EXEC sp_detach_db @dbname = N'''+RTRIM ( name)+''','''+'true''' from sysdatabases where dbid>4 and name not like 'distribution'

hozzzaaat ..

No comments: