• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 462
  • Last Modified:

how to update a field with metacharacter inside the str?

like
update table set f1='some=\'asdfsadf\' ' where id=1;

but the above sql statement won't work,
i know i can update f1 correctly if i set some='asdfsadf' to a variable and use that variable in the sql statemet. but i want to know if i can set that in the sql statement..
0
smantha1979
Asked:
smantha1979
  • 2
1 Solution
 
izblankCommented:
You just double the apostrophies that are part of the literal value:

update table set f1='some=''asdfsadf'' ' where id=1;
0
 
giriky99Commented:

Hi ,You can use the  apostrophies like this...
 
create table temp1
([id] int,f1 varchar(30))

insert into temp1(Id,f1) values(1,'sum=''asdfsadf''')

select * from temp1

update temp1
set f1='sum=''asdfsadf''' where id=1

select * from temp1

if you any other problem..let me know..

0
 
giriky99Commented:
You can use your string like this...with apostrophies

'some=\''asdfsadf\'''
0
 
smantha1979Author Commented:
i just found out that, can use char(39) too
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now