SELECT idx.name 索引名称,obj.name 表名,col.name 索引字段名
,'create index '+idx.name +' on '+obj.name +'('+col.name +')'+';' 创建索引语句
FROM sysindexes idx
JOIN sysindexkeys idxkey ON idx.id=idxkey.id AND idx.indid=idxkey.indid
JOIN sysobjects obj ON idxkey.id=obj.id
JOIN syscolumns col ON idxkey.id=col.id AND idxkey.colid=col.colid
WHERE idx.indid NOT IN(0,255) AND idx.name LIKE 'index%' AND obj.xtype='U'
--AND obj.name='sms_saleorder' --查指定表
ORDER BY obj.name,idx.name,col.name