Return the top 5 of each kind of record
You have three problems that I can see. Two performance, and one logic. In least-to-most significant order:

Performance: You should no use the NOT LIKE 'NOT FOUND' statement, it should be  &lt;&gt; 'NOT FOUND'
Potential logic problem: You should have an order-by clause on the inner select for the TOP 5 ... otherwise, what TOP 5 are you getting?
Performance: Using declare @table... syntax has different performacne to create table #table ... For example, this blog entry shows some real differences. I recommend trying the same query with a #temp table instead.

Also, read up on this SO Answer: SQL Server tables: what is the difference between @, # and ##?
Edit:
It was almost too obvious to ask... but, you have done the two most basic items... right?

an index on the [PartNumber].[PatternCode]
updated all table statistics

... right?