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

Questions by globalanil18   answers by globalanil18

Showing Answers 1 - 23 of 23 Answers

ora.nachs

  • Mar 14th, 2007
 

you can insert like below insert statment

insert into emp(ename) values('karthy's');

it will inserted or

insert into emp(ename) values('karthy'''s');

you can try with this also

  Was this answer useful?  Yes

ora.nachs

  • Mar 14th, 2007
 

if the above not working
try with this

insert into emp(ename) values('karthy`s');

` ---> use the key adjacent to 1, which is with tilda~ symbol

  Was this answer useful?  Yes

sankar kanna

  • Mar 21st, 2007
 

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

  Was this answer useful?  Yes

SHIKHA YADAVA

  • Apr 4th, 2007
 

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

  Was this answer useful?  Yes

hi all,

we can insert single quote into a table in the following way.

to insert: sandeep's name
table name: temp

Ans:

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 temp

where name like '%''%'

o/p:

name
-----
sandeep's name



 

  Was this answer useful?  Yes

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 There

In 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 arrive

Single 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 

  Was this answer useful?  Yes

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

  Was this answer useful?  Yes

Ajit

  • 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?

  Was this answer useful?  Yes

venki

  • Jul 23rd, 2011
 

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

output:- 'name'

  Was this answer useful?  Yes

Give your answer:

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

 

Related Answered Questions

 

Related Open Questions