_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › 碁煙れ企碁煙る貎朱Μ襷り鍵
豢..

select 
    c.name + '.' + a.name table_name
,   e.row_count
,   'create clustered index cix_' + d.name + ' on ' + 
    c.name + '.' + a.name + '(' + d.name + ') with (data_compression = page)' + char(13) + char(10) + 'go' + char(13) + char(10) create_index
from sys.all_objects a
    left join sys.indexes b
        on a.object_id = b.object_id     
        and b.type > 0
    inner join sys.schemas c
        on a.schema_id = c.schema_id
    inner join sys.all_columns d
        on a.object_id = d.object_id
    inner join (
        select
            object_id, sum(row_count) row_count
        from sys.dm_db_partition_stats
        group by
            object_id
    ) e
        on a.object_id = e.object_id
where b.object_id is null
and a.type = 'U'
and a.is_ms_shipped = 0
and c.name not in ('temp')
and d.name in ('std_dt', 'date_key')
order by e.row_count desc
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:52

螳讌 螻 襷 蟆讌 螻 豐 蟆螻 螳.