Solved

Inserting a value regardless what it is

Posted on 2009-05-15
6
174 Views
Last Modified: 2012-05-07
Is there anyway of inserting a value into SQL regardless what it is?

I have this value that I want to insert; L'INIZIO SET LUNCH but the ' is offending and SQL will not insert it saying: Incorrect syntax near 'INIZO'. Unclosed quotation mark after the character string ');'.
0
Comment
Question by:richard_gar
[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
6 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 24397606
replace that Single  quote with two single quotes

insert into urTable
SELECT '  L''INIZIO SET LUNCH  '
0
 
LVL 8

Expert Comment

by:SNilsson
ID: 24397959
If you want to do this once adding a single quote will do, if you want to automate this you should doubble up the single quotes in a insert/update trigger or in a SP if thats what your using.

If so you can use the sql command Replace to change ' to ''
0
 
LVL 13

Expert Comment

by:St3veMax
ID: 24398930
try:

INSERT INTO dbo.tbl_MyTable ('Col1') VALUES ('L''INIZIO SET LUNCH')

HTH
0
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24399448
of course, the '' instead of the ' will solve the issue in sql.
however, what programming language do you use? most (all) support bind parameters, which handle this issue transparently.
0
 

Author Comment

by:richard_gar
ID: 24399642
vb.net
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 24399732
see this tutorial:
http://www.dotnetspider.com/resources/90-Using-SqlParameter-Class.aspx

as you see, just a matter of defining the parameter, and you won't need to care about neither quotes, and for dates about the format etc.
just pass the value into the parameter, and you are done.
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

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

729 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