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)
 find number

Author  Topic 

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2011-01-29 : 22:54:13
hi

my table has a PartNumber field with 3 rows of data:
1211 55 3 125 5545
1211 05 4 125 5535
1216 53 5 128 5435

How do i use LIKE to extract exact match. For example, if a user type in 55, it should retrieve the 1st row, and if user typed in 5, then it should only retrieve the 3rd row. Thanks

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-01-30 : 01:34:29
check this one

Select
Col1,col2,...,ColN

from TableName
Where ColX like '% 55 %' --note the white spaces in at first and last.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-02-06 : 21:00:24
quote:
Originally posted by sg2255551

hi

my table has a PartNumber field with 3 rows of data:
1211 55 3 125 5545
1211 05 4 125 5535
1216 53 5 128 5435

How do i use LIKE to extract exact match. For example, if a user type in 55, it should retrieve the 1st row, and if user typed in 5, then it should only retrieve the 3rd row. Thanks



Are you searching specifically on the 6th & 7th char only ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2011-02-07 : 07:53:04
Thks. MIK_2008 solution works for me.
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-07 : 09:52:10
yrw

Cheers!
Go to Top of Page
   

- Advertisement -