日期:2014-05-18  浏览次数:20798 次

查询表中数据中带" ' " 的问题
怎样查询数据中带“ ' "的数据

比如:类似 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
 /*
 code
ABDE'dsd
assfdf'sdf
*/
drop table tb

------解决方案--------------------
探讨
table:
名称
ass'edds

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

类似这样的查询

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