GeekInterview.com
Series: Subject: Topic:
Question: 196 of 427

How to insert any data in table which contain single quote ('). Like "Father's Name" By Using SQL.

Asked by: globalanil18 | Member Since Aug-2006 | Asked on: Mar 12th, 2007

View all questions by globalanil18   View all answers by globalanil18

Showing Answers 1 - 9 of 9 Answers
ora.nachs

Answered On : Mar 14th, 2007

View all answers by ora.nachs

You can insert like below insert statmentinsert into emp(ename) values('karthy's');it will inserted orinsert into emp(ename) values('karthy'''s');you can try with this also

  
Login to rate this answer.
ora.nachs

Answered On : Mar 14th, 2007

View all answers by ora.nachs

If the above not workingtry with thisinsert into emp(ename) values('karthy`s');` ---> use the key adjacent to 1, which is with tilda~ symbol

  
Login to rate this answer.
sankar kanna

Answered On : Mar 21st, 2007

Insert into employee values('Karthy''s',30000) you can insert by using statement only

  
Login to rate this answer.
SHIKHA YADAVA

Answered On : Apr 4th, 2007

Insert into employee values('a2','sy'''v','iijr',700,'fh78')(use Two single qoutes)

  
Login to rate this answer.
sandeep_patro

Answered On : May 22nd, 2008

View all answers by sandeep_patro

Hi all,we can insert single quote into a table in the following way.to insert: sandeep's nametable name: tempAns:insert into temp (name)values('sandeep''s name');to fetch the records that have single quotes as values in any table the following code will be used.select * from tempwhere name like '%''%'o/p: name-----sandeep's name 

  
Login to rate this answer.

When the apostrophe/single quote is at the start of the string, you need to enter 3 single quotes for Oracle to display a quote symbol. SQL> SELECT '''Hi There'  Message FROM dual; MESSAGE--------------'Hi ThereIn the middle of the string, you need to enter 2 single quotes SQL>  SELECT 'He''s always the first to arrive' Message FROM dual;MESSAGE-------------------------------He's always the first to arriveSingle quote is at the end of a string, you need to enter 3 single quotes SQL> SELECT 'Smiths''' FROM dual; 'SMITHS-------Smiths'If you were to concatenate an apostrophe/single quote in a string, you need to enter 4 single quotes SQL> SELECT 'There' || '''' || 's Henry' Message FROM dual;MESSAGE-------------There's Henry 

  
Login to rate this answer.
miteshcpatel

Answered On : Nov 11th, 2008

View all answers by miteshcpatel

If we need to insert D'SOUSA.

Query will be

INSERT INTO < TABLE > &( < COLUMN >)
VALUES ('D''SOUSA');

-- Here single quate two times after D
I have tested the query.. It is working file

  
Login to rate this answer.
Ajit

Answered On : Jul 13th, 2011

Here all have given the answer which is for hard coded value for some predefined word. He is asking and I am too looking for the this Question "ANY DATA".If user don't know whether the coming string is having Quotes or not? I had tried with replace but it is not working

Code
  1. INSERT IN abc(stringname) VALUES (REPLACE(anyValue," ' ", " '' "));
  2.  
its not working . Any Good solution?

  
Login to rate this answer.
venki

Answered On : Jul 23rd, 2011

Try this its working insert into tablename (vname)values(chr(39)||'name'||chr(39))

output:- 'name'

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.