--script to generate the attach
statement for a database
declare @dbname as sysname
declare @sql as varchar(1000)
declare @n as integer
declare @filename as sysname
set @dbname = db_name()
declare curs cursor for
select rtrim(filename) from sysfiles
open curs
fetch next from curs into
@filename
set @n = 0
print '--ATTACH SCRIPT FOR ' + @dbname
print 'sp_attach_db @dbname = N'''
+ @dbname + ''','
while @@fetch_status = 0
begin
set @n = @n + 1
print '@filename' + cast(@n as varchar) + ' = ''' + @filename + ''','
fetch next from curs into
@filename
end
close curs
deallocate curs
No comments:
Post a Comment