您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

重建当前数据库中的所有索引

2025/8/10 16:37:28发布14次查看
重建当前数据库中的所有索引 无 declare @sql nvarchar(500) declare rebuildalltableindexes cursorread_onlyfor select quotename(schema_name(tbl.schema_id)) + '.' + quotename(tbl.name) tb_name,quotename(i.name) idx_namefrom sys.tables as tblinne
重建当前数据库中的所有索引
declare @sql nvarchar(500) declare rebuildalltableindexes cursorread_onlyfor select quotename(schema_name(tbl.schema_id)) + '.' + quotename(tbl.name) tb_name, quotename(i.name) idx_namefrom sys.tables as tblinner join sys.indexes as i on ( i.index_id > 0 and i.is_hypothetical = 0 ) and (i.object_id = tbl.object_id) declare @tb_name nvarchar(255), @idx_name nvarchar(255)open rebuildalltableindexes fetch next from rebuildalltableindexes into @tb_name, @idx_namewhile (@@fetch_status -1)begin if (@@fetch_status -2) begin set @sql = n'alter index ' + @idx_name + n' on ' + @tb_name + n' rebuild partition = all with (pad_index = off, statistics_norecompute = off, sort_in_tempdb = off, online = off, allow_row_locks = on, allow_page_locks = on, fillfactor = 90)' exec sp_executesql @sql end fetch next from rebuildalltableindexes into @tb_name, @idx_nameend close rebuildalltableindexesdeallocate rebuildalltableindexesgo
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product