简体   繁体   中英

Execute stored procedure based on first letter of parameter [closed]

I am trying to create a stored procedure in SQL Server that runs my query based on the first letter supplied by the parameter. Currently the code that I have runs every single row and column for the query not just the ones that start with the letter provided within the parameter. Please assist so that it will run based on the letter typed for the parameter. I have listed the current code I have. The letters are provided are the first letters in my rows.

CREATE PROCEDURE spListHumans (@first_name varchar(50), @last_name nvarchar(50), @name 
varchar(50))
AS
select h.first_name, h.last_name, ht.name, ht.description
from human h
left join humanstype ht ON h.human_type_id = ht.id
where @firstname like + '%' OR @firstname like ' 'AND @lastname like + '%'OR 
@lastname like ' 'AND @name like + '%' OR @name like + ' '

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM