Jan 09 2024 07:04 PM - edited Jan 09 2024 07:05 PM
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
Jan 09 2024 09:55 PM
@Tod_Lay wrote:Would someone provide a link to a microsoft forum discussing SQL language?
@Tod_Lay , for T-SQL in common see
Get Started Querying with Transact-SQL - Training | Microsoft Learn
T-SQL Tutorial: Write Transact-SQL statements - SQL Server | Microsoft Learn
and more specific for LIKE operator/wildcard search see
Wildcard search (%) - SQL Server | Microsoft Learn
The rest of you post is to vague.
Please post table design as DDL, some sample data as DML statement and the expected result.