I have what should be a simple task - Populate a user variable using the ResultSet from an Execute SQL task
SELECT MainID FROM TableA WHERE TableA_ID = 1`
(This will only return one Column and one Row).
MainID is currently stored as a user-defined datatype in the database. The value is stored in the format XXXX.Y (e.g. 8008.1).
If I change the UserVariable to a String datatype, I can assign the value without any problems either CASTing or CONVERTing the ResultSet to STRING/NUMERIC/FLOAT.
SELECT CAST(MainID as NUMERIC(9,1)) as 'MainID' FROM TableA WHERE TableA_ID = 1;
SELECT CAST(MainID as FLOAT) as 'MainID' FROM TableA WHERE TableA_ID = 1;
SELECT CAST(MainID as VARCHAR(10)) as 'MainID' FROM TableA WHERE TableA_ID = 1;
or
SELECT CONVERT(NUMERIC(9,1), MainID) as 'MainID' FROM TableA WHERE TableA_ID = 1;
SELECT CONVERT(FLOAT, MainID) as 'MainID' FROM TableA WHERE TableA_ID = 1;
SELECT CONVERT(VARCHAR(10), MainID) as 'MainID' FROM TableA WHERE TableA_ID = 1;
However, I can't assign the value if the User Variable Datatype is DOUBLE. I get the following error message:
[Execute SQL Task] Error: An error occurred while assigning a value to variable "dUserVariable": "The type of the value being assigned to variable "User::dUserVariable" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object. ".
I'm fairly new to SSIS so I'm a bit stumped on how to get this conversion to go through.
Any ideas?