How to identify a crm organisation database RRS feed

  • Question

  • Hi guyz, 

    im trying to import organisations and im doing it perfectly.

    Before importing, im doing the following steps:

                       -> Take SQLServer Database backup of CRM Organisation

                       -> Restore the backupfile into my CRM Server Machine

                       -> hardcoding the restored database name and then importing the organisation by giving the restored database name

    now i want to automate the process of restoring the database and which im able to do, but i just want to restore and import the database which is a CRM Organisation, can any on  tell me how do i do it, how do i identify the CRM Organisation database programamtically??

    please help me guyz,

    im able to find one solution where i can get the source name from where the database backup has been done and in general  A CRM organisation has _MSCRM Suffix, so as of now im using the below query to do that, but that is not the correct thing to do it.

    "SELECT rs.[destination_database_name], rs.[restore_date], bs.[backup_start_date], bs.[backup_finish_date], bs.[database_name] AS [source_database_name], bmf.[physical_device_name] AS [backup_file_used_for_restore] FROM [dbo].[restorehistory] rs JOIN [dbo].[backupset] bs ON rs.[backup_set_id] = bs.[backup_set_id] JOIN [dbo].[backupmediafamily] bmf ON bs.[media_set_id] = bmf.[media_set_id] ORDER BY rs.[restore_date] "

    please help me guyz, 

    Tuesday, September 11, 2012 6:41 AM