I have the below SQL statement that is being called via a SSIS Execute:
SELECT DISTINCT [ICDM_Log_Paths] = STUFF((SELECT ' ' + [ICDM_Log_Paths]+ '|'
FROM dbo.[tblTmpICDM_Log_Paths]
FOR XML PATH('')), 1, 1, '')
FROM dbo.[tblTmpICDM_Log_Paths] AS t
However, when I assign to a Result set and a String variable, I receive the error:
[Execute SQL Task] Error: The value type (__ComObject) can only be converted to variables of type Object. [Execute SQL Task] Error: An error occurred while assigning a value to variable "FileName":
"The type of the value (DBNull) being assigned to variable "User::FileName" differs from the current variable type (String). Variables may not change type during execution. Variable types are strict, except for variables of type Object. ".
How do I CAST the select as NVARCHAR when using the STUFF?
I have tried the below but it is not working:
SELECT DISTINCT [ICDM_Log_Paths] = STUFF((SELECT ' ' + CAST([ICDM_Log_Paths] AS nvarchar(500))+ '|'
FROM dbo.[tblTmpICDM_Log_Paths]
FOR XML PATH('')), 1, 1, '')
FROM dbo.[tblTmpICDM_Log_Paths] AS t