本文介绍了SQL Server通过TSQL更改所有索引的填充因子值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将数据库暴露到bacpac文件中,才能将其导入Azure.尝试导出时,出现错误,因为任何索引都具有fillFactor值.

I have to expoet my DB into a bacpac file to import it into Azure.When I try to export I get an error because any indexes have a fillFactor value.

我已经找到了如何为所有索引设置fillFactor值,但是我不能指定0,该值必须介于1到100之间.如果在Management Studio中更改该值,则可以将其设置为0.

I've found how to set a fillFactor value for all indexes but I can't specify 0, the value have to be between 1 an 100. If I change the value in the management studio I can set it to 0.

问题是我有很多要更改的索引,我想通过tsql将fillFactor值更改为所有索引.

The problem is that I have got lots of indexes to change and I would like to change the fillFactor value to all of them trough tsql.

有什么想法吗?.

谢谢.

推荐答案

单个数据库中所有表的简单操作:

something simpler for all tables in a single database:

   select 'ALTER INDEX ALL ON ['
   + s.name+ '].['+ o.name+'] REBUILD WITH (FILLFACTOR = 99)' 
   from sys.objects o
   inner join sys.schemas s on o.schema_id = s.schema_id
   where type='u' and is_ms_shipped=0

生成语句,然后可以复制&执行.

generates statements you can then copy & execute.

这篇关于SQL Server通过TSQL更改所有索引的填充因子值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 20:55