I'm trying to import SSAS DMV metadata into SQL Server using a data flow in SSIS. In this example, I'm attempting to import data from the $SYSTEM.TMSCHEMA_PARTITIONS DMV. My select statement (which looks like SQL but is not SQL), is:
SELECT
[ID]
,[TableID]
,[Name]
,[Description]
,[DataSourceID]
,[QueryDefinition]
,[State]
,[Type]
,[PartitionStorageID]
,[Mode]
,[DataView]
,[ModifiedTime]
,[RefreshedTime]
,[SystemFlags]
,[ErrorMessage]
FROM $SYSTEM.TMSCHEMA_PARTITIONS
The QueryDefinition column contains records with several thousand characters. However the ExternalColumns section of the SSIS data source component is recognising the columns as DT_WSTR with 255 length. It's not possible to change the external column data type as it will keep reverting back. Nor is it possible to use CAST or CONVERT in the DMV select statement as per MS documentation:
The query engine for DMVs is the Data Mining parser. The DMV query syntax is based on the SELECT (DMX) statement. Although DMV query syntax is based on a SQL SELECT statement, it does not support the full syntax of a SELECT statement. Notably, JOIN, GROUP BY, LIKE, CAST, and CONVERT are not supported.
Naturally, I'm getting a truncation error. My question is, is there any way to change the way in which SSIS interprets the SSAS DMV metadata data types?
I've tried using order by (as a test) to return records with string length > 255 first, in order to force SSIS into thinking straight. It was to no avail.