March 30, 2010 at 12:46 pm
How do search a table for anything containing an underscore? Since this is a wildcard in SQL I can not find a way to search for it.
SELECT ID FROM PART WHERE ID LIKE '%_%'
March 30, 2010 at 12:58 pm
DECLARE @Table TABLE (RowID int IDENTITY(1,1), Col1 varchar(10))
INSERT INTO @Table(Col1)
SELECT 'test' UNION ALL
SELECT 'T_est'
SELECT *
FROM@Table
WHERECHARINDEX('_',Col1) > 0
March 30, 2010 at 12:59 pm
SELECT ID FROM PART WHERE CHARINDEX('_',ID) > 0
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgMarch 30, 2010 at 1:04 pm
Perfect! Thanks.
March 30, 2010 at 1:06 pm
bpowers (3/30/2010)
How do search a table for anything containing an underscore? Since this is a wildcard in SQL I can not find a way to search for it.
SELECT ID FROM PART WHERE ID LIKE '%_%'
You can escape the wildcard by wrapping square brackets around it. The charindex solution works too.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply