×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Specifying carriage return/line feed in an SQL statement

Specifying carriage return/line feed in an SQL statement

Specifying carriage return/line feed in an SQL statement

(OP)
Hi there, I hope you can help us.

We're using this statement to import some values into a database:
SQLStatement = "INSERT MyTable (ID, VALUE) VALUES ('" & IDString & "', '" & VALUEString & "')"

The problem is that the strings might contain carriage returns/line feeds, i.e.
VALUEString = "Line 1." & vbCrLf & "Line 2."

It only imports up until the first vbCrLf. We have tried replacing vbCrLf with "\n", but this doesn't work either. What is the correct format for inserting a value that contains new line characters?

Thanks for your time,
Lasse.

RE: Specifying carriage return/line feed in an SQL statement

Dear SpaceRain,

I have worked in simial problem. Change your column type to VarChar and instead of single quote (') in insert into statement use double quotes. I have attached a example for your convience.

INSERT INTO mytab (ID, VAL) VALUES (" & CHR(34) & idstr & CHR(34) & "," & CHR(34) & valstr & CHR(34) & ")"

For further details please let me know things like a complete description like database environment, column types etc.

RE: Specifying carriage return/line feed in an SQL statement

Hi,

i would like to insert a carriage return into my select statement - but I couldn't find the sign for the carriage return anywhere!

I hope there is help out there,

Ramona

RE: Specifying carriage return/line feed in an SQL statement

Hi,

i would like to insert a carriage return into my select statement - but I couldn't find the sign for the carriage return anywhere!

I hope there is help out there,

Ramona

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources