zoukankan      html  css  js  c++  java
  • 批量导出表索引

     

      批量导出索引:

     

               SELECT   'CREATE  INDEX  ' + [name] 
                        + ' ON [' + OBJECT_NAME(object_id+ '] ('
                        + REVERSE(SUBSTRING(REVERSE(( SELECT    name
                                                                + CASE WHEN sc.is_descending_key = 1 THEN ' DESC'
                                                                       ELSE ' ASC'
                                                                  END + ','
                                                      FROM      sys.index_columns sc
                                                                JOIN sys.columns c ON sc.object_id = c.object_id
                                                                                      AND sc.column_id = c.column_id
                                                      WHERE     OBJECT_NAME(sc.object_idIN (SELECT sysno from IC_History.dbo.temp)
                                                                AND sc.object_id = i.object_id
                                                                AND sc.index_id = i.index_id
                                                      ORDER BY  index_column_id ASC
                                                    FOR
                                                      XML PATH('')
                                                    )), 28000)) + ') With (Online=On)'
               FROM     sys.indexes i
               WHERE    OBJECT_NAME(object_idIN  ('表名' )
                        AND CASE WHEN 1 = 1
                                      AND is_primary_key = 1
                                      AND type = 1 THEN 0
                                 ELSE 1
                            END = 1
                       -- AND is_unique_constraint = 0
                       -- AND is_primary_key = 0

  • 相关阅读:
    编程总结3
    编程总结2
    编程总结1
    对我影响最深的老师
    自我介绍
    BFC 规则及解决的问题?
    简述 CSS 精灵图原理,及优缺点?
    等高布局、圣杯布局、双飞翼布局的实现原理
    CSS 基本选择器有哪些?
    CSS 引入方式有哪些?
  • 原文地址:https://www.cnblogs.com/zping/p/2245807.html
Copyright © 2011-2022 走看看