Search

Thursday, August 4, 2011

Set autoshrink off for all databases

use master


go

declare @Databasename varchar(128)

declare @String varchar(1000)

declare Nonsysdatabases cursor for

select [name] from sysdatabases where dbid > 4 order by [name]

open Nonsysdatabases

fetch next from Nonsysdatabases

into @Databasename

while @@fetch_status = 0

begin

set @String = 'ALTER DATABASE [' + @Databasename + '] SET AUTO_SHRINK OFF'

exec (@String)

fetch next from Nonsysdatabases

into @Databasename

end

close Nonsysdatabases

deallocate Nonsysdatabases

1 comment: