您好我正在使用 SQLServer2008。我想知道 SQLServer 中的索引是什么以及如何使用它?
这是我的查询的一部分..我怎样才能给出索引?非常感谢..
DECLARE @TableMember TABLE
(
BrokerId INT ,
RankId INT ,
MemberId INT ,
InstallmentId INT ,
PlanId INT ,
IntroducerId INT ,
Date DATETIME ,
SelfAmount DECIMAL(18, 2) ,
UnitAmount DECIMAL(18, 2) ,
SpotAmount DECIMAL(18, 2) ,
ORBPercentageSelf DECIMAL(18, 2) ,
ORBPercentageUnit DECIMAL(18, 2) ,
ORBAmountSelf DECIMAL(18, 2) ,
ORBAmountUnit DECIMAL(18, 2) ,
IsSelfBusiness BIT ,
Mode VARCHAR(50) ,
InstallmentNo INT ,
PlanType VARCHAR(50) ,
PlanName VARCHAR(50) ,
CompanyId INT ,
CscId INT ,
Year VARCHAR(50) ,
CreateDate DATETIME ,
ModifideDate DATETIME
)
INSERT INTO @TableMember
( BrokerId ,
RankId ,
MemberId ,
InstallmentId ,
PlanId ,
IntroducerId ,
Date ,
SelfAmount ,
UnitAmount ,
SpotAmount ,
ORBPercentageSelf ,
ORBPercentageUnit ,
ORBAmountSelf ,
ORBAmountUnit ,
IsSelfBusiness ,
Mode ,
InstallmentNo ,
PlanType ,
PlanName ,
CompanyId ,
CscId ,
Year ,
CreateDate ,
ModifideDate
)
( SELECT BrokerId ,
RankId ,
MemberId ,
InstallmentId ,
PlanId ,
IntroducerId ,
Date ,
SelfAmount ,
UnitAmount ,
SpotAmount ,
ORBPercentageSelf ,
ORBPercentageUnit ,
ORBAmountSelf ,
ORBAmountUnit ,
IsSelfBusiness ,
Mode ,
InstallmentNo ,
PlanType ,
PlanName ,
CompanyId ,
CscId ,
Year ,
CreateDate ,
ModifideDate
FROM dbo.MemberBusiness AS mb
WHERE ( @CscId = 0
OR mb.CscId = @CscId
)
AND mb.Date >= @StartDate
AND mb.Date <= @EndDate
AND mb.RankId >= @FromRankId
AND mb.RankId <= @ToRankId
)