To import the Modelstore in a temporary schema and at the end apply follow steps:
Steps:
1. Open SSMS (SQL Server Management Studio) (Press the Windows Key + R, Run will open Type SSMS and enter)
2. Connect to the SQL Server instance where AX database resides
3. Expand to Databases > MicrosoftDynamicsAX_model > Security > Schemas
4. Right click > New schema
5. Type in the temporary schema name (TempoSchema) and select the schema owner and click "OK"
6. Initialize the temporary schema
For Initialize the temporary schema Use the command below:
Initialize-AXModelStore -AOSAccount "Domain\AccountName" -SchemaName <TempoSchema> -Server <ServerName> -Database <DatabaseName>)
Import model store to temporary schema
Syntax: Import-AXModelStore -File <filename> -TempoSchema
Example:
Import-AXModelStore -File “C:\AX\AX_ModelStores\AXModelStore.axmodelstore” -SchemaName “TempoSchema” –IdConflict overwrite
//-Config MicrosoftDynamicsAX -Details (OPTIONAL FOR CONFIG)
//-Config MicrosoftDynamicsAX -Details (OPTIONAL FOR CONFIG)
Import-AXModelStore -Apply:TempoSchema -Config MicrosoftDynamicsAX -details
--
SQL Commands for Change tracking system:
TO check what tables in Change LOG:
SELECT s.name AS Schema_name, t.name AS Table_name FROM sys.change_tracking_tables ctt
JOIN sys.tables t
ON t.object_id = ctt.object_id
JOIN sys.schemas s
ON s.schema_id = t.schema_id
ORDER BY s.name, t.name
The following script can be used to enable/disable Change Tracking on a particular database.
1
2
3
4
5
6
7
8
| -- Enable ALTER DATABASE database_name SET CHANGE_TRACKING = ON (CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON ) -- Disable ALTER DATABASE database_name SET CHANGE_TRACKING = OFF |
To enable/disable change tracking on individual table(s)
1
2
3
4
5
6
7
| -- Enable ALTER TABLE table_name Enable Change_tracking; -- Disable ALTER TABLE table_name Disable Change_tracking; |
If you wish to enable change tracking on all tables within a database in one go, you can use the following dynamic query to generate “enable change tracking” script.
1
2
3
4
| Use database_name; go EXEC sp_MSforeachtable 'PRINT ' 'ALTER TABLE ? ENABLE Change_tracking;' '' ; |
To disable change tracking on tables within a database in one go, use the following query
1
2
3
4
5
6
7
8
9
10
11
| Use database ; GO DECLARE @SQL NVARCHAR( MAX ) = '' ; SELECT @SQL = @SQL + 'ALTER TABLE ' + s. name + '.' + t. name + ' Disable Change_tracking;' + CHAR (10) FROM sys.change_tracking_tables ct JOIN sys.tables t ON ct.object_id= t.object_id JOIN sys.schemas s ON t.schema_id= s.schema_id; PRINT @SQL; -- EXEC sp_executesql @SQL; |
No comments:
Post a Comment