Solved

underscore within like

Posted on 2011-09-08
5
294 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
Comment Utility

use this

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

Accepted Solution

by:
ewangoya earned 300 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Yes. '_' means any single character whereas '%' is multiple.
http://msdn.microsoft.com/en-us/library/ms179859.aspx
0
 
LVL 5

Author Comment

by:25112
Comment Utility
cool...
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

771 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

9 Experts available now in Live!

Get 1:1 Help Now