程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SqlServer數據庫 >> 關於SqlServer >> sql server批量修改用戶數據庫自動增長

sql server批量修改用戶數據庫自動增長

編輯:關於SqlServer

if object_id('pr_modify_file_add') is not null

drop proc pr_modify_file_add

go

create proc pr_modify_file_add

@in_name nvarchar(256)

as

declare @d_name varchar(20)

set @d_name=@in_name

execute

(

'alter database '+@d_name+' modify file(name='+@d_name+', filegrowth=200MB) '

)

go

declare @databasename nvarchar(256)

declare cur01 cursor for

select name from sys.databases

where name not in ('master','tempdb','model','msdb','reportserver',& #39;ReportServerTempDB')

open cur01

fetch next from cur01 into @databasename

while @@fetch_status=0

begin

exec pr_modify_file_add @databasename

fetch next from cur01 into @databasename

end

close cur01

deallocate cur01

go

if object_id('pr_modify_file_add_log') is not null

drop proc pr_modify_file_add_log

go

create proc pr_modify_file_add_log

@in_name nvarchar (256),

@dlog nvarchar(256)

as

declare @d_name nvarchar(20)

set @d_name=@in_name

execute

(

'alter database '+@d_name+' modify  file (name='+@dlog+', filegrowth=400MB)'

)

go

declare @databasename nvarchar(256)

declare @string nvarchar(256)

declare @re nvarchar(256)

declare cur01 cursor for

select name from sys.databases

where name not in ('master','tempdb','model','msdb','reportserver',& #39;ReportServerTempDB')

open cur01

fetch next from cur01 into @databasename

while @@fetch_status=0

begin

set @string='select @a=name from '+@databasename +'.sys.database_files where type=1'

exec sp_executesql @string, N'@a nvarchar(200) output',@re output

exec pr_modify_file_add_log @databasename,@re

fetch next from cur01 into @databasename

end

close cur01

deallocate cur01

go

查看本欄目

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved