Does anyone know the actual maximum string length values for columns of type varchar(max) or nvarchar(max) when using the Table Import Wizard in a tabular project?
I'm working my way through the Wrox book Professional SQL Server 2012 Analysis Services with MDX and DAX and trying my hand at tabular projects for the first time. A couple of the tables provided in the AdventureWorksDW relational database have nvarchar(max) fields. When attempting to add these tables via the Table Import Wizard, I receive an error. No error number or code is provided, just this:
The size of a data value in table '<table name plus long identifier string>' column '<column name>' was too large to fit in that column. The current operation was cancelled because another operation in the transaction failed.
If I filter out the column from the import, the rest of the tables import fine, but the text didn't mention needing to exclude the columns.
I checked out the Data Types Supported
in BOL, and it contains the useful tidbit
You cannot import from a varchar(max) column that contains a string length of more than 131,072 characters.
"OK," I thought, "These fields are nvarchar(max), so that would probably max out at 65,536 characters since each character requires twice the bytes. There must be strings longer than that in my data."
However, when I ran both MAX(LEN(<field>
) and MAX(DATALENGTH(<field>
), one of the tables having the issue returned a maximum length for the field in question of only 34,568 characters and 69,136 bytes, well under the limit in BOL. Thinking it may be an issue with nvarchar(max) as opposed to varchar(max), I copied the data to a new table, moving the nvarchar(max) data to a varchar(max) field. Attempting to import from the varchar(max) field (now only 34,658 bytes) still generated the same error.
I haven't been able to locate any other information online about the error or about actual maximums enforced or whether or not it may be impacted by available memory (since it all has to be stored in-memory for the VertiPaq engine). I'd much appreciate any insight anyone has to offer.