Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

When to use char ( 13 ) and char ( 10 )?


Asked by Jaylah Rowe on Nov 30, 2021 FAQ



A line break is inserted only for the last string. If you want to generate a line break, it is a good practice to use CR and LF together. CHAR (13) + CHAR (10) Your tip on CHAR (13) + CHAR (10) being used TOGETHER helped me resolve a REPLACE query, since I couldn't tell which character was which prior to your note.
Also Know,
char(13) is carriage return and char(10) is line feed. Different text editors/viewers will interpret it differently. For example, in the SSMS output window, the following 3 does not show any difference.
Just so, As described earlier, char (10) inserts a line break. In the following query, we use the SQL REPLACE function for replacing the comma with char function: In the output, we can see a line break after each month. It formats data with a line break, and only one row gets affected due to this:
Consequently,
The CHAR (10) formula is used to insert a newline dynamically in a single cell. You will not need to use the ALT+ENTER shortcut to insert a new line. I have observed that sometimes the CHAR (10) formula does not seem to work.
Accordingly,
CHAR can be useful when you want to specify characters in formulas or functions that are awkward or impossible to type directly. For example, you can use CHAR (10) to add a line break in a formula on Windows, and CHAR (13) to add a line break on the Mac.