Solved

SQL Source for SSIS

Posted on 2014-04-14
4
280 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 65

Accepted Solution

by:
Jim Horn earned 500 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 65

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 65

Expert Comment

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

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

813 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now