February 1, 2023 at 9:33 pm
I'm using OPENROWSET to put the contents of a text file into a VARCHAR(MAX) column. However, it is stripping the carriage returns and line feeds out, so when I put the contents of the column back into Notepad I get one long line instead of the original text file. Is there a way to prevent this?
February 1, 2023 at 9:39 pm
What command are you using to insert the data?
February 1, 2023 at 10:19 pm
We never intended for SQL to be used for text management. You ought to be using the proper tool to store this data. As part Lane put it in one of his humorous essays, "the pumpkin is largely a failure is a shade tree."
Please post DDL and follow ANSI/ISO standards when asking for help.
February 1, 2023 at 10:37 pm
I'm using OPENROWSET to put the contents of a text file into a VARCHAR(MAX) column. However, it is stripping the carriage returns and line feeds out, so when I put the contents of the column back into Notepad I get one long line instead of the original text file. Is there a way to prevent this?
If you're manually copying "from the grid" to NotePad, it's the grid that's removing the CrLf characters. Try it with the text output instead of the grid.
If that doesn't work, then post back and we'll show you some code to check what's stored to see if the CrLfs are actually being stripped by the input process or not.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 1, 2023 at 11:06 pm
if copying from SSMS you can also go to tools->options->Query Results->SQL Server->Results to Grid and tick option "Retail CR/LF on copy or save"
February 2, 2023 at 3:38 am
We never intended for SQL to be used for text management. You ought to be using the proper tool to store this data. As part Lane put it in one of his humorous essays, "the pumpkin is largely a failure is a shade tree."
Please share what you consider to be "the proper tool".
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply