notepad file issue


I created some .sql files and when I open in notepad complete file in single line. But when I open in notepad++ it is opening correctly. Can you please let me know why and how can I convert into multiple lines and view the file properly in notepad itself?

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.

Deepak ChauhanSQL Server DBACommented:
Open the file in Notepad and click on the Format Tab and just Check mark the WordWrep option. From next time this will open correctly.
GouthamAnandAuthor Commented:
When it is mark word wrap or unmark word wrap its not in proper format. I think it is something related with encoding. and tried using save as option and selected ANSI encoding and saved the file, but no use. I am seeing the file data in single. But in notepad++ its in proper format with lines in different lines.
Dave BaldwinFixer of ProblemsCommented:
Notepad++ is aware of line endings where Notepad is not.  Another flaw with recent versions of Notepad is that it is no longer just a plain text editor.  It can corrupt plain text files.  You are Much better off using Notepad++ which is intended for plain text applications like SQL and other code files.
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

GouthamAnandAuthor Commented:
But this one sql file is not opening properly in notepad all other sql files are opening properly in notepad itself.
The issue is am unable to run this file in oracle sql command prompt and getting error like Error 45 initializing SQL*Plus.
But am able to run the files which are opening properly in notepad.
Deepak ChauhanSQL Server DBACommented:
Notepad only recognises CR, LF now an easy way to fix this problem, copy and paste the text into Word and then back into the notepad.

This problem generally happen when file created in Non Windows OS like unix.
GouthamAnandAuthor Commented:
I tried like this but format did not change. Its copied back as single line. Yes we are not able to open in Linux vi editor also.
Deepak ChauhanSQL Server DBACommented:
can you send the file if possible.
Dave BaldwinFixer of ProblemsCommented:
What editor did you use to create these files?

Try opening the files in Notepad++ and try one of the 'Save As' options and then see if Notepad will open it.  There is an option for SQL in the dropdown list.
GouthamAnandAuthor Commented:
Please find the attached sample file.
Notepad only recognizes <CR><LF> as a new line (as others have already mentioned), whereas Unix-based systems generally just use <LF> for a new line.  WordPad will display the files correctly (and of course many other programs like Notepad++).  The Windows programs I'm aware of will enter <CR><LF> for a new line when editing a file.

One way you can convert these files is with a utility like below.
It can also be done with a PowerShell script.

@DaveBaldwin - I'm interested in this comment.  "Another flaw with recent versions of Notepad is that it is no longer just a plain text editor.  It can corrupt plain text files."
Is this in Win8 or Win10?  I wasn't aware of this.
BTW, here's the PS command.
(gc C:\TEMP\1111.sql) | % { $_ -replace "`r?`n$","`r`n" } | sc C:\TEMP\1111.sql

Open in new window

Dave BaldwinFixer of ProblemsCommented:
I opened 1111.sql and it has only 'cr' and not 'lf' for line endings.  That is usually found on Macs.  When I forced it to use cr-lf, it opened fine in Notepad.
Dave BaldwinFixer of ProblemsCommented:
Re Notepad... in another question and I think it was about Win7, it seems that newer versions of Notepad actually support several file formats without telling you about it.  So you can't guarantee that Notepad will save as plain text.
David Johnson, CD, MVPOwnerCommented:
This file uses a Unix EOL
in notepad++ select all text, select edit  | EOL conversion | Windows format, save the file it will now show properly in notepad

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
GouthamAnandAuthor Commented:
Thank you very much.
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
Windows 7

From novice to tech pro — start learning today.