SQL Performance Query Speed up; Million Records
There are a million records in table.
How to speed up query, it takes two 3mins to process this one query.
ALTER PROCEDURE [dbo].[prc_GetDistinctConcatStringColorUnitsOnly]
AS
BEGIN
IF OBJECT_ID ('dbo.CONCAT_COLOR_UNITS_ONLY', 'U') IS NOT NULL
DROP TABLE dbo.CONCAT_COLOR_UNITS_ONLY;
select distinct ([COLOR].[TEST_SET_IDENTIFICATION] + ' ' +
[COLOR].[IDENTIFICATION] + ' ' +
[COLOR].[SERIAL_NUMBER] + ' ' +
[COLOR].[PART_NUMBER] + ' ' +
[COLOR].[CODE]) AS CONCAT, *
into dbo.CONCAT_COLOR_UNITS_ONLY
FROM dbo.COLOR
where SERIAL_NUMBER not like ('%[^0123456789]]%' )and LEN(SERIAL_NUMBER)= 6 and SERIAL_NUMBER NOT LIKE '%[A-Z]%' and COLOR_CATEGORY not like 'RED'
END