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)
 Check whether string is in varchar field

Author  Topic 

CoffeeAddict
Yak Posting Veteran

94 Posts

Posted - 2009-12-22 : 11:53:53
I can't get this syntax right.


select * from MyTable p
where p.productID = 9129
and p.SomeVarcharField having '27319'

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-22 : 11:57:08
Depending on ur data..this

select * from MyTable p
where p.productID = 9129
and p.SomeVarcharField like '27319%'


or

select * from MyTable p
where p.productID = 9129
and p.SomeVarcharField like '%27319%'


or even this..
select * from MyTable p
where p.productID = 9129
and p.SomeVarcharField = '27319'
Go to Top of Page
   

- Advertisement -