How to type a new line character in SQL Server Management Studio

You can paste the lines in from a text editor that uses UNIX-style line endings (CR+LF). I use Notepad++. First go to Settings/Preferences/New Document and change the format from Windows to Unix. Then open a new document, type in your lines, and copy them into SSMS.


You can't. (Edit: other good answers have been posted with some workable methods.)

My preferred method to do this is via a direct SQL update.

Two general techniques:

--Literal returns inside strings
UPDATE mytable
SET textvalue = 
'This text
can include
line breaks'
WHERE rowid = 1234

--Concatenating CHAR codes
UPDATE mytable
SET textvalue = 'This text' + CHAR(10) + CHAR(13) 
   + 'can include' + CHAR(10) + CHAR(13)
   + 'line breaks'
WHERE rowid = 1234

The former is a little easier to work with, but could give inconsistent results if you paste in text from outside sources with unknown line-ending codes.

The latter is somewhat harder to work with but is more likely to give you consistent and reliable results.


You can prepare the text in notepad, and paste it into SSMS. SSMS will not display the newlines, but they are there, as you can verify with a select:

select *
from YourTable
where Col1 like '%' + char(10) + '%'