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 2000 Forums
 Transact-SQL (2000)
 Compare records after removing some fields…

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-05-26 : 07:01:03
Suman writes "I need to search for a string with a column; but first I need to strip-out some characters (say every fifth character) before I can compare the user passed string with the stored data (the table has about 500000 records). I’m running SQL Server 7 and unable to use a UDF.

Here is an example:

Table:

Column1 Column2 ColumnN
1 1234567890 xxxxx
2 1111111111 xxxxx
3 1234567899 xxxxx

Now I want to search for ‘12346789’ using logic where I can ignore the every fifth character from ‘Column2’ before I search for ‘1236789’. The result should return the first and the last column.

Any help or suggestion is greatly appreciated."

sorengi
Starting Member

48 Posts

Posted - 2004-05-26 : 14:44:07
SELECT Column2
FROM Test
WHERE left(Column2,4) + right(Column2,5) like '%12346789%'

Michael D.
Go to Top of Page
   

- Advertisement -