我仍是写个小例子:
USETEMPDB
GO
IFOBJECT_ID(TB)ISNOTNULLDROPTABLETB
GO
CREATETABLETB(COL1INT,COL2INT,COL3INT,COL4INT)
GO
CREATECLUSTEREDINDEXINX_TB_COL1_COL2ONTB(COL1,COL2)
GO
CREATEINDEXINX_TB_COL3ONTB(COL3)
GO
INSERTINTOTB
SELECTT1.number,T2.number,CASEWHENT1.number%3=0THENNULLELSET1.numberEND,T1.NUMBER+T2.number
FROMMASTER..spt_valuesT1
INNERJOINMASTER..spt_valuesT2ONT1.number=T2.number-1
GO
SELECTCOUNT(*)
FROMTB