Solved

underscore within like

Posted on 2011-09-08
5
297 Views
Last Modified: 2012-05-12
when i use underscore, it seems like i am not getting predictable results.. can this be made reliable?
example:

declare @teststring table (testcolumn1 varchar(max)) 
insert into @teststring select 'Load PS.EMP TEST THIS COL: KEEP_EMP_SSN'
select * from @teststring
select * from @teststring where testcolumn1 like '%PS_EMP%'

Open in new window

0
Comment
Question by:25112
  • 2
  • 2
5 Comments
 
LVL 32

Expert Comment

by:ewangoya
ID: 36507328

use this

LIKE '%PS[_]EMP%'
0
 
LVL 32

Accepted Solution

by:
ewangoya earned 300 total points
ID: 36507338
The underscore is a wild card so to use it as a literal, you have to enclose it within square brackets  [_]
0
 
LVL 5

Author Comment

by:25112
ID: 36507409
wow.. so _ is just like %? (in a like statement)

anymore wildcard characters?
0
 
LVL 59

Assisted Solution

by:Kevin Cross
Kevin Cross earned 200 total points
ID: 36507573
Yes. '_' means any single character whereas '%' is multiple.
http://msdn.microsoft.com/en-us/library/ms179859.aspx
0
 
LVL 5

Author Comment

by:25112
ID: 36507769
cool...
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL LINE CONTINUATION ISSUE 12 31
SSIS Conditional Split 7 31
Update a text value in another table 10 35
T-SQL:  Collapsing 9 19
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now