how to update a field with metacharacter inside the str?

Posted on 2004-10-20
Last Modified: 2012-08-13
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..
Question by:smantha1979
  • 2

Accepted Solution

izblank earned 50 total points
ID: 12365380
You just double the apostrophies that are part of the literal value:

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

Expert Comment

ID: 12366465

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..


Expert Comment

ID: 12366470
You can use your string like this...with apostrophies


Author Comment

ID: 12386987
i just found out that, can use char(39) too

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Remote Server returned '400 4.4.7 Message delayed' 3 444
MySQL Backup Strategy 15 46
Access 2016 Query with Proper Case logic 2 36
Accessing variables in MySQL query 4 33
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question