Home >> FAQs/Tutorials >> SQL Server FAQ

SQL Server FAQ - Inserting New Line Characters into Strings

By: FYIcenter.com

(Continued from previous topic...)

How To Insert New Line Characters into Strings?

If you want to break a string into multiple lines, you need to insert new line characters into the string. With some client tools like SQL Server Management Studio, it is not so easy to insert a new line character.

One work around is to use the CHAR(int) function to generated new line character and other special characters with their code values:

  • CHAR(9) - Generates the tab character.
  • CHAR(10) - Generates the line feed (new line) character.
  • CHAR(13) - Generates the carriage return character.

The tutorial examples below gives you a good example

PRINT 'Welcome to '+CHAR(10)+'FYIcenter.com';
PRINT CHAR(10);
PRINT 'Current date and time is '
   +CONVERT(VARCHAR(20), GETDATE());
GO
Welcome to 
FYIcenter.com


Current date and time is May 19 2007  7:30PM

(Continued on next topic...)

  1. How To Concatenate Two Character Strings Together?
  2. What Happens When Unicode Strings Concatenate with Non-Unicode Strings?
  3. How To Convert a Unicode Strings to Non-Unicode Strings?
  4. What Are the Character String Functions Supported by SQL Server 2005?
  5. How To Insert New Line Characters into Strings?
  6. How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions?
  7. How To Concatenate Two Binary Strings Together?
  8. Can Binary Strings Be Used in Arithmetical Operations?
  9. How To Convert Binary Strings into Integers?
  10. Can Binary Strings Be Converted into NUMERIC or FLOAT Data Types?
  11. Can Binary Strings Be Converted into Character Strings?
  12. Can Binary Strings Be Converted into Unicode Character Strings?
  13. How To Convert Binary Strings into Hexadecimal Character Strings
  14. What Are Bitwise Operations?

Related Articles:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...