I cannot remember how to add an index for faster lookup from the table. I have a primary key, but I want to have an index for faster lookup of rows by the Component code. For a faster reading of:
select * from prices where ComponentCode like '%something%'
Look at the two last lines of the script
What am I doing wrong?
CREATE TABLE [dbo].[Prices] (
Id int IDENTITY(1,1) NOT NULL,
ComponentCode varchar(255),
Description VARCHAR(255),
PriceUnit float,
Price float
);
GO
ALTER TABLE [dbo].[Prices]
ADD CONSTRAINT [PK_Prices]
PRIMARY KEY CLUSTERED ([Id] ASC);
GO
CREATE CLUSTERED INDEX CI_Prices ON [dbo].[Prices] (ComponentCode);
GO