ISSUEWhen running the DetachDatabase NWAdmin command, the operation lists out sites associated with the database, and then the following error occurs:
Command line execution error: Object reference not set to an instance of an object.
- Take backup of the Nintex content database being detached.
- Run the following query within SQL Management Studio against the Nintex content database being detached to find all SiteIds referenced in the database:
SELECT DISTINCT CAST(siteid as uniqueidentifier) as SiteID FROM dbo.workflowinstance
- Based the SiteIds returned, determine which ID the DetachDatabase command failed on (this will be the first site or SiteId *not* listed out by the DetachDatabase command)
- Once the orphaned SiteId is determined, expand open the Nintex content database > Programmability > Stored Procedures
- Right-click on the dbo.PurgeWorkflowData stored procedure and select 'Execute Stored Procedure...'
- Within the window that appears, check 'Pass Null Value' for all parameters *except* for @siteid
- Pass @siteid the GUID of the orphaned site found in step 3, and select OK.
- Re-run the DetachDatabase command.