April 20, 2009 at 12:30 pm
how would i select a name that has 2 letters after uner score at the end.
something like
BugdetRev120909_PA
SirsregionRev_CA
April 20, 2009 at 12:44 pm
Do some reading in BOL on the LIKE operator and wildcards.
April 20, 2009 at 12:49 pm
How about this:
SELECT
*
FROM
TABLE
WHERE
LEN(column) - CHARINDEX('_', 'column') = 2
Or
SELECT
*
FROM
TABLE
WHERE
Column LIKE '%/___' ESCAPE '/'
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
April 29, 2009 at 5:18 am
Tara
Hope this will be helpful....
-- Create Tmp Table
create table #tmp1 (firstname varchar(100))
-- Insert records
insert into #tmp1 values ('BugdetRev120909_PA')
insert into #tmp1 values ('SirsregionRev_CA')
insert into #tmp1 values ('BugdetRev120909_PAxxx')
insert into #tmp1 values ('SirsregionRev_CAxxx')
-- Fetch records for matching criteria
select * from #tmp1 where substring(firstname, len(firstname)-2,1) = '_'
Rgds
Mohan Kumar Vs
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply