当前位置: 代码迷 >> Sql Server >> 查询表中数据中带" ' " 的有关问题
  详细解决方案

查询表中数据中带" ' " 的有关问题

热度:90   发布时间:2016-04-27 11:50:21.0
查询表中数据中带" ' " 的问题
怎样查询数据中带“ ' "的数据

比如:类似 ABDE'dsd的数据

------解决方案--------------------
SQL code
create table tb(code varchar(120))insert tb select 'ABDE''dsd' union select 'sfs' union select 'assfdf''sdf' select * from tb where CHARINDEX ('''',code)>0 /* codeABDE'dsdassfdf'sdf*/drop table tb
------解决方案--------------------
探讨
table:
名称
ass'edds

select * from table where 名称='ass'edds'

类似这样的查询

------解决方案--------------------
SQL code
select * from table_name where 名称 = 'ass''edds'   --需要转义一下,用2个'代表一个'
  相关解决方案