Sybase 插入语句的字段值有分隔符“'”的解决方案

问题场景

往Sybase库插入数据的时候,有一个字段的值是要存入SQL语句,含有分隔符“’”,如何正确地插入语句?

解决方案

在字段的值当中,将分隔符中加多一个,那么就可以顺利插入

示例

错误样例

insert into test(a,b) values (1,"delete from tableA where name='s' ");
insert into test(a,b) values (1,'delete from tableA where name='s'      ');

正确示例

insert into test(a,b) values (1,'delete from tableA where name=''s''      ');

posted on 2022-11-29 18:40  枫夜求索阁  阅读(0)  评论(0)    收藏  举报

导航