Inconsistent Line Endings while opening .sql files in SSMS

I get warning messages when I open SQL files (.sql) in SQL Server Management Studio(SSMS).

Says : The line endings of the following file are not consistent. Do you want to normalize the line endings?

Any Idea why this happening?

Screenshot attached... [1]: /storage/temp/406-lineending.png
lineending.png (5.3 kB)
more ▼

asked Sep 17, 2012 at 11:08 AM in Default

Cyborg gravatar image

10.6k 36 40 45

I still have this problem when I open .sql files in SSMS, the sql files has scripts that are generated from powershell or by dynamic SQL. Anyone experienced this?
Oct 10, 2012 at 01:02 PM Cyborg
(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first
I've never had this message myself but it would suggest to me that whereas some line endings are denoted by the classic windows CR LF sequence, other lines are denoted by just the LF or maybe just CR. (any good hexdump utility will show you!). Nowadays, most text editors or text export utilities allow you to choose between the windows and Unix line-ending convention (LF), and most will accept either. Could this problem happen if you post sections of code into SSMS from another source? Whichever it is, I'd say yes and let SSMS tidy it up for you.
more ▼

answered Sep 17, 2012 at 11:17 AM

Phil Factor gravatar image

Phil Factor
3.9k 8 9 16

Thanks @Phill Factor, The script file is created by using SSMS only. when I open the script file in SSMS it asks me to save, the warning message hides once this is saved.
Sep 17, 2012 at 11:27 AM Cyborg
I remember, the same warning messages popup when i open SQL script files generated by Powershell.
Sep 17, 2012 at 11:29 AM Cyborg
Sounds like a UTF/ANSI issue.
Sep 17, 2012 at 12:31 PM Blackhawk-17
(comments are locked)
10|1200 characters needed characters left
Is anything in the script auto-generated from data within a database? If so, it might be that there are some inconsistencies there that need to be addressed.
more ▼

answered Sep 17, 2012 at 11:33 AM

ThomasRushton gravatar image

ThomasRushton ♦
34.2k 18 20 44

The script file basically has the attach database statement generated using dynamic SQL Query.
Sep 17, 2012 at 12:34 PM Cyborg
So, probably not the problem then!
Sep 17, 2012 at 02:22 PM ThomasRushton ♦
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Sep 17, 2012 at 11:08 AM

Seen: 4264 times

Last Updated: Oct 10, 2012 at 01:02 PM