Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Most efficient in string exact match.

Author  Topic 

Humate
Posting Yak Master

101 Posts

Posted - 2011-09-22 : 07:21:27
Hi all,

I'm after some advice on the best approach to complete an exact match on a string. I have numbers stored as a string (not by choice!), and need to match part of the string, exactly.

I have used a like search, but i don't want similar results, only where the number matches exactly somewhere in the string.

I'm doing this on a lot of data, so need to find an efficient solution. Any help appreciated

DECLARE @test TABLE

(ID INT,
NumberInTextString NVARCHAR(30))

INSERT @test

SELECT 1, '016723458701674563450167234587' UNION ALL
SELECT 2, '016723458601674563480167234589' UNION ALL
SELECT 3, '016723458101674563430167234585'

SELECT * FROM @test
WHERE NumberInTextString LIKE '%0167234587%'



Kristen
Test

22859 Posts

Posted - 2011-09-22 : 08:22:29
What's wrong with

WHERE NumberInTextString LIKE '%0167234587%'

??
Go to Top of Page
   

- Advertisement -