Moving SQL user database with the GUI can be cumbersome and time consuming. Using this procedure you can reconfigure SQL quickly and easily. Modify for your needs.
These scripts assume the following:
- Lync Front Ends are Enterprise edition and are using an external SQL Server.
- The default Lync paths are being re-used.
- Monitoring/Archiving databases are not included. I will update the script later to include these databases.
For information on SQL Server Data and Log file placement for Lync click here…
To move a data or log file as part of a planned relocation, follow these steps:
Reference: http://msdn.microsoft.com/en-us/library/ms345483.aspx
- Stop all Lync services on the Front End servers.
- On a computer that is running Microsoft SQL Server, open SQL Server Management Studio and connect to the Default database instance.
- Click New Query.
- Run the following statement.
ALTER DATABASE xds SET OFFLINE; ALTER DATABASE lis SET OFFLINE; ALTER DATABASE rtc SET OFFLINE; ALTER DATABASE rtcdyn SET OFFLINE; ALTER DATABASE rtcab SET OFFLINE; ALTER DATABASE rtcab1 SET OFFLINE; ALTER DATABASE cpsdyn SET OFFLINE; ALTER DATABASE rgsconfig SET OFFLINE; ALTER DATABASE rgsdyn SET OFFLINE;
- Move the files to the new location.
- After the files are successfully moved, run the following statement. (Replace the path with the drive letter and directory of the new destination)
ALTER DATABASE rtc MODIFY FILE ( NAME = rtc_data, FILENAME = '?:\csdata\backendstore\(default)\dbpath\rtc.mdf' ); ALTER DATABASE rtc MODIFY FILE ( NAME = rtc_log, FILENAME = '?:\csdata\backendstore\(default)\logpath\rtc.ldf' ); ALTER DATABASE rtcdyn MODIFY FILE ( NAME = rtcdyn_data, FILENAME = '?:\csdata\backendstore\(default)\dyndbpath\rtcdyn.mdf' ); ALTER DATABASE rtcdyn MODIFY FILE ( NAME = rtcdyn_log, FILENAME = '?:\csdata\backendstore\(default)\dynlogpath\rtcdyn.ldf' ); ALTER DATABASE xds MODIFY FILE ( NAME = xds_data, FILENAME = '?:\csdata\centralmgmtstore\(default)\dbpath\xds.mdf' ); ALTER DATABASE xds MODIFY FILE ( NAME = xds_log, FILENAME = '?:\csdata\centralmgmtstore\(default)\logpath\xds.ldf' ); ALTER DATABASE lis MODIFY FILE ( NAME = lis_data, FILENAME = '?:\csdata\centralmgmtstore\(default)\dbpath\lis.mdf' ); ALTER DATABASE lis MODIFY FILE ( NAME = lis_log, FILENAME = '?:\csdata\centralmgmtstore\(default)\logpath\lis.ldf' ); ALTER DATABASE rtcab MODIFY FILE ( NAME = rtcab_data, FILENAME = '?:\csdata\absstore\(default)\dbpath\rtcab.mdf' ); ALTER DATABASE rtcab MODIFY FILE ( NAME = rtcab_log, FILENAME = '?:\csdata\absstore\(default)\logpath\rtcad.ldf' ); ALTER DATABASE rtcab1 MODIFY FILE ( NAME = rtcab1_data, FILENAME = '?:\csdata\absstore\(default)\dbpath\rtcab1.mdf' ); ALTER DATABASE rtcab1 MODIFY FILE ( NAME = rtcab1_log, FILENAME = '?:\csdata\absstore\(default)\logpath\rtcab1.ldf' ); ALTER DATABASE cpsdyn MODIFY FILE ( NAME = cpsdyn_data, FILENAME = '?:\csdata\applicationstore\(default)\dbpath\cpsdyn.mdf' ); ALTER DATABASE cpsdyn MODIFY FILE ( NAME = cpsdyn_log, FILENAME = '?:\csdata\applicationstore\(default)\logpath\cpsdyn.ldf' ); ALTER DATABASE rgsconfig MODIFY FILE ( NAME = rgsconfig_data, FILENAME = '?:\csdata\applicationstore\(default)\dbpath\rgsconfig.mdf' ); ALTER DATABASE rgsconfig MODIFY FILE ( NAME = rgsconfig_log, FILENAME = '?:\csdata\applicationstore\(default)\logpath\rgsconfig.ldf' ); ALTER DATABASE rgsdyn MODIFY FILE ( NAME = rgsdyn_data, FILENAME = '?:\csdata\applicationstore\(default)\dbpath\rgsdyn.mdf' ); ALTER DATABASE rgsdyn MODIFY FILE ( NAME = rgsdyn_log, FILENAME = '?:\csdata\applicationstore\(default)\logpath\rgsdyn.ldf' );
- Run the following statement.
ALTER DATABASE xds SET ONLINE; ALTER DATABASE lis SET ONLINE; ALTER DATABASE rtc SET ONLINE; ALTER DATABASE rtcdyn SET ONLINE; ALTER DATABASE rtcab SET ONLINE; ALTER DATABASE rtcab1 SET ONLINE; ALTER DATABASE cpsdyn SET ONLINE; ALTER DATABASE rgsconfig SET ONLINE; ALTER DATABASE rgsdyn SET ONLINE;
To enable chaining of the RTC and RTCdyn databases
Reference: http://support.microsoft.com/kb/968100
- On a computer that is running Microsoft SQL Server, connect to the RTC database, and then run the following SQL command from SQL Server Management Studio:
sp_dboption rtc, 'db chaining', TRUE
- Connect to the RTCdyn database, and then run the following SQL command from SQL Server Management Studio:
sp_dboption rtcdyn, 'db chaining', TRUE
- Start the Front End services.

{ 4 comments… read them below or add one }
In this process do we not need to move CMS to a different pool first?
No, this process is for moving the databases to different locations within the same SQL server. To move the CMS to a different pool altogether you’ll want to follow this process: http://technet.microsoft.com/en-us/library/gg195644.aspx.
Matt,
Thanks for this article. I think this is what I need to move the dbs from the C drive to the D drive on my SQL server.
My question is with the “chaining”. Is this something I must do, or is this optional to do a move? I am not changing SQL servers or instances, just moving the location from the system drive to the Data drive.
Thanks,
Josh
Yes, whenever you move the databases either locally or between SQL servers you will need to re-enable cross-databse chaining..