SQL Query on transformed table in SSIS - ssis

I have joined 5 tables and done transformation on these tables. Now I got a single table at the end. Now I want to perform sql query on this single table to filter records. But I don't know how to perform simple sql query on this table. I have attached a snap shot which shows the resulting table. How I get this resulting data set as the source? I want to populate my destination after filter out this data.
I am using SSIS 2008.
Click here to see the Table on which I want to perform a simple sql query

SELECT * FROM `first_table`
where `some_column` =
(
SELECT `*`
FROM second_table
WHERE
`some_column2`='something'
LIMIT 1
)
Try this code This will help. You can even use this to connect all those four tables with each other.

From the image you posted, it looks like you have a set of data in the dataflow you're trying to query against. You need to do one of two things at this point. Either you insert the data into a table in the database and use another data flow to query it, or you use use a conditional split (or multicast and conditional splits) to filter the rows down further from there.
Without more detail about what you're actually trying to accomplish, these are the recommendations I can determine.
You could send the rows into a record set destination, but you aren't able to query it like a regular table and you'd need some C#/VB skills to access it to do more than a FOR EACH loop.

Assuming your sql query that you want to run against the resulting table is simple, you can use a script component task. By simple, I mean, if it is of this nature:
SELECT * FROM T WHERE a = 'zz' and b = 'XX' etc.
However, if your query has self joins, then you would be better of dumping the outcome of joining those 5 tables in to a physical table, and go from there.
It appears that query is going to be real straight-forward; in that case using a script component would be helpful.
A separate question: It's advisable to do the sorting at the database level. You are using 5 sort tasks in your solution. Can you please elucidate the reason?

Related

How to add a calculated field in a group by in access?

I am attempting to combine two groupings(sum), EPL and POL and relabel them as something, say "Other GL". The current output is this. I've attempted adding a formula in the criteria but it is not working. I have also attempted adding another column in the design view with a formula alone.
The best way to "combine" data rows for grouping (i.e. sums) is to create a preliminary query which reassigns the individual source rows to a common value. Then use that query as the source for the other query(ies). (Such a preliminary query could be either a nested query -a.k.a. subquery-, or a saved query. I personally prefer saved queries since they can be edited and viewed using the standard Access Query Designer, whereas subqueries can only be edited as SQL text.)
Without other database schema or SQL statement to work with, all I can show is a SQL snippet showing the altered selection:
SELECT iif(Claims2.Grouping = 'EPL' Or Claims2.Grouping = 'POL', 'Other GL', Claims2.Grouping) As AltGrouping, ...
FROM Claims2
For what it's worth, the same iif() statement could also be inserted directly into the your query as a "calculated field"--within the query designer just copy and paste it into the Field cell in place of Grouping. But a saved query that adjusts labels preliminary to final queries can be reused and makes later queries simpler.

Prioritize Bulk Insert in a table using Union all in ssis

I have multiple archive tables storing similar kind of data in these tables but archived in the month wise format. Now, the requirement is to get all the archived data in to one table instead of multiple tables.
I am doing this activity with the help of Union all in SSIS, however it seems that it is taking random insert in the destination table.
Attach is the route taken for the transformation.
I want to prioritize the insert, please suggest!
You can add an extra column "Priority" to each of OLE DB sources with the corresponding priority for each source and then after union you can add Sort Component that sorts the data by Priority. But if you have a lot of data - that would be really inefficient because sort component will wait until all the source data is read.
I would suggest to write a proper source SQL statement that does the union/prioritization/sort for you and then insert into target.
Also if the sources are on different servers you can create Foreach loop container that will iterate through source tables and inset all of them into the target table. You can use this article for the reference.

limit sql results via table selections

I am curious if it is possible to limit the results of an sql select statement by joining another table with selectable options. ie. Have one table that a user can use to update their preferences such as display a,c,d and do not display b and e. (assuming the table would only have columns a-e) (this has is separate from the question). Once the user has updated / selected their options im curious if i can create an sql select statement that would fetch the results of another table based off of the options selected by the user in the first table. I know can can create a larger statement that would include all of the results and omit them if the value is not provided. im curious if there is a way to only select particular columns based off of another table
im curious if there is a way to only select particular columns based
off of another table
No. Queries cannot have varying columns. Technically, you can make a stored procedure do something like that; but it is considered a rather poor practice.
...and doing it the right way is likely not going to be a "larger statement".

MS-Access Form for multiple queries

Ok here is my dilemma and I am sure more experienced Access users have an easy solution. I have been manually running a set of queries to pull data for business users, that I want to create a form for so they can just run it themselves. This would be easy if it was one query, but the way I have to pull the correct data is first have to run one query that creates a table. I then use that 'new' table in a secondary query to get the data I need.
That first make table query needs to take inputs like supplier number and date range. I then use that output table in another query that sums up total dollar value of purchase orders. I can not include these two steps in one query as it creates an ambiguous outer join.
Any ideas on how I would go about creating a form for something like this?
Well after re-thinking this I think I was OVER thinking it. Instead of creating a table in the first step, I can just save it as a query and join that query to the second query. Then make a form off the two queries.

Access 07 VBA Get Table by Path

Is it possible to reference (in VBA) a non-linked Access table by its full path?
For instance, say you're building a form that draws from a set of tables, but your user needs to add tables as time goes on; you might start with tableA, tableB, and tableC, but a year down the line tableZ might exist.
The goal then becomes finding a way to reference the newly-added tables without needing to add them as external data sources if possible; [how] can this be done? (My particular case involves using the tables as RowSource values, if that's significant.)
I was thinking something along the lines of
control1.RowSource = "X:\database\databaseName.accdb" & [???]
might work, but I really have no idea what would go in the brackets.
Within an Access query, there are 2 ways to reference an unlinked table in a different Access database.
SELECT YourTable.some_field
FROM YourTable IN 'X:\database\databaseName.accdb';
or ...
SELECT YourTable.some_field
FROM [X:\database\databaseName.accdb].YourTable;
I think you can get what you want if you use a similar query as your RowSource. (Control.RowSource = "SELECT ...")