当前位置: 代码迷 >> Sql Server >> 简单有关问题:如何在查询的时候用"%"去匹配变量
  详细解决方案

简单有关问题:如何在查询的时候用"%"去匹配变量

热度:22   发布时间:2016-04-27 17:47:07.0
简单问题:怎么在查询的时候用"%"去匹配变量
怎么在查询的时候去匹配变量:
比如,查询姓 "王 "的用select   *   from   people   where   name   like   '%王 '
但我是用在存储过程中
定议的一个变量,比如
declare   @name   nvarchar(50)
@name记录的是姓
[email protected]

------解决方案--------------------
declare @name nvarchar(50)
select * from people where name like '% '[email protected]+ ' ' ' '
------解决方案--------------------
declare @name nvarchar(50)
set @name= '王 '
select * from people where name like '% '[email protected]
------解决方案--------------------
like '% '[email protected]
------解决方案--------------------
declare @name nvarchar(50)
select * from people where name like ' ' '% ' ' '[email protected]+ ' ' ' '
  相关解决方案