如何在SQL Server中创建复合索引?

时间:2015-11-09 06:25:10

标签: sql sql-server indexing

我需要在advisor_name

上创建复合索引名Employee
where Advisor Name = Last_Name + ", " + First_Name

1 个答案:

答案 0 :(得分:1)

您可以添加持久计算列,而不是创建索引。 有关详细信息:Indexes on Computed Columns

ALTER TABLE dbo.EmployeeTable
ADD AdvisorName AS Last_Name + ', ' + First_Name PERSISTED
GO

CREATE INDEX IX_EmployeeTable_AdvisorName ON dbo.EmployeeTable
(AdvisorName)