这是我输入的@Name为“Rupesh's”
我想在“AppliedPolicies
”表格中找到“Rupesh's”之类的名称
Select PolicyID, CustomerName, PolicyDesc
From AppliedPolicies
Where PolicyDesc = @Name
PLZ。建议我怎样才能得到所需的结果。
答案 0 :(得分:3)
试试这个
Select PolicyID, CustomerName, PolicyDesc
From AppliedPolicies
Where PolicyDesc like '%' + @Name + '%'
答案 1 :(得分:1)
你需要添加另一个单引号以逃避名称中的单引号,即'Rupesh'''
示例:
declare @name varchar(20) = 'Rupesh''s'
SELECT * FROM
AppliedPolicies
WHERE PolicyDesc = @Name
答案 2 :(得分:1)
Select PolicyID, CustomerName, PolicyDesc From AppliedPolicies
Where PolicyDesc like'%Rupesh'
答案 3 :(得分:0)
根据你的头衔,也许试试这个:
Select
PolicyID,
CustomerName,
PolicyDesc
From
AppliedPolicies
Where
PolicyDesc like '%''%'
答案 4 :(得分:0)
试试这个SQL
Select PolicyID, CustomerName, PolicyDesc
From AppliedPolicies
Where Replace(PolicyDesc,'''','_') = Replace(**@Name**,'''','_')