Tuesday 6 December 2011

Re-import CRM org in to new server

I have got two servers, CRM-Dev and CRM-Staging,
CRM-Dev contains the latest changes and we want to deploy it to CRM-Staging

Open SQL-Managment Studio and take the backup of CRM-Dev_MSCRM instance and restore it on CRM-Staging machine with a same or different database name e.ge CRM-Stag_MSCRM.

On the restored database execute following sql script, and then copy each reult view and execute the script again. This will ensure that all org id is unique.


SELECT 'ALTER TABLE '+QUOTENAME(name)+' NOCHECK CONSTRAINT ALL'
FROM sysobjects WHERE xtype='U' and uid=1

declare @newid uniqueidentifier

select @newid = newid()

 SELECT 
        'Update ' + c.TABLE_SCHEMA + '.' + c.TABLE_NAME + ' set ' + c.COLUMN_NAME +' =''' + +cast(@newid as varchar(40))+''''
     FROM INFORMATION_SCHEMA.Columns c
        INNER JOIN INFORMATION_SCHEMA.Tables t
        ON c.TABLE_NAME = t.TABLE_NAME
        AND t.TABLE_TYPE = 'BASE TABLE'
    WHERE DATA_TYPE = 'uniqueidentifier'  and column_name='organizationid'
    
SELECT 'ALTER TABLE '+QUOTENAME(name)+' CHECK CONSTRAINT ALL'
FROM sysobjects WHERE xtype='U' and uid=1

Open the deployment Manager and select import option, and select the recently restored database, and select defaults.

Organisation is successfully imported.


1 comment:

  1. i am a successful business owner and father. I got one of these already programmed blank ATM cards that allows me withdraw a maximum of $5,000 daily for 30 days. I am so happy about these cards because I received mine last week and have already used it to get $20,000. Skylink technology is giving out these cards to support people in any kind of financial problem. I must be sincere to you, when i first saw the advert, I believed it to be illegal and a hoax but when I contacted this team, they confirmed to me that although it is illegal, nobody gets caught while using these cards because they have been programmed to disable every communication once inserted into any Automated Teller Machine(ATM). If interested get through to them on mail: skylinktechnes@yahoo.com  or  whatsapp/telegram: +1(213)785-1553  

    ReplyDelete