?
Solved

Inserting a value regardless what it is

Posted on 2009-05-15
6
Medium Priority
?
175 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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 2000 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

There are some very powerful Dynamic 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 di…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

752 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