Thursday, July 14, 2005 - Posts

Converting a String Date

Converting a string date in the form YYYYMMDD to a date

This question comes up a lot. How to convert a date in string format to a date type.

You can write a simple derived column expression to parse this out and convert it to a date. You can set the derived column to replace the string date column or create a new one.

Here's the expression to do it:

(DT_DATE)(SUBSTRING(Date,6,2) + "-" + SUBSTRING(Date,8,2) + "-" + SUBSTRING(Date,1,5))

That will convert a string date column like this:

Date

Derived Column 1

20050112

1/12/05

20031122

11/22/03

20050509

5/9/05

20010101

1/1/01

20000301

3/1/00

20021003

10/3/02

20022002

2/20/02

19631003

10/3/63

19621002

10/2/62

20051111

11/11/05

Universe.Earth.Software.Microsoft.SQLServer.IS.KirkHaselden

 

Another blogger in the SSIS space...

Simon Sabin has been blogging a bit lately on SSIS with some pretty interesting things to say.

http://sqljunkies.com/WebLog/simons/default.aspx

Universe.Earth.Software.Microsoft.SQLServer.IS.KirkHaselden

A Jump Start to SQL Server BI

If you're interested in a good introduction to SQL Server BI offerings take a look here.

Windows IT Pro, Penton Media, the folks that put out SQL Server Magazine among others, have pulled together several articles to create this ebook as an introduction to SQL Server Business Intelligence technologies. There are introductory topics, essentials, as well as tips and tricks and practices articles from well known authors like Don Awalt, Brian Lawton, Rus Whitney, and Paul Sanders.

There are other ebooks available there as well. Take a look.

Thanks,

Universe.Earth.Software.Microsoft.SQLServer.IS.KirkHaselden

Contact Information and Robust Package Loading

Contact Information and Graceful Load Failover

One of the new, less visible features of Integration Services is what we call robust package loading or graceful load failover.

Ever try to open a package and have it fail. How do you fix it? You can't load it into the designer, so you end up plowing through the package XML trying to figure out what went wrong. Or, maybe you moved the package to a different machine and it references a custom task you wrote that isn't installed on the machine. Loading such a package was sure to fail in earlier builds.

Graceful load failover and contact information are two features aimed at reducing the occurance of these kinds of loading problems or at least, simplifying their resolution.

Graceful load failover is what the object model will do when a component that is referenced in a package is not installed on the machine. When the package attempts to load a component like a transform or a task, it will check to see if it succeeded. If not, it will capture the failure and emit an error but continue to load the remainder of the package.

Contact information is a feature that allows components to describe themselves. Look at the XML for any package with stock tasks in it and you'll see the contact information for the task as part of the task's XML. If the task or other object fails to load, the package will retrieve the contact information for the component and build an error with the contact information embedded.

Try It
To see this at work, try this:

  • Build a package with a SQL Task.
  • You don't need to modify it or anything, just drop in on a new package
  • Save the package and close it
  • Open the package by right clicking on it in the solution explorer and selecting "View code"
  • Find the SQL Task node.
  • Change the creation name in some way to make it invalid. I added two periods where there should be one.
  • Save the package
  • Restart BIDS 
  • Now, attempt to load it into the designer again

The package will look the same. The task will be there, but you should also get an error message box telling you that there were errors loading the task and that the package didn't load successfully. What's happening under the covers? In this case the runtime gets as much information about the task as possible and creates something that looks like the SQL Task. Try to run the package and it will fail, but at least, now, you know that there was a SQL Task there and that it's invalid.

Contact Information

If you look in the errors window, usually down below, you'll see an error something like this:

Error 4 Validation error. Execute SQL Task : The task has failed to load. The contact information for this task is "Execute SQL Task; Microsoft Corporation; Microsoft SQL Server v9; © 2004 Microsoft Corporation; All Rights Reserved;http://www.microsoft.com/sql/support/default.asp;1".   20008242.dtsx 0 0 

You Can Too
If you're writing a custom task, you can add contact information as well.

The TaskContact information is provided by adding it as an element in the DtsTask attribute. The SQL Contact information looks like this:

TaskContact = "Execute SQL Task; Microsoft Corporation; Microsoft SQL Server v9; © 2004 Microsoft Corporation; All Rights Reserved;http://www.microsoft.com/sql/support/default.asp;1"

Similar attributes exist for the other component types as well.

What's The Idea

The idea behind the contact information is, if one of your customers has a package with one of your custom components in it, and it fails to load, they have all the information they need to recover the component. The contact information is just a string. Microsoft recommends the format shown, ie. Task name, company name, Product name, copyrights, and website. For your component, you could actually place a link directly to the web page dedicated to the resolution of the problem or one having contact information etc. It's really up to you. It's free form text to provide information to your customers for how to trouble shoot the problem.

Summary

Integration Services provides a way to recover broken packages and discover what components may be causing the break.

Patents are pending. :)

Universe.Earth.Software.Microsoft.SQLServer.IS.KirkHaselden