Showing posts with label component. Show all posts
Showing posts with label component. Show all posts

Thursday, March 29, 2012

Dervied Column - Expression?

Hi:

I have a Dervied Column Component, in which there is a column called RecStatusCode. The criteria to give a value to that column is below in SQL:

(SELECT CASE CertParticipant
WHEN 'Y' THEN 'C'
WHEN NULL THEN 'A'
END
FROM [dbo].[SchoolCertRequest]
WHERE SchoolID = (SELECT SchoolCode FROM [WebStrategy].[LAF].[LoanApplication] WHERE LoanApplicationID = @.LoanApplicationID) and SchoolBranch = (SELECT BranchCode FROM [WebStrategy].[LAF].[LoanApplication] WHERE LoanApplicationID = @.LoanApplicationID) AND LoanType=(SELECT LoanApplicationTypeCode FROM [WebStrategy].[LAF].[LoanApplication] WHERE LoanApplicationID = @.LoanApplicationID))

My question is how can I use this SQL in that expression field, or is it possible to have a user variable, with the above sql being the criteria, and the value could be used in the derived column, by just using the variable in the expression. In either case, I hope you understand what I am trying to accomplish. The reason why its like this is because currently in my Data Flow Task, i Have a OLEDB source which returns 25+ column values, the source connects to this derived column item, and then finally the destination oledb where the mapping takes place. So basically I am trying to avoid MERGE JOIN, because i tried using it , and it complicated the whole thing much more then it really needs to be. Like the RecStatusCode column, i have 5 more columns which are dervied, and the values are coming from a SQL statement similar to above. I really need some help here, and I have not seen anything in reference to this in BOL or any articles online. Thanks in advance.

I think a combination of Replace and ISNull functions will do the trick.

http://msdn2.microsoft.com/en-us/library/ms141196.aspx

http://msdn2.microsoft.com/en-us/library/ms141184.aspx

|||Is there a way to put SQL queries in a user variable? I am just trying to figure out, whats the best way to do this? Can someone please advise. Thanks.|||Try doing that in an OLE DB command... You can't execute a SQL statement in a variable. You can store a SQL statement in a variable as it's just a string. You can even make that statement dynamic using variable expressions.|||

Please disregard my first answer; I thought you were asking how to translate the case statement into a SSIS expression.

Anyway; have you consider to include that query with the query in your source component; assuming all tables are in the same DB it would work just fine. In case the data is in different DB/Server; you could use a staging table to load the data on a common place and then have one single query.

Otherwise a second source component with a merge join may be an option.

Sunday, March 25, 2012

Derived Column error:can''t change datatype

I am trying to replace the value of a column in a derived column component, but it will not let me change the datatype.

It has decided that the column is a float, which is wrong.

How can I change it to the correct type?

Adding a cast function to the expression of the derived column should work for you. You could also use a data transformation component, but that would add extra columns to the pipeline.|||

Unfortunately this doesn't work.

The following

ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue

gives a datatype of

double-precision float

even changing it to

(DT_NUMERIC,28,9)(ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue)

makes no difference

|||That's interesting. I just put the same expression into a Derived Column transform, and it set the data type to DT_NUMERIC(28,9). I'm on SP2 - what SP are you running?|||win xp pro: v5.1 (build 2600.xpsp_sp2_gdr.050301-1519 : Service Pack 2)

Are you sure you are setting "replace column X" and not "add as new column"?|||workaround:

on the oledb source, advanced editor, set the datatype on the output column to numeric, then it is already correct on the way in

yet another hacky timewaster methinks...|||

Pipeline buffer columns' data types are fixed.

So, in a derived column, when using 'Replace' mode , that means one can change the contents alone, not the data type. This fixed typing is why the data conversion component always adds a new pipeline column, for example.

SSIS pipeline metdata is fixed, or deterministicly typed. Deterministic pipeline metdata is a design feature of SSIS, one you may not agree with.

|||I've said before that you should be able to operate SSIS in a given 'data mode' i.e. sql server.

The least it should do is correctly map the datatypes based on the connection manager type/subtype according to the recommendations in BOL

My Numeric column should map to DT_NUMERIC, why on earth it is choosing to map to DT_R8 is beyond me.

Derived Column error:can''t change datatype

I am trying to replace the value of a column in a derived column component, but it will not let me change the datatype.

It has decided that the column is a float, which is wrong.

How can I change it to the correct type?

Adding a cast function to the expression of the derived column should work for you. You could also use a data transformation component, but that would add extra columns to the pipeline.|||

Unfortunately this doesn't work.

The following

ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue

gives a datatype of

double-precision float

even changing it to

(DT_NUMERIC,28,9)(ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue)

makes no difference

|||That's interesting. I just put the same expression into a Derived Column transform, and it set the data type to DT_NUMERIC(28,9). I'm on SP2 - what SP are you running?|||win xp pro: v5.1 (build 2600.xpsp_sp2_gdr.050301-1519 : Service Pack 2)

Are you sure you are setting "replace column X" and not "add as new column"?|||workaround:

on the oledb source, advanced editor, set the datatype on the output column to numeric, then it is already correct on the way in

yet another hacky timewaster methinks...|||

Pipeline buffer columns' data types are fixed.

So, in a derived column, when using 'Replace' mode , that means one can change the contents alone, not the data type. This fixed typing is why the data conversion component always adds a new pipeline column, for example.

SSIS pipeline metdata is fixed, or deterministicly typed. Deterministic pipeline metdata is a design feature of SSIS, one you may not agree with.

|||I've said before that you should be able to operate SSIS in a given 'data mode' i.e. sql server.

The least it should do is correctly map the datatypes based on the connection manager type/subtype according to the recommendations in BOL

My Numeric column should map to DT_NUMERIC, why on earth it is choosing to map to DT_R8 is beyond me.sql

Derived Column error:can''t change datatype

I am trying to replace the value of a column in a derived column component, but it will not let me change the datatype.

It has decided that the column is a float, which is wrong.

How can I change it to the correct type?

Adding a cast function to the expression of the derived column should work for you. You could also use a data transformation component, but that would add extra columns to the pipeline.|||

Unfortunately this doesn't work.

The following

ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue

gives a datatype of

double-precision float

even changing it to

(DT_NUMERIC,28,9)(ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue)

makes no difference

|||That's interesting. I just put the same expression into a Derived Column transform, and it set the data type to DT_NUMERIC(28,9). I'm on SP2 - what SP are you running?|||win xp pro: v5.1 (build 2600.xpsp_sp2_gdr.050301-1519 : Service Pack 2)

Are you sure you are setting "replace column X" and not "add as new column"?|||workaround:

on the oledb source, advanced editor, set the datatype on the output column to numeric, then it is already correct on the way in

yet another hacky timewaster methinks...|||

Pipeline buffer columns' data types are fixed.

So, in a derived column, when using 'Replace' mode , that means one can change the contents alone, not the data type. This fixed typing is why the data conversion component always adds a new pipeline column, for example.

SSIS pipeline metdata is fixed, or deterministicly typed. Deterministic pipeline metdata is a design feature of SSIS, one you may not agree with.

|||I've said before that you should be able to operate SSIS in a given 'data mode' i.e. sql server.

The least it should do is correctly map the datatypes based on the connection manager type/subtype according to the recommendations in BOL

My Numeric column should map to DT_NUMERIC, why on earth it is choosing to map to DT_R8 is beyond me.

Derived Column error:can''t change datatype

I am trying to replace the value of a column in a derived column component, but it will not let me change the datatype.

It has decided that the column is a float, which is wrong.

How can I change it to the correct type?

Adding a cast function to the expression of the derived column should work for you. You could also use a data transformation component, but that would add extra columns to the pipeline.|||

Unfortunately this doesn't work.

The following

ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue

gives a datatype of

double-precision float

even changing it to

(DT_NUMERIC,28,9)(ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue)

makes no difference

|||That's interesting. I just put the same expression into a Derived Column transform, and it set the data type to DT_NUMERIC(28,9). I'm on SP2 - what SP are you running?|||win xp pro: v5.1 (build 2600.xpsp_sp2_gdr.050301-1519 : Service Pack 2)

Are you sure you are setting "replace column X" and not "add as new column"?|||workaround:

on the oledb source, advanced editor, set the datatype on the output column to numeric, then it is already correct on the way in

yet another hacky timewaster methinks...|||

Pipeline buffer columns' data types are fixed.

So, in a derived column, when using 'Replace' mode , that means one can change the contents alone, not the data type. This fixed typing is why the data conversion component always adds a new pipeline column, for example.

SSIS pipeline metdata is fixed, or deterministicly typed. Deterministic pipeline metdata is a design feature of SSIS, one you may not agree with.

|||I've said before that you should be able to operate SSIS in a given 'data mode' i.e. sql server.

The least it should do is correctly map the datatypes based on the connection manager type/subtype according to the recommendations in BOL

My Numeric column should map to DT_NUMERIC, why on earth it is choosing to map to DT_R8 is beyond me.

Derived Column error:can''t change datatype

I am trying to replace the value of a column in a derived column component, but it will not let me change the datatype.

It has decided that the column is a float, which is wrong.

How can I change it to the correct type?

Adding a cast function to the expression of the derived column should work for you. You could also use a data transformation component, but that would add extra columns to the pipeline.|||

Unfortunately this doesn't work.

The following

ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue

gives a datatype of

double-precision float

even changing it to

(DT_NUMERIC,28,9)(ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue)

makes no difference

|||That's interesting. I just put the same expression into a Derived Column transform, and it set the data type to DT_NUMERIC(28,9). I'm on SP2 - what SP are you running?|||win xp pro: v5.1 (build 2600.xpsp_sp2_gdr.050301-1519 : Service Pack 2)

Are you sure you are setting "replace column X" and not "add as new column"?|||workaround:

on the oledb source, advanced editor, set the datatype on the output column to numeric, then it is already correct on the way in

yet another hacky timewaster methinks...|||

Pipeline buffer columns' data types are fixed.

So, in a derived column, when using 'Replace' mode , that means one can change the contents alone, not the data type. This fixed typing is why the data conversion component always adds a new pipeline column, for example.

SSIS pipeline metdata is fixed, or deterministicly typed. Deterministic pipeline metdata is a design feature of SSIS, one you may not agree with.

|||I've said before that you should be able to operate SSIS in a given 'data mode' i.e. sql server.

The least it should do is correctly map the datatypes based on the connection manager type/subtype according to the recommendations in BOL

My Numeric column should map to DT_NUMERIC, why on earth it is choosing to map to DT_R8 is beyond me.

Derived Column error:can''t change datatype

I am trying to replace the value of a column in a derived column component, but it will not let me change the datatype.

It has decided that the column is a float, which is wrong.

How can I change it to the correct type?

Adding a cast function to the expression of the derived column should work for you. You could also use a data transformation component, but that would add extra columns to the pipeline.|||

Unfortunately this doesn't work.

The following

ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue

gives a datatype of

double-precision float

even changing it to

(DT_NUMERIC,28,9)(ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue)

makes no difference

|||That's interesting. I just put the same expression into a Derived Column transform, and it set the data type to DT_NUMERIC(28,9). I'm on SP2 - what SP are you running?|||win xp pro: v5.1 (build 2600.xpsp_sp2_gdr.050301-1519 : Service Pack 2)

Are you sure you are setting "replace column X" and not "add as new column"?|||workaround:

on the oledb source, advanced editor, set the datatype on the output column to numeric, then it is already correct on the way in

yet another hacky timewaster methinks...|||

Pipeline buffer columns' data types are fixed.

So, in a derived column, when using 'Replace' mode , that means one can change the contents alone, not the data type. This fixed typing is why the data conversion component always adds a new pipeline column, for example.

SSIS pipeline metdata is fixed, or deterministicly typed. Deterministic pipeline metdata is a design feature of SSIS, one you may not agree with.

|||I've said before that you should be able to operate SSIS in a given 'data mode' i.e. sql server.

The least it should do is correctly map the datatypes based on the connection manager type/subtype according to the recommendations in BOL

My Numeric column should map to DT_NUMERIC, why on earth it is choosing to map to DT_R8 is beyond me.

Derived Column error:can''t change datatype

I am trying to replace the value of a column in a derived column component, but it will not let me change the datatype.

It has decided that the column is a float, which is wrong.

How can I change it to the correct type?

Adding a cast function to the expression of the derived column should work for you. You could also use a data transformation component, but that would add extra columns to the pipeline.|||

Unfortunately this doesn't work.

The following

ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue

gives a datatype of

double-precision float

even changing it to

(DT_NUMERIC,28,9)(ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue)

makes no difference

|||That's interesting. I just put the same expression into a Derived Column transform, and it set the data type to DT_NUMERIC(28,9). I'm on SP2 - what SP are you running?|||win xp pro: v5.1 (build 2600.xpsp_sp2_gdr.050301-1519 : Service Pack 2)

Are you sure you are setting "replace column X" and not "add as new column"?|||workaround:

on the oledb source, advanced editor, set the datatype on the output column to numeric, then it is already correct on the way in

yet another hacky timewaster methinks...|||

Pipeline buffer columns' data types are fixed.

So, in a derived column, when using 'Replace' mode , that means one can change the contents alone, not the data type. This fixed typing is why the data conversion component always adds a new pipeline column, for example.

SSIS pipeline metdata is fixed, or deterministicly typed. Deterministic pipeline metdata is a design feature of SSIS, one you may not agree with.

|||I've said before that you should be able to operate SSIS in a given 'data mode' i.e. sql server.

The least it should do is correctly map the datatypes based on the connection manager type/subtype according to the recommendations in BOL

My Numeric column should map to DT_NUMERIC, why on earth it is choosing to map to DT_R8 is beyond me.sql

Derived Column error:can''t change datatype

I am trying to replace the value of a column in a derived column component, but it will not let me change the datatype.

It has decided that the column is a float, which is wrong.

How can I change it to the correct type?

Adding a cast function to the expression of the derived column should work for you. You could also use a data transformation component, but that would add extra columns to the pipeline.|||

Unfortunately this doesn't work.

The following

ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue

gives a datatype of

double-precision float

even changing it to

(DT_NUMERIC,28,9)(ISNULL(FaceValue) ? (DT_NUMERIC,28,9)(NotionalAmount + ReturnGrossAmount) : (DT_NUMERIC,28,9)FaceValue)

makes no difference

|||That's interesting. I just put the same expression into a Derived Column transform, and it set the data type to DT_NUMERIC(28,9). I'm on SP2 - what SP are you running?|||win xp pro: v5.1 (build 2600.xpsp_sp2_gdr.050301-1519 : Service Pack 2)

Are you sure you are setting "replace column X" and not "add as new column"?|||workaround:

on the oledb source, advanced editor, set the datatype on the output column to numeric, then it is already correct on the way in

yet another hacky timewaster methinks...|||

Pipeline buffer columns' data types are fixed.

So, in a derived column, when using 'Replace' mode , that means one can change the contents alone, not the data type. This fixed typing is why the data conversion component always adds a new pipeline column, for example.

SSIS pipeline metdata is fixed, or deterministicly typed. Deterministic pipeline metdata is a design feature of SSIS, one you may not agree with.

|||I've said before that you should be able to operate SSIS in a given 'data mode' i.e. sql server.

The least it should do is correctly map the datatypes based on the connection manager type/subtype according to the recommendations in BOL

My Numeric column should map to DT_NUMERIC, why on earth it is choosing to map to DT_R8 is beyond me.