N. Kester
N. Kester

Reputation: 1

Find all records that contain a single character followed by a space

I need to find all records that contain a middle initial in the following format:

N Jones  
S Smith  
T Thompson  
SELECT * 
FROM USERS 
WHERE Last_Name LIKE '% %'

This query returns

JE Smith  
TE Jones  

I only want to include rows that contain a single character at the beginning of the string followed by a space.

Upvotes: 0

Views: 48

Answers (1)

David Browne - Microsoft
David Browne - Microsoft

Reputation: 88996

I only want to include rows that contain a single character at the beginning of the string followed by a space.

Then don't use a multi-character wildcard (%) use a single character wildcard (_).

Upvotes: 1

Related Questions