Reporting stops working after upgrading from Service Manager 2012 SP1 to R2

After upgrading Service Manager 2012 from SP1 to R2 Reporting stops working.
 
Looking at Data Warehouse - Data Warehouse Jobs in the Service Manager Console some of the jobs are listed as Failed, amongst them, Load.Common, Load.OMDWDataMart and Load.CMDWDataMart.
 
After a great deal of Googling I came across this site:
 
http://technet.microsoft.com/en-us/library/dn299381.aspx
 
Stating the it's a known issue and that all you need to do is to run a SQL-script against 4 databases on the Data Warehouse server.
 
The databases are:
 
- DWRepository
- DWDataMart
- CMDWDataMart
- OMDWDataMart
 
The script:
 
IF OBJECT_ID('tempdb..#PKFixQueries') IS NOT NULL
    DROP TABLE #PKFixQueries

;WITH FactName
AS (
        SELECT  w.WarehouseEntityName
        FROM    etl.WarehouseEntity w
        JOIN    etl.WarehouseEntityType t ON w.WarehouseEntityTypeId = t.WarehouseEntityTypeId
        WHERE   t.WarehouseEntityTypeName = 'Fact'
),FactList
AS (
    SELECT  PartitionName, p.WarehouseEntityName
    FROM    etl.TablePartition p
    JOIN    FactName f ON p.WarehouseEntityName = f.WarehouseEntityName
)
, FactWithPK
AS (
    SELECT  f.WarehouseEntityName, f.PartitionName, b.CONSTRAINT_NAME, a.COLUMN_NAME
    FROM    FactList f
    JOIN    INFORMATION_SCHEMA.KEY_COLUMN_USAGE a ON f.PartitionName = a.TABLE_NAME
    JOIN    INFORMATION_SCHEMA.TABLE_CONSTRAINTS b ON a.CONSTRAINT_NAME = b.CONSTRAINT_NAME AND b.CONSTRAINT_TYPE = 'Primary key'
)
, FactWithDefaultOrNoPK
AS (
    SELECT  DISTINCT f.WarehouseEntityName, f.PartitionName
            , 'PK_' + f.WarehouseEntityName AS DefaultPKConstraint
            , 'PK_' + f.PartitionName AS NewPKConstraint
    FROM    FactList f
    LEFT JOIN    FactWithPK pkf ON pkf.WarehouseEntityName = f.WarehouseEntityName AND pkf.PartitionName = f.PartitionName
    WHERE   pkf.WarehouseEntityName IS NULL OR pkf.CONSTRAINT_NAME = 'PK_' + f.WarehouseEntityName
)
, FactPKList
AS (
    SELECT  DISTINCT f.WarehouseEntityName, f.COLUMN_NAME
    FROM    FactWithPK f
)
, FactPKListStr
AS (
    SELECT  DISTINCT f1.WarehouseEntityName, F.COLUMN_NAME AS PKList
    FROM    FactPKList f1
    CROSS APPLY (
                    SELECT  '[' + COLUMN_NAME + '],'
                    FROM    FactPKList f2
                    WHERE   f2.WarehouseEntityName = f1.WarehouseEntityName
                    ORDER BY COLUMN_NAME
                    FOR XML PATH('')
                ) AS F (COLUMN_NAME)
)
SELECT  f.PartitionName,
        '----------------------------- [' + f.PartitionName + '] -----------------------------' + CHAR(13) +
        'IF OBJECT_ID(''[' + f.DefaultPKConstraint + ']'') IS NOT NULL' + CHAR(13) +
        'BEGIN' + CHAR(13) +
        '  ALTER TABLE [dbo].[' + f.PartitionName + '] DROP CONSTRAINT [' + f.DefaultPKConstraint + ']' + CHAR(13) +
        'END' + CHAR(13) + CHAR(13) +
        'IF OBJECT_ID(''[' + f.NewPKConstraint + ']'') IS NULL' + CHAR(13) +
        'BEGIN' + CHAR(13) +
        '  ALTER TABLE [dbo].[' + f.PartitionName + '] ADD CONSTRAINT [' + f.NewPKConstraint + '] PRIMARY KEY NONCLUSTERED (' + SUBSTRING(pk.PKList, 1, LEN(pk.PKList) -1) + ')' + CHAR(13) +
        'END' AS Query
INTO    #PKFixQueries
FROM    FactWithDefaultOrNoPK f
JOIN    FactPKListStr pk ON pk.WarehouseEntityName = f.WarehouseEntityName

DECLARE @PartitionName NVARCHAR(MAX), @Query NVARCHAR(MAX)
WHILE EXISTS (SELECT 1 FROM #PKFixQueries)
BEGIN
    SELECT  TOP 1
            @PartitionName = PartitionName,
            @Query = Query
    FROM    #PKFixQueries

    PRINT   @Query
    EXEC(@Query)

    DELETE  #PKFixQueries
    WHERE   PartitionName = @PartitionName
END
 
After running the script against these 4 databases, start the jobs in the Service Manager Shell using the command Start-SCDWJob -JobName Load.Common -ComputerName <dwservername>. You will see the BatchId and StartTime being updated after running the jobs. Use Get-SCDWJob -JobName Load.Common -ComputerName <dwservername> to get information about the jobs.
 
 

RSS 2.0