473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

single quote

How do I insert a single quote ' into a table? For example:
Insert mytable values (1,''')
I get an error message.

Any ideas? The server does not recognize double quote (why? is this
tsql, ansi?), otherwise I could have written it as:
Insert mytable values (1,"'")

Thanks.

Nov 9 '06 #1
4 7060
Nevermind. Following worked:
SET QUOTED_IDENTIFIER OFF
insert mytable values (3,"'",getdate())

othell...@yahoo.com wrote:
How do I insert a single quote ' into a table? For example:
Insert mytable values (1,''')
I get an error message.

Any ideas? The server does not recognize double quote (why? is this
tsql, ansi?), otherwise I could have written it as:
Insert mytable values (1,"'")

Thanks.
Nov 9 '06 #2
(ot*******@yahoo.com) writes:
Nevermind. Following worked:
SET QUOTED_IDENTIFIER OFF
insert mytable values (3,"'",getdate())

Yes, that's one way to do it. But it will not always work, because the
setting QUOTED_IDENTIFIER must be ON in some situations.

The standard way to do it is do double the string delimiter:

insert mytable values (3, '''', getdate())

Standard SQL only recognizes ' as a string delimiter. " is used to delimiter
identifiers with "funny" characters in them, like space. (Although with SQL
Server you normally use [] in this case.)

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Nov 9 '06 #3
To add on to Eland's response, the ANSI standard QUOTED IDENTIFIER ON allows
you to use SQL Server features line indexes on views and computed columns.

--
Hope this helps.

Dan Guzman
SQL Server MVP

<ot*******@yahoo.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Nevermind. Following worked:
SET QUOTED_IDENTIFIER OFF
insert mytable values (3,"'",getdate())

othell...@yahoo.com wrote:
>How do I insert a single quote ' into a table? For example:
Insert mytable values (1,''')
I get an error message.

Any ideas? The server does not recognize double quote (why? is this
tsql, ansi?), otherwise I could have written it as:
Insert mytable values (1,"'")

Thanks.
Nov 9 '06 #4
Dan Guzman (gu******@nospam-online.sbcglobal.net) writes:
To add on to Eland's response, the ANSI standard QUOTED IDENTIFIER ON
allows you to use SQL Server features line indexes on views and computed
columns.
And in SQL 2005, XQuery.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Nov 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: sankofa | last post by:
hi, i can't seem to be able to escape my single quote properly... is it even possible in javascript? this is a portion of my code.. var DLEWIS="Pastor Lewis"; .... Sermon is a yser-defined...
5
by: Joel | last post by:
Hi, I incorporated a function in my code that whenever I use a string variable in an sql statement if the string contains a single quote it will encase it in double quotes else single quotes. ...
3
by: Jason | last post by:
I have several tables with quite a few fields and I'm getting errors when trying to insert records with single quotes in the data like: name = John O'Henry or a city name of O'Fallen So I went...
11
by: Elmo | last post by:
Hi all! I am not very proud to ask this but here is my problem: string code = "\'13\'" The string code will have to contain following info: '51','52','63','other'... to get certain info...
13
by: JohnQ | last post by:
Why would anyone write: class SomeThing // class littered with non-domain single-instancing code :( { private: SomeThing(); static SomeThing* pInstance_; public: static SomeThing*...
3
by: Eric Layman | last post by:
Hi, I've saved data into the db by doing a replace() on single quote. Right now on data display on a datagrid, it shows double single quote. How do I make changes during run time of datagrid...
8
by: Grant Edwards | last post by:
I'm pretty sure the answer is "no", but before I give up on the idea, I thought I'd ask... Is there any way to do single-precision floating point calculations in Python? I know the various...
4
by: fniles | last post by:
I am looping thru DataReader and constructing a sql query to insert to another database. When the data type of the field is string I insert the field value using a single quote. When the value of...
2
by: Reporter | last post by:
I got the following example from http://www.evolt.org/article/User_Friendly_Forms_in_PHP/20/60144/index.html : echo '<tr><td>First name:</td><td><input type="text" name="first_name"...
0
by: dhascuba | last post by:
The @name field can contain a single quote in it such as: Mike O'Grady. Since this is creating and SQL statement on the server side, it will not process the name if it has a single quote in it. Id'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.