sql server 2008 - How to extract from multiple tables with different structure to one flat file? -
I have to follow three tables, which can be connected using common columns, keys and they have different There are columns.
Table 1 (key, colnA-1, colnA-2, ..., colnA-n) Table 2 (key, colnB-1, colnB-2, ..., colnB- M) Table 3 (key, colnC-1, colnC-2, ..., colnC-i)
I have to combine three tables and export a flat file like
colnA- 1, colnA-2, a, colnA-3, ..., colnAnn colnA-1, colnA-2, b, colnB-1, colnB-2,. .., colnB-M colnA-1, colnA-2, b, colnB-1, colnB-2, ..., colnB-m colnA-1, colnA-2, b, colnB-1, colnB-2,. .., colnB-m ... colnA-1, colnA-2, c, colnC-1, colnC-2, ..., colnC-i colnA-1, colnA-2, c, colnC-1, colnC- 2, ..., colnC-i colnA-1, colnA-2, c, colnC-1, colnC-2, ..., colnC-i ... A means that data in the remaining line From 1st to B, B means that the data in the remaining row is from table 2, etc.
My first question is it possible to write a question to do this? Join the three tables to create a final table with the structure as above, then I can use the SSIS to export the data from the last table to a flat file? My answer is probably not because table A has different structure of record from table B.
Another question is, because I am quite new to create an SSIS package, my only experience is to use SSIS to export / export SSMS, is there any one to achieve my goal Can SSIS share some ideas to create a package?
I do not really understand how you are joining in three tables to be more precise Attributes will be required.
The original idea is to go to
SELECT colnA-1, colnA-2, 'A', ..., colnA-1 select Union all from colnB- 1, colnB-2, 'B', ..., colnB-N from Table 2 Unius Select all colnC-1, colnC-2, 'C', ..., colnC-n to f1 table
If your datasets are incompatible, you have to use the CAST ()
statement to make them compatible.
When you are building a package and selecting a data source, choose an OLE DB source. In the configuration window, instead of choosing a table, select an SQL command. Then paste your working query into SSIS.
Comments
Post a Comment