• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

VB6, MSSQL, INSERT INTO, string with carriage returns


I am reading from an entry field that has carriage returns and/or line feeds in it.  When I look

When move the text field into a varibale and look at the contents in my watch window I can see that the text is on separate lines.

Can I just insert this text as is into an MSSQL nvarchar field or is there a special select statment to ensure the carriage returns are preserved ?

2 Solutions
If you use prepared statement you will be able to insert the string as it is. Just Goggle VB6 prepared statement, you will find plenty examples in the Internet
If you want to keep the CRLF characters then there's nothing special you need to do when storing the string in a variable.  You'd only need to do something different if you wanted to remove the characters which it doesn't sound like you are.

If you ran a select statement in SQL Management Studio you wouldn't see the CRLF since the value returns in a grid form... however, if you copied the contents and put them in a text editor the characters would be handled properly.  You may not see them but they're there unless you specifically remove them.
jcwiatrAuthor Commented:
Accepting both responses. jpgobert thank-you for identigying that I would not see them in Management Studio - this is where I was tripping up.

Also found out during investigations that if from toolbar-Query-Text you can see the output as it has been written with the correct spacing etc.

Thank-you both for responding.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now