Ha Son, can you email me so i can send you the fixed SQL? I couldn't find my original so i just re-created it, basically it just adds 3 new delete statements to remove the children of the errored out resources. Kentico 8 had children, but Kentico 9 didn't, so when you go from 8 to 9, those children remain and the 9 to 10 sql doesn't account for them.
email me at tfayas@hbs.net
Or just run these lines on your database before upgrading:
-- Custom, remove settings Keys and Categories first before removing that module
Delete from [CMS_SettingsKey] where [KeyCategoryID] in (Select CategoryID from [CMS_SettingsCategory] where CategoryResourceID = (Select ResourceID from [CMS_Resource] WHERE [ResourceGUID] = 'f3233ad0-50ee-45e3-b50f-6c1d8e90dbb0'))
Delete FROM [CMS_SettingsCategory] where CategoryResourceID = (Select ResourceID from [CMS_Resource] WHERE [ResourceGUID] = 'f3233ad0-50ee-45e3-b50f-6c1d8e90dbb0')
-- Custom Remove any children and grandchildren reports first
DELETE FROM [Reporting_ReportCategory] where CategoryParentID in (
select CategoryID FROM [Reporting_ReportCategory] where CategoryParentID = (
Select CategoryID FROM [Reporting_ReportCategory] WHERE [CategoryGUID] = '8d008d2b-daef-4d44-aff7-4a3b39d8c33b'
)
)
DELETE FROM [Reporting_ReportCategory] where CategoryParentID = (
Select CategoryID FROM [Reporting_ReportCategory] WHERE [CategoryGUID] = '8d008d2b-daef-4d44-aff7-4a3b39d8c33b'
)