0

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

TheDizzle
  • 1,534
  • 5
  • 33
  • 76

2 Answers2

9

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.

Code Different
  • 90,614
  • 16
  • 144
  • 163
  • It doesn't display it as such when I reference it from the database in my site – TheDizzle Jun 23 '15 at 20:06
  • 1
    So is it not showing up on your website or you can't see it in the database? if the first case, I suggesting adding `
    ` instead of `CHAR(13) + CHAR(10)`. That's HTML for line break. If the second case, there's nothing to worry about.
    – Code Different Jun 23 '15 at 20:09
4

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.

Xavier
  • 440
  • 4
  • 11