我这段语句出了问题:
insert into databaselog (sqlstr) values ('insert into dzjb (fjbm,bm,placename,bjbm) values ('-1','7','fs','7')')
7 个解决方案
#1
insert into databaselog (sqlstr) values ('insert into dzjb (fjbm,bm,placename,bjbm) values (''-1'',''7'',''fs'',''7'')')
#2
create table tc(str1 nvarchar(100))
go
insert into tc select 'insert into tc select * from str1'
go
insert into tc select 'insert into tc select * from str1'
#3
--try
insert into databaselog (sqlstr) values ('insert into dzjb (fjbm,bm,placename,bjbm) values (''-1'',''7'',''fs'',''7'')')
insert into databaselog (sqlstr) values ('insert into dzjb (fjbm,bm,placename,bjbm) values (''-1'',''7'',''fs'',''7'')')
#4
在SQL里:
若想要引用单引号(')作为字符串中的一部分,
必须用两个单引号('')代替,以区分字符串边界符(')
#5
,,
#6
insert into databaselog (sqlstr) values select replace(sql语句,'','''')
#7
注意字符串就OK了..
#1
insert into databaselog (sqlstr) values ('insert into dzjb (fjbm,bm,placename,bjbm) values (''-1'',''7'',''fs'',''7'')')
#2
create table tc(str1 nvarchar(100))
go
insert into tc select 'insert into tc select * from str1'
go
insert into tc select 'insert into tc select * from str1'
#3
--try
insert into databaselog (sqlstr) values ('insert into dzjb (fjbm,bm,placename,bjbm) values (''-1'',''7'',''fs'',''7'')')
insert into databaselog (sqlstr) values ('insert into dzjb (fjbm,bm,placename,bjbm) values (''-1'',''7'',''fs'',''7'')')
#4
在SQL里:
若想要引用单引号(')作为字符串中的一部分,
必须用两个单引号('')代替,以区分字符串边界符(')
#5
,,
#6
insert into databaselog (sqlstr) values select replace(sql语句,'','''')
#7
注意字符串就OK了..