like 问题 解决立马结帖

happy664618843 2016-12-15 01:46:01

tbInstanceInfo表数据如下 值为:
DBName InstanceName
ReportServer_HFM MSSQLSERVER;ReportServer_HFM
ReportServer_HFMTempDB MSSQLSERVER;ReportServer_HFMTempDB
HFM MSSQLSERVER:HFM


当我select * from tbInstanceInfowhere InstanceName like '%ReportServer_HFM%'
会查询出来两条数据。

我想根据ReportServer_HFM关键字查询只查询出来一条数据。
...全文
424 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
shadowpj 2016-12-15
  • 打赏
  • 举报
回复
select * from tbInstanceInfo where InstanceName like '%ReportServer_HFM'
LongRui888 2016-12-15
  • 打赏
  • 举报
回复
如果分隔符都是 分号 ,可以用这个: select * from tbInstanceInfowhere ';'+InstanceName+';' like '%;ReportServer_HFM;%'
中国风 2016-12-15
  • 打赏
  • 举报
回复
或用 e.g.
select * from  tbInstanceInfo where CHARINDEX(';ReportServer_HFM;',';' + InstanceName + ';')>0

select * from  tbInstanceInfo where PATINDEX('%;ReportServer_HFM;%',';' + InstanceName + ';' )>0
  • 打赏
  • 举报
回复
直接 select * from tbInstanceInfo where InstanceName like '%ReportServer_HFM' 或者 select * from tbInstanceInfo where InstanceName = 'ReportServer_HFM'
happy664618843 2016-12-15
  • 打赏
  • 举报
回复
引用 1 楼 shoppo0505 的回复:
select * from tbInstanceInfo where ';' + InstanceName + ';' like '%;ReportServer_HFM;%'
3q 我试下!
shoppo0505 2016-12-15
  • 打赏
  • 举报
回复
select * from tbInstanceInfo where ';' + InstanceName + ';' like '%;ReportServer_HFM;%'

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧