Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a column called EventLog varchar(max) and can be pretty big because essentially it stores the event log of an entire batch process.

The problem is that when I go into the query window and do a select like this

SELECT EventLog from BatchProcess

When I cut and paste the text of the event log into Notepad, it

  1. removes all of the NewLines \n and is just one continous line.
  2. only copies a certain amount of text into the clipboard and truncates the rest.

How can I get the content of EventLog from the SQL Server Management Studio?

share|improve this question

migrated from Jun 10 '11 at 18:18

This question came from our site for professional and enthusiast programmers.

up vote 6 down vote accepted

To deal with the truncation try converting it to XML for processing

DECLARE @S varchar(max)

SELECT @S = ''

SELECT @S = @S + '
' + EventLog  FROM BatchProcess

SELECT @S AS [processing-instruction(x)] FOR XML PATH('')

Code modifed from Martin's Smith's answer to How do I view the full content of a text or varchar(MAX) column in SQL Server 2008 Management Studio?

This may also solve the line breaks, but if its a big deal try a different editor

share|improve this answer
thank you, this is perfect for my need. I had a look at the log file, it was about 3MB, so I have a feeling SQL Server cuts off anything after one meg. – RoboShop Jun 11 '11 at 1:27
  1. removes all of the NewLines and is just one continous line.

That sounds like the typical crappiness of Notepad. IIRC, in order to actually display line breaks, Notepad needs \r\n line endings, not just \n. Try pasting into WordPad or a real editor.

share|improve this answer
it could've been but i tried it in Word and WordPad also, and it was still continuous lines. The other solution worked though, both for getting the data out and getting the NewLines to appear. – RoboShop Jun 11 '11 at 1:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.