Focusing on setup and development using SQL Server products from 2000 to 2008 and beyond. Also about anything geeky that compels me to write a blog entry.

Showing posts with label SSIS. Show all posts
Showing posts with label SSIS. Show all posts

Saturday, May 12, 2012

SQL Saturday #112 - Birmingham 2012

Today was another great SQL Saturday in Birmingham.  A day packed full of meeting other SQL professionals, good food, and great sessions of information.  If you have never been to a SQL Saturday and you are reading this blog, you should go.  Here is a quick run down of the sessions that I attended today.

Time Saving Tips & Tricks for SSMS 2012 - Aaron Nelson
What's New in SSIS 2012 - Christopher Price
SQL Server 2012: What's New - Bob Cheatham
Data Quality Services 2012 - Chris Price
Introduction to FileTables - Sven Aelterman
Windowing Functions: The Reason to Upgrade to 2012 - Kevin Boles

As you can tell, it was a great day for learning more about SQL 2012.  


Check the site and find a session near you.  You will not regret it.

Saturday, July 30, 2011

SQL Saturday #81 Birmingham

Today I had the great pleasure of meeting other SQL Server professionals from all over the Southeast, and listening to some great presentations on everything from design and statistics to the upcoming SQL "Denali".

We had five different sessions to choose from in each of the six time slots. My choices today were

Database Design
SQL "Denali" High Availability
SQL Statistics
Building a Professional Development Plan
Table Partitioning
Advanced DW Scenarios in SSIS

It was not just informative. These events are about networking and being a part of a community centered around the SQL Server product. Plus, on top of great sessions and door-prizes, we were provided with coffee, doughnuts, sodas, and a nice box lunch. If you have not been to one, I highly recommend it.

Sunday, July 24, 2011

Upcoming SQL Saturday in Birmingham, AL

It is time for year three of the incredible FREE training day on SQL Server in Birmingham, AL.  This event has grown each year across the country, and this year will be no exception.  If you are anywhere in the Southeast region, I recommend you make the trip to Birmingham on July 30th.  Otherwise, please go to the main site and find a SQL Saturday closer to you.  You owe it to yourself to take advantage of these free events to continue your professional development and take advantage of networking with other SQL Server professionals.

http://sqlsaturday.com/81/eventhome.aspx

Monday, December 28, 2009

Redirecting SSIS Data Errors to Avoid Package Failure

When setting up a new Integration Services package, is it often advantageous to leave your errors untrapped so your package crashes and you can interpret the errors. But after you get past the first wave of setup, it is often best to trap for additional data errors in your code to prevent complete package failures.


So how do you do it? I'll cover it in broad strokes.

I start with my source table structure. In order to capture error output, I want to create a table that matches the field names of the source table, but not the data type. The idea is to have a table that is so wide open, it can handle any data you throw at it.

For example, the source table, lets call it T1 has these fields:
ID Int Not Null
Name varchar(30) Not Null
Addr varchar(40) Not Null


To handle error output, you would create a table (T2) with these fields:

ErrCode varchar(100) Null
ErrColumn varchar(100) Null
ID varchar(100) Null
Name varchar(200) Null
Addr varchar(200) Null

Let's go over the noteworthy differences. First I added the ErrCode and ErrColumn fields which will be populated with data from the SSIS error handling.


Most importantly, I changed the data types on all fields to varchar fields and made sure the size was big enough to handle even bad data. Depending on your situation, you may adjust these sizes much larger to accommodate the worst possible over sized data records.


Lastly, I allowed Nulls in all of the columns to ensure that every field of data in the row with errors can be stored in the error table, regardless of Nulls.


Now that the structure is in place, it is time to add to the SSIS package. In the Data Flow where you are pulling from your source table, in our case the nondescript T1 table, we must add the error output. Within the data flow section, drag a destination object from the toolbar that connects to your new T2 table. Then click on the Source object that connects to T1 and drag the red line from the bottom of the object to the T2 Destination box.

If you edit the Error Output in the T1 Data Source, you can specify what should be done with each column of data. You can have a column cause the package to fail on error, ignore the error, or redirect the error output, which is the option we want to use. By redirecting all columns on error, they become available to consume in your T2 table data destination.

Now that the red line is attached, you can edit the properties in your T2 destination to insure that the ErrCode, ErrColumn, and all other fields are mapped properly from your error output to your T2 fields. Once you have the mappings all established, you should be ready to run.

To me the great benefit of this type of error handling comes in dealing with bad data that you are pulling from production databases into secondary aggregate, data warehouse, or reporting databases. It allows you to get most of the data into the primary tables and the leisure to review the bad results afterward. Of course, if the data you are pulling has data requirements that would make partial data useless, you must consider this when considering the error output option. Regardless, using error output is an excellent way to troubleshoot as you are developing a new SSIS package.

Tuesday, December 22, 2009

SSIS Package Credentials

This is a great article on setting up SSIS Package Credentials, which is more involved than the old DTS days. If you need to schedule your SSIS packages, read this article and it will save you a lot of troubleshooting time.

http://www.sqlservercentral.com/links/81443/131962

Saturday, November 14, 2009

Conditionally Blocking Scheduled Reporting

As is true for many DBAs, I have developed a custom set of SSIS packages along with a database that manages scheduled Reporting Services reports. It delivers to a mixture of email recipients and FTP locations after generating the output PDFs and Excel results.

Then came the inevitable weekend of trouble. The set of SQL Server 2005 databases, which provide the data for the reports, failed to load due to trouble with the source legacy systems. However, since the data in the SQL Server databases still contained yesterday's data, the report schedule had no problem completing the scheduled reporting.

Therein lay the problem. I did not want any reports to generate, or worse yet email to recipients, if the recent day of data was not included.

The solution is fairly simple. The SSIS packages that load the SQL Server databases were logging to a table, and included a special status column. When each database was finished loading and had completed any subsequent updates required, a log entry with a status of DONE and UPDATED were entered. I just created a stored procedure to scan the log for databases that were scheduled to be loaded, filtered by UPDATED, and with a log time that fit into the correct date/time range for the current day's data load.

If the stored procedure found any records that did not meet the above criteria, it returned a result reporting accordingly. Then I just added a call to this stored procedure in my primary scheduled reporting stored procedure, where the list of scheduled reports to process is generated. If the data load check reported problems, I prevent the scheduled reports from processing. Then once the problem with the data load is resolved and all data is available, all I have to do it run the SQL Agent job that runs the scheduled reports and this time it will succeed.

I'm always a fan of a little more work in the back end to make a little less work for the routine. Not to mention, you don't have to answer Fred's email asking, "Why did I get two emails of the same report, and which one is right?"