How To Insert New Line Characters into Strings?
Submitted by: AdministratorIf 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)+'GlobalGuideLine.com';
PRINT CHAR(10);
PRINT 'Current date and time is '
+CONVERT(VARCHAR(20), GETDATE());
GO
Welcome to
GlobalGuideLine.com
Current date and time is May 19 2007 7:30PM
Submitted by: Administrator
* 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)+'GlobalGuideLine.com';
PRINT CHAR(10);
PRINT 'Current date and time is '
+CONVERT(VARCHAR(20), GETDATE());
GO
Welcome to
GlobalGuideLine.com
Current date and time is May 19 2007 7:30PM
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How To Execute the Cursor Queries with "OPEN" Statements? |
☺ | What Happens If Strings Are Casted into Wrong Code Pages in MS SQL Server? |
☺ | How To Convert a Numeric Expression from One Data Type to Another? |
☺ | How To Use Subqueries with the IN Operators in MS SQL Server? |
☺ | How To Use Subqueries with the EXISTS Operators in MS SQL Server? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |