I have a data set which is of following format in excel
Col A Col B WW1 WW2 WW3.... WW51 Ww52
The columns A & B has text values and WW1 to WW52 has numeric values. This data is unpivoted to the following format into a SQL staging table
Col A Col B CurrentWW WorkWeeks Qty
The WorkWeeks column will have 52 workweek values including the current work week in the format yyyyww and Qty as numeric. A sample data set will look like as follows :
ColA ColB CurrentWW WorkWeeks Qty
US01 ABC 201717 201717 1
US01 EFG 201717 201718 1
US01 HIJ 201717 201719 2
and so on.. until the 52nd workweek starting from 201717.
How can I achieve this in SSIS?
I have tried the following options - Lookup,Merge Join,Union all.. but it joins with the first row only. I know Im very close but still missing something. Any help would be appreciated.
What is your end result (flat file, Excel file, sql table, etc)? You could always load the Excel file into another staging table and then join the two tables using SQL. That may help reduce the complexity since I know joining two sources with SSIS can sometimes be a pain.
Related
How to append specific data in flatfile destination using SSIS package loop iterate?
Source: emp (SQL Server) sample data. In this table I have 1 million records
I need to load specific empid information into flat file destination using loop iterate.
Sample data
empid | Ename
------+---------
1 | ab
2 | dg
3 | hg
Load the specific empid information maintain in empmaster table.empids values frequenctly changing in empmaster table
Table: Empmaster
Empid
-----
1
2
5
6
Destination: text files emp.txt
empid | Ename
-------+--------
1 | ab
2 | dg
I tried like this:
Step 1: create 2 variables empid (datatype varchar) and empidresult (datatype object)
Step 2: drag and drop the ExecuteSQL task and using oledb connection and SQL command is: select distinct empdid from empmaster and resultset is: fullresultset and resultset variable select the empidresult
Step 3: drag and drop the foreachloopcontainer and container type is foreachadoenumerator adoobjectsource variable is: empidresult and variable mapping is: empid
Step 4: inside container drag and drop the dataflow task and using oledb source connection SQL statement with parameters
select empid,ename from emp where empid =? and parameter mapping to empid
Step 5: drag and drop flatfiledestination and configure emp.txt file
here I select the columns names in the first data row unchecked and overwrite data in the file unchecked and executed the package i can append the data for required empids data but header is missing
I tried another methods empmaster records i have converts rows to columns and result store into object with commasepareate buts its supporting only up to 9000 records
if master table have more than 10,000 records then its not working
I need first row as header then remain each loop iterate should be data append in destination files.
How to achive this task in sql server?
what's wrong with a data flow sourced by:
SELECT empid,ename
FROM emp
JOIN Empmaster on emp.empid = Empmaster.empid
and then just run that into a flatfile output.
Looking at how to output a certain way.
Right now this is how SSRS outputs my table:
Output1
This is how I would like the table to output:
My expected output
Use Matrix and define the field with ID (777xxx) in the column group
I replicated your Data into my local Report. First step you data is something like below
ID CITY PRIMARYORELEMENTARY
7777888 Houston,TX Elementary
7777889 Houston,TX Elementary
7777890 Mumbai,IN Primary
7777891 Delhi,IN Elementary
Now you could so in your SSRS something like below.
Insert and then matrix
After you have matrix then you see matrix as below. Then in column select ID
Now select Rows and then add row inside group below
Now select Primary Element and City in two rows 1 after another.
Once you follow all the steps, below is how you will get your Report
Let's consider simple Excel table associated with SQL Server's table:
ID some_data
0 a
1 b
2 c
I'd like to extend it with manually added column (not present in SQL Server's table):
ID some_data my_column
0 a some_data_for_0
1 b some_data_for_1
2 c some_data_for_2
However, when source data are changed (rows inserted / deleted / updated) the relation between my_column and ID column is not preserved. For example, when new row (3, d) is added:
ID some_data my_column
0 a some_data_for_0
1 b some_data_for_1
2 c
3 d some_data_for_2
Is there any Excel built-in solution that would allow me to specify how my_column rows should be ordered in relation to ID column or do I need to implement it by myself using VBA?
You could use an ORDER BY clause in your SQL statement, but even that's not very reliable. The only reliable way to do this is store your additional data in its own table and use a formula to relate it to the SQL data.
On a separate worksheet, put
ID my_column
0 some_data_for_0
1 some_data_for_1
2 some_data_for_2
Now in a column adjacent to the SQL data, put
=IFERROR(VLOOKUP([#ID],tblAddtlInfo,2,FALSE),"")
However the SQL data is sorted, the additional info will be in the right row. This assumes you made your additional info list into a table and named it tblAddtlInfo.
If you want to get fancy, you can write some code in the Change event that looks for non-formulas in the extra column. If the formula gets over written, then grab the new data, add it to (or update) your additional info table, and restore the formula. Then you can type the data in the row, but maintain the integrity by moving it to a different table.
I would like to do data mining. But my data is not useful.
my table structure is something like:
date customerid age residence prosubsclassid productid
----------------------------------------------------------------------------
21.11.2001 123232323 a b 2099 23232322
amount asset sales
------------------------
4 34 56
Now I have to show the data in this way:
prosubsclassid 130207 130208 130209
------ ------ ------
1413232 1 3 1
3435545 2 1 2
3534344 3 1 sum(amount)
Column(customerid)
I want to convert to tabular form in my data.
There is no automatic way to do this. There are support for pivot in SQL server, but the columns still needs to be specified.
Depending on if you want to have a text report or a table with dynamic columns I would group the data per date and prosubsclassid and then using a cursor to build the data.
If you want a dynaic table build a dynamic sql query based on the grouped data and run Exec.
If you want text report, just concatenate the string data the way you want per line into
a temp table with one textcolumn and when you are done, select the table.
I have the following table ,
Database Table:
BatchID BatchName Chemical Value
----------------------------------------------
BI-1 BN-1 CH-1 1
BI-2 BN-2 CH-2 2
----------------------------------------------
I need to display the following table.
BI-1 BI-2
BN-1 BN-2
-----------------------------------------
CH-1 1 null
------------------------------------------
CH-2 null 2
------------------------------------------
Here BI-1,BN-1 are two rows in a single columns i need to display chemical value as row of that.Could Please help me to solve this problem.
I tried it in Pivot table but i unable to get this.
So is there any chance in Reporting Server MDX.
First, you need to create a cube with Analysis Services (MDX only works against multidimensional data sources)
Then, assuming you have a cube "MYCUBE" with "Batch" and "Chemical" dimensions and a "Value" measure, the query would be something like this (of course, you could select just the members you need instead of all the members in the dimensions):
SELECT
{[Batch].members * [Measures].[Value]} on columns,
{[Chemical].members} on rows
FROM [MYCUBE]