Summary: An ETL process which moved data from a new application to a legacy one, encountered errors in date columns. Since there were multiple data types and insufficient validation by the user application, a quick check of numerous date columns was necessary. This stored procedure provides a quick scan of all columns in a table or range of tables, displaying the minimum and maximum values for all Date, DateTime, and SmallDateTime columns.
Detail: A new application for tracking IT projects used a DATE datatype for the numerous dates recorded in any given project. Unfortunately, since DATE allows values from "0001-01-01 through 9999-12-31" (http://msdn.microsoft.com/en-us/library/bb630352.aspx ) and the user application did no validation, a mistyped date caused issues for an SSIS process that moved data to legacy tables in which som columns were datatype SmallDateTime. This datatype will only accept values from "1900-01-01 through 2079-06-06" (http://msdn.microsoft.com/en-us/library/ms182418.aspx )
Since the error can be the results of values in several dozen columns, a quick snapshot of minimum and maximum values seemed useful. This stored procedure provides that quick inspection. Here is an example of its usage - note that one of the columns will pose a problem: