sql 如何查询单引号

来源:百度知道 编辑:UC知道 时间:2024/05/29 09:29:11
Purchase表中如何查询SPEC列 包含有'(单引号)这个特殊字符啊.

谢谢!
1到4楼的答案,我试过了,还是不行.

是不是这样:
declare @Purchase table(SPEC varchar(10))
insert into @Purchase
select '111' union
select '222' union
select '333''33' union
select '4''5''6''' union
select '789' union
select '000'

select * from @Purchase

select * from @Purchase where SPEC like '%''%'

--------------
(6 个资料列受到影响)
SPEC
----------
000
111
222
333'33
4'5'6'
789

(6 个资料列受到影响)

SPEC
----------
333'33
4'5'6'

(2 个资料列受到影响)

相信楼主要查询的是成对的单引号吧,如果是单个的,sql是不支持的。

具体实例属下
create table a(b varchar(20))--建表
insert into a values('''33333''')--初始化数据
数据表内容是'33333'
select * from a where b like '''33333''%'--模糊查询语句
select * from a where b = '