Database Reference
In-Depth Information
[Date]
, [DateName]
, [Month]
, [MonthName]
, [Quarter]
, [QuarterName]
, [Year]
, [YearName]
)
VALUES (
-- [Date]
@DateInProcess
-- [DateName]
, Convert(varchar(50), @DateInProcess, 110)+', '
+ DateName( weekday, @DateInProcess )
-- [Month]
, Month( @DateInProcess )
-- [MonthName]
, Cast( Year(@DateInProcess) as varchar(4) )+' - '
+ DateName( month, @DateInProcess )
-- [Quarter]
, DateName( quarter, @DateInProcess )
-- [QuarterName]
, Cast( Year(@DateInProcess) as varchar(4) )+' - '
+ 'Q'+DateName( quarter, @DateInProcess )
-- [Year]
, Year(@DateInProcess)
-- [YearName]
, Cast( Year(@DateInProcess) as Char(4) )
)
-- Add a day and loop again
SET @DateInProcess=DateAdd(d, 1, @DateInProcess)
END
-- Check the table SELECT Top 10 * FROM DimDates
Note that we used SQL variables to indicate the range of our dates as starting on 1/1/1990 and ending on
12/31/1995. This may seem odd, but if you look at the dates in the Pubs database, you will see that all of the dates
are within this range.
Dealing with Nulls
Null values represent a special challenge because there are many different opinions on how to handle them in a
data warehouse environment. Because of their very nature, nulls present you with multiple options, and it's up
to you to sort out which approach works best in a given case. Nulls are most often considered to be an unknown
value, but what does the term unknown really mean? Does it mean that it is unknowable and could never be
known? Does it mean that is unknown at the moment but will soon be available? Does it mean that a value just
does not apply in this particular instance? Any of these can be true: the value may not be known, may be missing,
or may not be applicable.
 
Search WWH ::




Custom Search