Next Line in SQL Server String - Providing Next Line in SQL Printing

Here is the query in one of the forums.

I have a string like this.

'Your password has just been reset successfully. If you did not reset your password, please log in and ensure your password is secure and up to date.MyLincoln Mobile Team'

But I need it like the below format.

Your password has just been reset successfully. If you did not reset your password, please log in and ensure your password is secure and up to date.

MyLincoln Mobile Team

Field name is body
data type is nvarchar(max)


Solution for the above problem:

Char(13) provides the next line option in SQL Server.

Below is the query to workout the issue.

  1. declare @str nvarchar(4000)  
  2. set @str = N'Your password has just been reset successfully. If you did not reset your password, please log in and ensure your password is secure and up to date.MyLincoln Mobile Team'  
  3. print @str  
  4.   
  5. declare @str1 nvarchar(4000)  
  6. set @str1 = N'Your password has just been reset successfully. If you did not reset your password, please log in and ensure your password is secure and up to date.'CHAR(13) +'MyLincoln Mobile Team'  
  7. print @str1  

 

X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now