In SQL Server 2005 I am trying to query a varchar(MAX) column which has some rows with text data that exceed the 8192. Yet, In Management Studio I have under Tools --> Options --> Query Results --> Results to Text --> Max numbers of characters displayed in each column = 8192, which is a maximum. Accordingly, it seems the truncation on these rows occurs only due to the limitation imposed by text output.
The only thing I see to get around this is to use a SUBSTRING function to grab say the first 8000 chars, then the next 8000 chars etc. etc. But this is ugly and error prone.
I should mention that SSIS and BCP are not options for me.
Does anyone have a better suggestion? Thanks!
TRUNCATE TABLE removes all rows from a table, but the table structure and its columns, constraints, indexes, and so on remain. To remove the table definition in addition to its data, use the DROP TABLE statement.
Limitations of SQL Server Express:1GB maximum memory used by the database engine. 10GB maximum database size. 1MB maximum buffer cache. CPU the lesser of one (1) socket or four (4) cores (number of SQL user connections NOT limited)
Right click in the query editor and select Query Options. Under Results, select Text. Uncheck “Include column headers in the result set” and change the maximum number of characters displayed to 8192. Click on in the editor and click Results To and choose Results to Text and click OK.
You can export the data to a flat file which will not be truncated. To do this:
Remaining steps should be self explanatory. This will output the file to text and you can open it in your favorite text editor.
I also use XML but a slightly different method that gets around most of the issues with XML entitisation.
declare @VeryLongText nvarchar(max) = ''; SELECT top 100 @VeryLongText = @VeryLongText + ' ' + OBJECT_DEFINITION(object_id) FROM sys.all_objects WHERE type='P' and is_ms_shipped=1 SELECT LEN(@VeryLongText) SELECT @VeryLongText AS [processing-instruction(x)] FOR XML PATH('') PRINT @VeryLongText /*WILL be truncated*/
Make sure that the "XML data" limit in SSMS is set sufficiently high!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With