Forum Discussion

Tod_Lay's avatar
Tod_Lay
Copper Contributor
Jan 10, 2024

T-SQL Support

Would someone provide a link to a microsoft forum discussing SQL language? OR... Help me with this issue. I have a query that has a WHERE clause like this:

 

--------------------------

set @name =
'%jones%'

 

Defendant_Last_Name like @name

--------------------------

 

Sometimes the last name is something common like Jones and so there are hundreds of results. I'd like to put a first initial only when the results need to be narrowed down. So if it's Gym Jones I want to put G as the first name initial. I'm thinking I would start by creating a variable for the first initial, like:

 

--------------------------

set @name ='%jones%'

set @FI = 'G%'

--------------------------

 

And then modify the Where clause to look for the FI only if there is a value set for FI. 

 

Can someone help me with this one. Or feel free to just point me to the correct forum.

 

Thanx,

 

tod

 

Resources