通过sql语句直接获取表的对应索引的脚本,就象在 企业管理器中 编写索引脚本为 。
如索引名称为:IX_AccAgeGroup_RecoType
获取的脚本为:
/****** Object: Index [IX_AccAgeGroup_RecoType] Script Date: 09/24/2015 11:32:19 ******/
IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AccAgeGroup]') AND name = N'IX_AccAgeGroup_RecoType')
DROP INDEX [IX_AccAgeGroup_RecoType] ON [dbo].[AccAgeGroup] WITH ( ONLINE = OFF )
GO
/****** Object: Index [IX_AccAgeGroup_RecoType] Script Date: 09/24/2015 11:32:19 ******/
CREATE NONCLUSTERED INDEX [IX_AccAgeGroup_RecoType] ON [dbo].[AccAgeGroup]
(
[RecoType] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
------解决思路----------------------
网上有现成的