|
楼主 |
发表于 2018-1-28 10:48
|
显示全部楼层
Dim StrSQL$, Arr, i%, JoinSQL$
Dim SQL$
'所有用户表,查有否有单号与序号的表
'这是所有有单号同时又有序号的表not
StrSQL = "select name from sysobjects where xtype='U' " & _
" and id in (select distinct id from syscolumns where name='单号') " & _
" and id not in (select distinct id from syscolumns where name='序号') " & _
" and name in(select name from sysobjects where xtype='U')"
Arr = RsToArr(StrSQL)
For i = LBound(Arr) + 1 To UBound(Arr)
'所有流程表加入单号序号 且名为Order的索引
SQL = " IF EXISTS (SELECT * FROM dbo.sysindexes " & _
" WHERE id = OBJECT_ID(N'[dbo].[" & Arr(i, 1) & "]') AND name = N'singleorder') " & _
" DROP INDEX [dbo].[" & Arr(i, 1) & "].[singleoorder]" & _
" ; CREATE NONCLUSTERED INDEX [singleoorder] ON [dbo].[" & Arr(i, 1) & "]([单号] ) "
JoinSQL = JoinMySQL(JoinSQL, SQL)
Next
Call ExecuteSQL(JoinSQL, "重建所有只有单号的表的索引", 1)
上面的做法完全能达到要求,只是想用一段SQL语句能否达到要求呢
|
|