How to store the result of a SQL statement as a variable and use the result in an SSIS Expression?

SSingh

I am using a SSIS Data Flow Task to transfer data from one table to another. Column A in Table A contains a number, the last 3 digits of which I want to store in Column B of Table B.

First I'm trying to grab all of the data in Column A and store in a variable via a simple SELECT statement SELECT COLUMN_A FROM TABLE_A. However, the variable stores the statement as a string when I want the result set of the query. I have set the EvaluateAsExpression property to False but to no avail.

Secondly I want to be able to use the result of this query in the Derived Column of my Data Flow to extract the last 3 digits and store the values in Column_B in the destination. The expression I have is:

(DT_STR,3,1252)RIGHT(@User::[VariableName],3)

I want to store this as a string hence the (DT_STR,3,1252) data type.

All I'm getting so far in Column_B of Table_B is is the last 3 characters of the SELECT statement "E_A". There is a lot of useful information on the web including YouTube videos for things like setting file paths and server names as parameters or variables but I can't see many relevant to the specifics of my query.

I have used an Execute SQL Task to insert row counts from flat files but, in this example, I want to use the Derived Column tool instead.

What am i doing wrong? Any help is gratefully appreciated.

SSingh

Thanks KeithL thats one solution I will use in future but I found another.

I dropped the variable and in the Expression box of the Transformation Editor did:

(DT_STR,3,1252)RIGHT((DT_STR,3,1252)Column_A,3).

In my question, I failed to cast Column_A from Table_A as a string. The first use of (DT_STR,3,1252) simply sets the destination column as a string so as not to use the same data type as the source which in my case was int.

Its the 2nd use of (DT_STR,3,1252) that actually casts Column_A from int to a string.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to store result of a LINQ statement executed in foreach to a variable for future use?

From Dev

How to store select statement result to table variable in sql server

From Dev

How to store the result of dynamic SQL in a variable?

From Dev

How to store the result of the expression into a variable in Windows batch script?

From Dev

how can i store the printing result, obtained by "for statement" variable?

From Dev

Cannot store result into variable SQL

From Dev

Store result of numeric expression in SAS macro variable

From Dev

How to store a query result in a variable

From Dev

How to store result of stored procedure in a variable using SQL Server

From Dev

How to store SQL query result in a variable using PHP?

From Dev

How do you assign the result of an expression to an SQL substitution variable?

From Dev

How to store a query result into a variable in mysql and then use it another query and echo result?

From Dev

Store function result to variable for later use in PHP?

From Dev

How to use regular expression result into another expression

From Dev

Store a sql query result in pentaho variable

From Dev

How to convert SQL statement to an expression in SSIS package

From Dev

Save Result of SQL Statement to Use Elsewhere

From Dev

How to use a $result variable with table object in SQL query using mySQLi

From Dev

How do I use an SQL Query Result as the value of a variable in Java?

From Dev

How to store query result (a single document) into a variable?

From Dev

How to store in a variable an echo | cut result?

From Dev

how to store result of tail command in variable?

From Dev

How to store sed result in variable in tcsh

From Dev

Python - How to store a Search Result (list) in a variable?

From Dev

how to store the result of a set operation into a variable

From Dev

How to store sed result in variable in tcsh

From Dev

how to store the query result into a variable in mysql

From Dev

How can I store the result of a function into a variable?

From Dev

Javascript - How to store result of the for loop into the variable?

Related Related

  1. 1

    How to store result of a LINQ statement executed in foreach to a variable for future use?

  2. 2

    How to store select statement result to table variable in sql server

  3. 3

    How to store the result of dynamic SQL in a variable?

  4. 4

    How to store the result of the expression into a variable in Windows batch script?

  5. 5

    how can i store the printing result, obtained by "for statement" variable?

  6. 6

    Cannot store result into variable SQL

  7. 7

    Store result of numeric expression in SAS macro variable

  8. 8

    How to store a query result in a variable

  9. 9

    How to store result of stored procedure in a variable using SQL Server

  10. 10

    How to store SQL query result in a variable using PHP?

  11. 11

    How do you assign the result of an expression to an SQL substitution variable?

  12. 12

    How to store a query result into a variable in mysql and then use it another query and echo result?

  13. 13

    Store function result to variable for later use in PHP?

  14. 14

    How to use regular expression result into another expression

  15. 15

    Store a sql query result in pentaho variable

  16. 16

    How to convert SQL statement to an expression in SSIS package

  17. 17

    Save Result of SQL Statement to Use Elsewhere

  18. 18

    How to use a $result variable with table object in SQL query using mySQLi

  19. 19

    How do I use an SQL Query Result as the value of a variable in Java?

  20. 20

    How to store query result (a single document) into a variable?

  21. 21

    How to store in a variable an echo | cut result?

  22. 22

    how to store result of tail command in variable?

  23. 23

    How to store sed result in variable in tcsh

  24. 24

    Python - How to store a Search Result (list) in a variable?

  25. 25

    how to store the result of a set operation into a variable

  26. 26

    How to store sed result in variable in tcsh

  27. 27

    how to store the query result into a variable in mysql

  28. 28

    How can I store the result of a function into a variable?

  29. 29

    Javascript - How to store result of the for loop into the variable?

HotTag

Archive