I am over SQL Server 2008 and I have a field with a huge amount of data. When I apply…
DATALENGTH(field_name)
… I get to know my field is 288.946 characters long, but on MS SQL Server Management Studio, when I try to copy-paste the result of a simple SELECT of that field into a text editor (Notepad+), it seems like SQL Server only packs 43.679 characters… Or is it that the buffer for copying text in Windows is blowing the maximum number of characters? I have tested already and the limit isn’t with Notepad+ line size or something… If I copy-paste into a new query window in SQL Server, the result is the same text string limited to 43.679 characters.
Well, the question is: I need to copy-paste the whole content of that field… Is there something special I should do in my query? Thank you.
I filed a bug against this during the beta of SQL Server 2008. They closed it as “fixed” but then commented that it was a duplicate of a Vista issue. Which surprised me because it appears in several other SSMS / operating system combinations as well, including Denali CTP1 on Windows 7.
http://connect.microsoft.com/SQLServer/feedback/details/344150/ssms-grid-will-not-display-43-679-characters-from-varchar-max
So, I’m not sure why they’ve called it fixed, because it is most certainly still a real limitation.
If you have < 64K, you can convert to XML then click on the result in grid mode. Unfortunately with more than that you’re pretty limited to what SSMS is going to be able to get for you. You’ll need to export to a flat file as others have suggested, use a different program to pull the data in full, or manually paste together chunks of 40000 characters. In your example you could do something like this:
But you’d have to adjust by adding more operations for columns with values > 320K.