locked
Save Formatted Text using SSMS RRS feed

  • Question

  • How do I save the following text with the format so it can be returned in the exact same format 

    to an aps.net's <P> tag.

    Welcome to American Saint Miguel, you may now request to online if your lease does not expire within 10 -15 days of your request. 
    
    To be considered eligible to lease, you must:
    
    (1) You have not rented before, and 
    
    (2) You must be in “good standing”. 
    
    Note: If your account is delinquent, you will not be able to lease and your application fee will not be refunded. 
    
    Good standing means that you do not owe money, you do not have any past due amount to creditors, and your lease expires within 10 - 15 days. 
    
    If you do not meet the good standing criteria, your application will not be approved.
    
    If you meet the above mentioned criteria, please click here for details on required documents that you will need to submit.


    • Edited by MikeGanem2 Friday, July 24, 2020 2:39 AM
    Friday, July 24, 2020 2:28 AM

All replies

  • Did you try to save it as is in varchar(max) column?

    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog


    My TechNet articles

    Friday, July 24, 2020 5:12 AM
  • How do I save the following text with the format so it can be returned in the exact same format

    By saving it ...; what's your exact issue here?

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Friday, July 24, 2020 5:33 AM
  • As others have remarked, it is not clear what your issue is, but if the problem is that when you copy the text from the grid in SSMS all line breaks are gone, there are two ways to go:

    1) Use Ctrl/T to switch set output to text. Or Ctrl/F to set output to a file directly.

    2) In Tools->Options->Query Results->SQL Server->Results to Grid, there is an option "Retain CR/LF on copy/save". I believe this option is unchecked by default. (I always have it checked myself).


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

    Friday, July 24, 2020 8:38 AM
  • Hi MikeGanem2,

    Please tell us what is the specific problem.Besides,Thomas M Porter II’s views may be useful to you

    To store formatting, there will need to be a markup of some kind. HTML might work. If this will be displayed in a browser, sanitize the value to avoid any possible security issues.

    If you use HTML, the literal stored value might be:

    <strong>This</strong> is a <i>sentence</i>
    Edit: noticed the WPF tag, which has different formatting markup from HTML. The idea is still the same.

    <Bold>This</Bold> is a <Italic>sentence</Italic>
    Edit2: Not sure why the WPF tag was removed and "formatted" example were changed in the question, lol. Stack Overflow seems like a strange place.

    Since it's been brought up, yes, text with markup is not pure relational data, so it theoretically has no business being in a relational database.

    However, realistically, there are scenarios that storing the formatting in an alternate way would be counterintuitive/costly (Content Management Systems with Rich Text Boxes that modify dynamic data come to mind)

    So, it could be used as long as the developer knows what the consequences are, it's not used badly and blindly (throwing static/never changing content in DB instead of files), and he/she gets the blessing from his/her friendly neighborhood DBA.

    Best Regards
    Echo


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Monday, July 27, 2020 7:16 AM
  • Hi MikeGanem2,

    Has your problem been solved? If it is solved, please mark the point that you 
    think is correct as an answer. This can help others who encounter similar problems.


    Best Regards
    Echo


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Thursday, July 30, 2020 9:09 AM
  • Hi

    The data type should nvarchar .For carage return concat by CHAR(13) .Follow the bellow link for details

    https://www.sqlshack.com/sql-carriage-return-or-tab-in-sql-server-string/

    Thanks and regards

    Thursday, July 30, 2020 4:32 PM