Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What are the invalid SQL string characters and how to handle

Status
Not open for further replies.

wmotter

Programmer
Mar 31, 2001
4
US
I have to insert some data into an Access and SQL Server 7 database. I have a peice of data that has a '&' and/or a ',' in it. The field this data is going into is a text(varchar) field. The insert fails and I assume it is because of one or both of these characters. That led me to start looking for a list of invalid text characters and more importantly how do I 'escape' them so I can insert them into my field with either an UPDATE or INSERT SQL. I have failed to find it. Can anyone help?
 
Can you post an example of the code you're using to do the INSERT?

Greg.
 
INSERT INTO Table (Field)VALUES('This is a , sample & test')
 
This works - have you created the table?

Create table #Table_name (Field1 varchar(50))
INSERT INTO #Table_name (Field1)VALUES('This is a , sample & test')
select * from #Table_name

(1 row(s) affected)

Field1
--------------------------------------------------
This is a , sample & test

(1 row(s) affected) Malcolm
 
I am an idiot. I was positive the field was a varchar and it was numeric. So I embrassingly sign off and offer my thanks for your response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top