TheDizzle
TheDizzle

Reputation: 1574

Create a new line in SQL Server

I am trying to create a new line in sql server. This is my query

UPDATE Translations
SET FieldLabel = 'Sequence' + CHAR(13) + CHAR(10) + 'Number'
WHERE (id = '1')

I need there to be a break between Sequence and Number. So far nothing is working.

Its generated on the page using

@Html.LabelFor(p => Model.FirstOrDefault().SeqNbr, htmlAttributes: null,
 labelText: xxx.Controllers.FieldTranslation.GetLabel("SeqNbr", 
@xxx.DNetSynch.GlobalVariables.LanguageID))

Does not return the break whether i use char(10) or br

Upvotes: 0

Views: 343

Answers (2)

Xavier
Xavier

Reputation: 467

This will work, but you FieldLabel must be a varchar() or nvarchar()

UPDATE       Translations
SET                FieldLabel = 'Sequence' + CHAR(10) + 'Number'
WHERE        (id = '1')

if you render this in a web page, then use

UPDATE       Translations
SET                FieldLabel = 'Sequence<br>Number'
WHERE        (id = '1')

but it would be better to use the first solution, and do a replace of char(10) by a <br> in your server logic.

Upvotes: 4

Code Different
Code Different

Reputation: 93151

The line break will not show up in the result grid but it's there. You can try copy & paste the cell to a text editor.

Upvotes: 9

Related Questions