Update year 2015 calender for AdventureWorksDW2014
Does anybody have scripts for updating DimDate for adding
March 27th, 2015 12:49pm

HI,

You can modify this script by

Avatar of Stefan Hoffmann Stefan Hoffmann

wrote in this topic

WITH Numbers ( N ) AS
    (
        SELECT ROW_NUMBER() OVER ( ORDER BY A.object_id )
        FROM sys.objects A, sys.objects B, sys.objects C
    ),
    Dates ( D ) AS
    (
        SELECT    DATEADD(DAY, N - 1, '1970-01-01')
        FROM    Numbers
        WHERE    DATEADD(DAY, N - 1, '1970-01-01') <= '2099-12-31'
    )
    SELECT    CAST(CONVERT(VARCHAR(8), D, 112) AS INT),
            MONTH(D),
            YEAR(D),
            YEAR(DATEADD(MONTH, 4, D)),
            'Q' + CAST(DATEPART(QUARTER, D) AS CHAR(1)),
            'Q' + CAST(DATEPART(QUARTER, DATEADD(MONTH, 4, D)) AS CHAR(1)),
            D
    FROM    Dates
    WHERE d between '20150101' and '20160101'


Free Windows Admin Tool Kit Click here and download it now
March 27th, 2015 2:51pm

Thanks Vitaliy.

I got overflow error for column 'datetime' when I runned your script. 

March 27th, 2015 2:56pm

Kenny,

Error or warning

Can post it?

Free Windows Admin Tool Kit Click here and download it now
March 27th, 2015 3:01pm

Are you sure that this works with AdventureWorksDW2014?

Msg 517, Level 16, State 1, Line 1
Adding a value to a 'datetime' column caused an overflow.

March 27th, 2015 3:42pm

Yes i'm. Modify columns in query and use it, very helpfull query :-)

Free Windows Admin Tool Kit Click here and download it now
March 30th, 2015 2:00am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics