I have two excel source on one excel file 1st fetching value date and 2nd fetching value price
now i have tried merge then union all also to get those two values in one derived column
but when i execute my package it is inserting values separately.
like this into two rows one by one but i want to insert these two values in one row only.
for example this is my problem:
date price
12-12-2001 null
date price
null 54
but i want it in one row only like
date price
12-12-2001 54
Create two derived columns with the same value (i.e. call them id1 and id2 and set both to have a value of 1).
Change the sort to sort by the new id columns.
Change the merge component to a merge join and use the newly created ids to link the data based on an inner join
which will give you a single row
Related
I have created a new column in the "destination" table with the same name, datatype and other values as appear in the "source" column in a different table. I have tried many suggested solutions as found on stackoverflow. This one appeared to work (found on Quora) but when I went to the destination table the previously empty column remains empty with nothing but NULL values noted. This is the Quora suggestion:
you can fill data in column from another existing one by using INSERT INTO statement and SELECT statement together like that
INSERT INTO `table1`(column_name)
SELECT column_name FROM `table2`
here you filled a single column in table 1 with data located in a single column in table 2
so if you want to fill the whole table 1 (all columns) with data located in table 2 you can make table 1 like a copy of table 2 by using the same code but without column name
INSERT INTO `table1`
SELECT * FROM `table2`
but note to do this (copy table content to another one) ensure that both of tables have the same column count and data types.
I'm not sure what is meant by column count (do the two table have to have the same number of columns?)
When I run it I get error # 1138.
Any help greatly appreciated. -JG
I am trying to use the lookup transformation but can not seem to get the functionality out of it that I need. I have two tables that are the exact same structure
Temp Table (input): Smaller table but may have entries that do not exist in other table
Reference Lookup Table: Larger table that may not have identical entries to Temp Table.
I am trying to compare the entries of the Temp Table to the entries of the Reference Lookup Table. Anything that exists in the Temp Table, but not the Lookup should be output to a separate table (No match output).
It is a very simple Data Flow, but it does not seem to accomplish the lookup properly. It will find "No Match" rows, but the "no match" table is populated with null values for every column. I am trying to figure out why the data is losing its values?
How the Lookup is setup:
The data in temp table is what drives your data flow. 151 rows flowed out of it.
Your lookup is going to match based on whatever criteria you specify and you've identified that if there is no match, I want to push the no-match data into a table.
Since the lookup task cannot add columns to the no-match output path, this would imply your source (temp table) started NULL across the board.
Drop a data viewer/data tap onto the data flow between the lookup and the destination and then compare that data to your source. I suspect you're going to discover that the process that populated Temp table is at fault.
In the Lookup Transformation, in the columns tab you have identified that you want to use the value from the reference table to replace the value from the source.
Which works great until you get a no-match. In which case, the component is going to do the non-intuitive (even to me with 15+ years of working with it) action of update that column whether it matches or not.
Source query
SELECT 21 AS tipID, NULL AS tipYear
UNION ALL SELECT 22, 2020
UNION ALL SELECT 64263810, 2020
This adds three rows to my data flow, the first with no tipYear and the next two rows with a year of 2020. Stamp of 1 in the below image
Lookup query
SELECT
*
FROM
(
values (20, 1111), (21, 2021), (22, 2022)
)D(tipID, tipYear)
This reference data will supply a year for all the matches (21 and 22). In the matched path, we'll see 21 supplied with a value and 22 will have its year updated. Stamp 2 in the image
For id 64263810 however, no match will be found and we'll see the initial value of 2020 replaced with the matching row aka NULL. Stamp 3
Lessons learned. If you need to use the data from the reference table but have a no-match output path, do not replace column in the lookup transformation (unless your intention is to wipe out data)
I have added a new column as "DateOrder" to my existing table called "orders" and I need to add (insert) data to the new column.
The only way I have found is using the "Update, Set, Where" syntax, however, it forces me to add values each by repeating the syntax.
I would appreciate if you help me how I can insert all my values at once.
Four rows only? Then use CASE WHEN in the SET clause:
update orders
set dateorder =
(
case id
when 1 then date '2018-10-13'
when 2 then date '2017-08-24'
when 3 then date '2019-01-11'
when 4 then date '2018-02-02'
end
);
Don't store dates as integers. Store them as dates as shown.
Initially, while creating the new column set a default value to it. And see if it has any binding with others. Then after you can directly insert new values to new records and update previous records just by update.
I'm trying to insert rows using the same last values of rows in the column name bill period.
this is my desired result, and after the billperiod 3 it goes into 4 taking the data rows of billperiod 3.
I tried other solution where I used the other table to use it as a where but this are the results.
but It didn't work, here is the image of my other table
We have a SSIS package that does a union all on 2 tables and we need to get rid of duplicate rows if the row is a duplicate and a column value is null. Any ideas?
You can use the aggregate component to group by all the columns resulting in a distinct list for you destination
You will also need to use a conditional split to branch the null column away from your target table as follows