How to generate insert script from sql server with line breaks in data

I have data with line feeds as below how can I generate the insert scripts with line break

Field1                      Desc
1                              This is a tes1a<CR>
                                This is a tes1b<CR>
                                This is a tes1
2                              This is a tes2a<CR>
                                This is a tes2b
3                              This is a tes3a<CR>
                                This is a tes3b<CR>
                                This is a tes3c
Bharat GuruAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
By using line breaks?!

      ID INT ,
      Payload NVARCHAR(64)

VALUES  ( 1, N'This is a tes1a
This is a tes1b
This is a tes1' ),
        ( 2, N'This is a tes2a
This is a tes2b' ),
        ( 3, N'This is a tes3a
This is a tes3b
This is a tes3c' );

SELECT  S.Payload ,
FROM    @Sample S;

Open in new window

Just use Results to Text in SSMS.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott PletcherSenior DBACommented:
Carriage Return = CHAR(13)
Line Feed = CHAR(10)

Typically the LF char is more critical, but if you just want a CR you can do this:

'This is a tes1a' + CHAR(13) + 'This is a tes1b' + CHAR(13) + 'This is a tes1'
Vitor MontalvãoMSSQL Senior EngineerCommented:
Bharat, do you still need help with this question?
Bharat GuruAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.