Solved

how to update a field with metacharacter inside the str?

Posted on 2004-10-20
4
453 Views
Last Modified: 2012-08-13
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
Comment
Question by:smantha1979
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
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;
0
 
LVL 1

Expert Comment

by:giriky99
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..

0
 
LVL 1

Expert Comment

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

'some=\''asdfsadf\'''
0
 

Author Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
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…

734 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