This action might not be possible to undo. Are you sure you want to continue?
Copying an SQL Server database
Version: 48 Validity:
Valid Since 15.08.2011
You want to copy an SQL Server database within a homogenous system copy. This procedure has been released for all SAP applications that are based on an SAP database (BW, CRM).
Homogenous system copy, BW, migration, sp_attach_db, sp_detach_db
Reason and Prerequisites
This note describes the system copy procedure using the SQL Server system stored procedures sp_detach_db and sp_attach_db or the command 'CREATE DATABASE FOR ATTACH'. Alternatively, you can restore the database.
The following example describes the system copy procedure of the productive PRD SAP system to the Quality assurance system (QAS).
For Java or ABAP + Java systems that are based on NetWeaver technology lower than Version 7.10, you must first export parts of the Java source system. For this, you must use the delivered SAP installation master DVD of your installed SAP release. The export of the Java part into a file is then created using the option 'system copy'. Establish whether you use a schema system or not. In the SAP system, choose the menu option "System" -> "Status" and check the value of the field "Owner". In a schema system (MCOD), the owner has the value <sid>, while the value is 'dbo' in a non-schema system. Install the SQL Server and the SAP system on the target system. For SQL Server 2000, you are required to take Note 600027 into account. Prepare the source database using the homogenous system copy guide. You will find the guide on SAP Service Marketplace at: http://service.sap.com/instguides. You can also use this procedure to perform an SQL Server upgrade by appending the database to an SQL Server that has a higher version. You can append an SQL Server 2000 database to an SQL Server Version 2000, 2005, and 2008. You can append an SQL Server 2005 database to SQL Server Versions 2005 and 2008; you can append an SQL Server 2008 database only to an SQL Server 2008. As part of the append process, the database is converted to the new version. Ensure that the log file(s) of the database can grow automatically and that sufficient disk space exists for a growing log file. Once the database has been converted, you cannot append it to the old SQL Server version again.
Page 1 of 9
ndf PRIMARY 1951744 KB PRDDATA3 4 d:\PRDDATA3\PRDDATA3. create the directory structure for the data and log 24.SAP Note 151603 - Copying an SQL Server database For this reason.------------------------------------------PRDDATA1 1 d:\PRDDATA1\PRDDATA1. you must ensure that all prerequisites (SQL Server collation. Step 2: Determine the file structure of the source database Determine the file structure of the source database using the Server Query Analyzer. 6.ldf NULL 287816 KB PRDDATA2 3 d:\PRDDATA2\PRDDATA2.-----. execute the following commands in the SAP database: Schema system: use <SAPSID> go setuser '<sid>' go exec sap_droproc Non-schema system: use <SAPSID> go exec sap_droproc These commands delete all temporary stored procedures in the database. SQL data types. Connect to the database to be copied and execute the command sp_helpfile.ndf PRIMARY 1953792 KB Step 3: Create the directory structure for the target database In the target system. Example: use PRD exec sp_helpfile Result: name fileid filename filegroup size -------.05. Using the SQL Server Query Analyzer or the SQL Server Management Studio. This command provides the physical name (file name) and the logical name (name) of all database files. SAP Basis Support Packages. If your system was configured for Performance Warehouse Monitoring by Solution Manager. Follow the instructions for database migration in your SAP release. 5.2012 Page 2 of 9 . They are created again automatically if necessary while the SAP system is operating. you must read Note 1388700. since important post-processing steps are required after the database copy. and so on) are fulfilled for the new database version BEFORE you append the database to the higher version. Delete the automatically generated stored procedures.mdf PRIMARY 11214912 KB PRDLOG1 2 e:\PRDLOG1\PRDLOG1.
The target database name can differ from the source database name. QASDATA2. o To recover the database. You may rename the files if required. The database can be reattached to the SQL Server later using sp_attach_db or 'CREATE DATABASE FOR ATTACH'.SAP Note 151603 - Copying an SQL Server database files of the SQL Server. On the target system. the server no longer recognizes the database <SID>.2012 Page 3 of 9 . this is described in Note 806925. QASDATA3. you must first detach it from the SQL Server using the stored procedure sp_detach-db or recover it successfully. Execute the following command in the Query Analyzer: use master exec sp_detach_db '<SID>'. you must create the directories QASDATA1. 24. and QASLOG1. The stored procedure sp_detach_db separates a database from the SQL Server. Note that detaching and attaching the database can cause problems. true o Step 5: Copying the data and log files Copy the data and log files into the relevant target directories of the target computer. This procedure is safer than the stored procedure 'sp_detach_db'. the data files are on drive g:. This corresponds to a deletion (Drop) of the database without eliminating the respective files. The target database can be located on the same server or on another machine. the log file is on drive h:). Directory and file names should correspond to the SAP naming conventions.05. Example: use master exec sp_detach_db 'PRD'. You should restart the SQL Server. true After you have done this. Sufficient place must be available on the target system for the data and log files. Example: You must copy the source database PRD to a target database QAS. you must simply start the SQL Server and stop it again. You must set all activities on the source database. You can then copy the database files at system level. Create the directories <target_SID>DATA and <target_SID>LOG. It must differ from the source database name in the case of the same SQL Server instance. since you do not have to detach the source database from the SQL Server. They can be distributed on different drives (in our example. Step 4: Detaching the source database To reattach a database successfully to an SQL Server.
mdf') FOR ATTACH.mdf) and all files whose physical location or name were changed. Therefore. for the source database.05. 'g:\QASDATA1\QASDATA1. Example: CREATE DATABASE PRD ON (FILENAME = 'd:\PRDDATA1\PRDDATA1.mdf'.mdf g:\QASDATA1\QASDATA1.SAP Note 151603 Example: Copying an SQL Server database copy d:\PRDDATA1\PRDDATA1. Therefore. you only need to call 'sp_attach_db' with the name of the initial database and the complete path names of the master data file since no files or names have changed in this database. 'd:\PRDDATA1\PRDDATA1. sp_attach_db requires the name of the database and a list of physical file names (complete path names) as a parameter.mdf Step 6: Reattaching the source database SQL Server 2000: You can make the source database available again using 'sp_attach_db'.mdf) and all files whose physical location or name were changed. you only need to specify the name of the initial database and the complete path names of the master data file because no files or names have changed in this database. Step 7: Attaching the target database SQL Server 2000: Execute the following command in the Query Analyzer in the target system: Example: use master exec sp_attach_db 'QAS'. The list must contain the master data file (*. 24. The list must contain the master data file (*.mdf' SQL Server 2005 and higher: You can make the source database available again using 'CREATE DATABASE FOR ATTACH'. 'g:\QASDATA2\QASDATA2.2012 Page 4 of 9 . Example: exec sp_attach_db 'PRD'. for the source database.ndf'. This command requires the name of the database and a list of physical file names (complete path names) as a parameter.
you have to specify all database files. SQL Server 2005 and higher: Execute the following command in the Query Analyzer in the target system: Example: use master CREATE DATABASE QAS ON (FILENAME='g:\QASDATA1\QASDATA1. !! 1. Changing the owner of all database objects Schema system: 24. this is described in Note 806925.0 SR3 Installations Master DVD for copying an SQL 2008 system.ndf').2012 Page 5 of 9 . You will find the exact syntax description of this command in the SQL Server Books Online. refer to Note 1152240. If the database contains more than 16 files. For a cluster installation.ldf') FOR ATTACH Since the location and the names of the files have changed. you can also perform the following steps manually. As an alternative to steps 4 to 7.ndf'). (FILENAME='g:\QASDATA2\QASDATA2. use the command 'CREATE DATABASE FOR ATTACH'. If you cannot use the SAP tools for the SQL Server for whatever reason.05. Step 8: Follow-up procedure The delivered SAP Installation Master DVD of the installed SAP release must be used for postprocessing for a Java or an ABAP+Java system in order to install the ABAP central instance. you can restore the database by restoring a database backup. you have to specify all database files: The command 'sp_attach_db' only supports up to 16 data or log files. If you use Netweaver 7.00.mdf'). follow the instructions from Note 683447 (SAP Tools for MS SQL Server). also see Note 910012.SAP Note 151603 - Copying an SQL Server database 'g:\QASDATA3\QASDATA3. 'h:\QASLOG1\QASLOG1. (FILENAME='g:\QASDATA3\QASDATA3. !! ATTENTION: You perform manual execution at your own risk. (FILENAME='h:\QASLOG1\QASLOG1. Note that detaching and attaching the database can cause problems.ldf' Since the location and the names of the files have changed.ndf'. For Java or ABAP+Java systems that are based on a NetWeaver technology lower than Release 7.
2012 Page 6 of 9 . proceed as described in Note 363018. use Note 551915 and the scripts that are attached to it if necessary. you must change the owner of all database objects. 4.05. Creating the DB13 jobs Delete all DB13 jobs in the database using the following script: Schema system: use <SAPSID> go setuser '<sid>' go truncate table truncate table SDBAP SDBAR Non-schema system: use <SAPSID> truncate table truncate table SDBAP SDBAR Then create the jobs using the DBA Planning Calendar in the Computing Center Management System (DB13). Non-schema system: You are not required to change the owner.0 for SQL Server 2000 and 9. If 24. To do this. Configuration of the SQL Server You must configure the SQL Server as described in Note 879941 (SQL Server 2005). Non-schema system: Proceed as described in Note 98678. 2. Increase the tempdb database to at least 300 MB. 5. Select your database version from the "Database Release" field. size = 50MB) If you need to move the tempdb database.0 for SQL Server 7. You can do this using the Enterprise Manager or the following SQL script: alter database tempdb modify file (name = tempdev. or Note 126808 (SQL Server 7). size = 250MB) alter database tempdb modify file (name = templog. Creating the permanent stored procedures Call transaction SE38 and execute report MSSPROCS. Creating the logins on the target system: Schema system: Proceed as described in Note 551915.SAP Note 151603 - Copying an SQL Server database If the <SID> is changed by the copy. Select 7. 8. Note 327494 (SQL Server 2000). 3.0 for SQL Server 2005.
Postprocessing using the homogenous system copy guide Since the SID and the host name of the SAP system (among other things) have changed due to the database copy.05. For Basis Release 620 and higher. Licensing the SAP system 24. You must always select 9. 8. 6. you have to initialize the tables sap_perfhist. which are required for the correct functioning of the SAP system.2012 Page 7 of 9 . The permanent stored procedures.0 for SQL Server 2005. you can also select 7. sap_perfsample and sap_perfinfo using the SQL command 'TRUNCATE TABLE'. and the SQL Server jobs for the CCMS Monitor are created in this way. Execute the following commands: Schema system: use <SAPSID> go setuser '<sid>' go TRUNCATE TABLE 700) TRUNCATE TABLE TRUNCATE TABLE TRUNCATE TABLE TRUNCATE TABLE TRUNCATE TABLE sap_perfhist sap_perfsample sap_perfinfo sap_perfvali MSSDWDLLS sap_mon_text (up to and including Basis Release (as of Basis Release 640) (as of Basis Release 620) (as of Basis Release 702 (SP7)) Non-schema system: use <SAPSID> TRUNCATE TABLE 700) TRUNCATE TABLE TRUNCATE TABLE TRUNCATE TABLE TRUNCATE TABLE TRUNCATE TABLE sap_perfhist sap_perfsample sap_perfinfo sap_perfvali MSSDWDLLS sap_mon_text (up to and including Basis Release (as of Basis Release 640) (as of Basis Release 620) (as of Basis Release 702 (SP7)) 9. see the guide for homogenous system copies. the SQL Server keeps logical file names that naturally contain the name of the source system.0 for SQL Server 2000. These names do not affect database operation. You can change the names in SQL Server 2000 using the 'ALTER DATABASE MODIFY FILE' command. some postprocessing is required in the new SAP system (such as setting up the transport system). Renaming the logical file names Within the database files. You will find the exact syntax description of this command in the SQL Server Books Online. Initializing the database collector For SAP Basis Release 610 and higher. Start creating the stored procedures using "Start all".SAP Note 151603 - Copying an SQL Server database 8. You cannot change these names in SQL Server 7. 7. For information about the required database work (from an SAP point of view).0 is not available. you must also initialize the table MSSDWDLLS.
the Java export created in the first step is imported into the target system.2012 Page 8 of 9 . check the environment of users <sid>adm and SAPService<SID> as well as the profiles of the SAP system as described in Note 98678. see the homogenous system copy guide.1 Database Warehouse for MSSQL SQL Server Remote Database Monitor in Solution Manager 400 Windows: Migration from 32-bit to 64-bit (x86_64) MS SQL Server: Migrating from 32-bit to 64-bit Installing the Corrected MS SQL Server Collation FAQ: Microsoft SQL Server R/3 won't start after database restore or database copy File management for SQL Server 24.sql'.SAP Note 151603 - Copying an SQL Server database For information about licensing the SAP system.08. Here.05. If the copied system fails to start or if no connection to the system can be established. Header Data Release Status: Released on: Master Language: Priority: Category: Primary Component: Released for Customer 15. Bear the following in mind: The script 'mss_varbin_conversion. is irrelevant for the procedure described here and must not be executed. the system copy is complete.2011 13:32:26 German Recommendations/additional info Installation information BC-DB-MSS Microsoft SQL Server The Note is release-independent Related Notes Number 1471910 1458291 1388700 960769 666805 600027 555223 551915 363018 Short Text SQL Server Partitioning in System Copies and DB Migrations Solution Manager 7. As a result. described in the notes for homogenous system copies. The delivered SAP Installation Master DVD of the installed SAP release must be used for postprocessing for a Java or an ABAP+Java system in order to install the Java Add-In.
0 24.05.SAP Note 151603 Number 339912 193816 172547 Copying an SQL Server database Short Text R3COPY on NT-MS SQL Server Restore with SQL Server Platform changes between Intel and Alpha with SQL Server 7.2012 Page 9 of 9 .
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.