我的数据库中有这些表
我的存储过程是
ALTER procedure [dbo].[SearchEmployee]
@Name varchar(155),
@Gender varchar(50),
@MaterialStatus varchar(50),
@DOB date,
@Designation varchar(155),
@Salary money
AS
SET NOCOUNT OFF;
BEGIN
SELECT
intEmployeeId,
(vchFirstName + ' ' + ISNULL(vchMiddleName,' ') + ' ' + vchLastName) AS Name,
vchGender ,
vchMaterialStatus,
dtDOB,
vchDesignation,
intSalary,
dtmCreatedDate,
bitActive,
F.vchFilename As FileName ,
F.intFileid As Fileid
FROM
Employee AS E
FULL OUTER JOIN
EmployeeFiles AS EF ON e.intEmployeeId = EF.intEmployeeIds
FULL OUTER JOIN
Files AS F ON EF.intFileids = F.intFileid
WHERE
vchFirstName LIKE @Name OR
vchMiddleName LIKE @Name OR
vchLastName LIKE @Name
END
此查询仅返回一行
exec SearchEmployee @Name='m', @Gender=NULL, @MaterialStatus=NULL,
@DOB='0001-01-01', @Designation=NULL, @Salary=NULL
我有多名员工,其名称包含m
个字符。如何从数据库中获取所有行?
答案 0 :(得分:2)
根据我的理解,您需要获取名称中包含M
的所有记录。因此,您需要将外卡字符%
告诉刽子手,%
前面的M
表示M
之前和{{1}之前的任意数字字符}表示M
之后任意数量的任何字符。 Read more about it here
因此,您需要更改M
条件
like