Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Source for SSIS

Posted on 2014-04-14
4
Medium Priority
?
313 Views
Last Modified: 2016-02-10
Hello:

I'm planning on creating a TSQL view containing data that will be extracted by SSIS.  The first section of the view is to be a header section of about five fields.  The next four sections will be the body of the data containing anywhere from eight to thirty fields.  The final section will be a footer of about three fields.

First, is it possible to create a TSQL view containing sections with different numbers of fields like this?  If not, what other solutions are there?  I have created views many times in the past, with UNION ALL statements, but each statement separated sections that contained an equal number of fields.

Secondly, is it possible to tell SSIS to not pull column headings when extracting data from SQL?

Ultimately, I want to create a text file from SSIS that will be uploaded by a bank.  Banks have very strict requirements as to the format of the data in such files.

Thanks!

TBSupport
0
Comment
Question by:TBSupport
  • 3
4 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 39999071
>I'm planning on creating a TSQL view containing data that will be extracted by SSIS.
Ok.

>The first section of the view is to be a header section of about five fields.  The next four sections
Unless you have Super Ninja T-SQL skills, it's asking a lot of a view to contain multiple sections with varying fields in each section.  Better to create a view for each section, with a 'sort_order' column that goes something like 1 for the header, 2 for a group header, 3 for the detail, 4 for the footer, you get the idea.  

Then in your output write all columns as one, with an 'ORDER BY sort_order' to write the header, detail, etc. in the correct order.

>is it possible to tell SSIS to not pull column headings when extracting data from SQL?
Yes, eyeballeth the connection properties.
0
 
LVL 1

Author Comment

by:TBSupport
ID: 39999092
Thanks for the quick response, Jim!  Excellent!

Can you please elaborate on the following:

...in your output write all columns as one, with an 'ORDER BY sort_order' to write the header, detail, etc. in the correct order?

I don't understand how to get the TSQL syntax to accommodate this.  I thought that "ORDER BY" was forbidden in views.

Thanks, again!

TBSupport
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 39999118
Trying to remember a previous project where I pulled this off, so bear with me.
The ORDER BY isn't in a view, it's in a SELECT that writes to the destination.

Source
Three views, essentially a header, detail, and footer view.
After the Source I had a merge join, that went something like this..

SELECT 1 as sort_order, column_1 + column_2 + column_n as the_row
FROM v_header
UNION ALL
SELECT 2, column_A + column_B + column_C + column_KIIJR
FROM v_detail
UNION ALL
SELECT 3, column_banana + column_grape
FROM v_footer

Destination
SELECT the_row
FROM {my table}
ORDER BY sort_order
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 39999424
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My client sends a request to me that they want me to load data, which will be returned by Web Service APIs, and do some transformation before importing to database. In this article, I will provide an approach to load data with Web Service Task and X…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question