Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics SL forum
Suggested answer

Refreshing Test Database

Posted on by Microsoft Employee

I need to refresh  Microsoft dynamics Test Database from Live.

We have dynamics SL 2015 CU1

I see that there are two databases Finance and FinanaceSys, I can restore databases in Test Environment from backups that is fine,

but I need to know,  do we need to change any records so databases can work in Test environment.

This is my first time refreshing Dynamics database in Test any help will be greatly appreciated.

  • Suggested answer
    Butch Adams Profile Picture
    Butch Adams 4,757 on at
    RE: Refreshing Test Database

    Here's a basic script I use to sort of automate it. Adjust DB and filenames to meet your needs.

    Use master
    PRINT GETDATE()
    ALTER DATABASE SLTestApp
    SET SINGLE_USER WITH
    ROLLBACK IMMEDIATE
    ALTER DATABASE SLTestSys
    SET SINGLE_USER WITH
    ROLLBACK IMMEDIATE

    RESTORE DATABASE SLTestApp
    FROM DISK = 'D:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup\SLApplication.bak'
    WITH REPLACE,
    MOVE 'SLApplication_Data' TO 'D:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\SLTestApp.mdf',
    MOVE 'SLApplication_Log' TO 'D:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\SLTestApp_1.ldf'

    GO

    RESTORE DATABASE SLTestSys
    FROM DISK = 'D:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup\restore\SLSystem.bak'
    WITH REPLACE,
    MOVE 'SLSystem_Data' TO 'D:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\SLTestSys.mdf',
    MOVE 'SLSystem_Log' TO 'D:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\SLTestSys_1.ldf'

    ALTER DATABASE SLTestApp SET MULTI_USER
    ALTER DATABASE SLTestSys SET MULTI_USER

    USE SLTestSys
    --Update Server and Database names in system db tables
    update Domain set DatabaseName = 'SLTestApp' where DatabaseName = 'SLApplication'
    update Domain set DatabaseName = 'SLTestSys' where DatabaseName = 'SLSystem'
    update Domain set ServerName = 'TESTSERVER'

    update Company set DatabaseName = 'SLTestApp' where DatabaseName = 'SLApplication'

    --Change colors to RED
    update Company set CpnyColor = 255

    --Rename Companies
    update Company set CpnyName = '-- TEST -- ' + LEFT(CpnyName,19)


    go
    PRINT GETDATE()

    --Now run SL Database Maint and
    --Syncronize all Database Ownership and Security
    --Update Views

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Refreshing Test Database

    system.domain and\or system.company

    you will find the database server name and database names in there.

    then of course run db maintenance - update views and security

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans