日期:2014-05-17  浏览次数:20468 次

判断两个表的重名索引是否存在

现在在有2个婊 tab1和 tab2,对这两个表的某个属性建立索引,起名都叫tab_index

我心中要判断这两个索引是不是存在。是要分别判断tab1和 tab2的tab_index是否存在,不是判断只要存在tab_index就行,
谢谢
sql?索引?重名?判断

------解决方案--------------------
select distinct sys.tables.name, sys.indexes.name from sys.tables
inner join sys.indexes on sys.tables.object_id = sys.indexes.object_id
and sys.indexes.name = 'tab_index'
where sys.tables.name in ('tab1', 'tab2')