怎么创建表名为参数的索引呢?
创建索引的sql为:
create index [索引名] ON 表名
其中表名是参数,这个语句改怎么写?
举例:
DECLARE @tabName varchar(50)
set @tabName = 'student_' + (SELECT (RIGHT(YEAR(GetDate()), 4) + RIGHT(100+Month(GetDate()), 2) + RIGHT(100+day(GetDate()), 2)));
IF EXISTS (SELECT * FROM dbo.SysObjects WHERE id = object_id(@tabName)
AND OBJECTPROPERTY(ID, 'IsTable') = 1)
create index index_111 on @tabName(name)
ELSE
PRINT '不存在'