Skip to main content

How to Copy the Design of Portal via SQL Query

Overview

This article provides step-by-step instructions for copying a portal design between environments using SQL queries. The process covers scenarios for the same SQL server and database, different databases on the same server, and different SQL servers.

Instructions

Copy the Design Within the Same SQL Server and Database

  1. Go to the database used with the test server.
  2. Select the database and create a new query.
    SQL Server Management Studio new query window with database selected
  3. Enter the following query:
DECLARE @fromClient AS int = n
DECLARE @fromStore AS int = n
DECLARE @toClient AS int = n
DECLARE @tostore AS int = n

UPDATE [SSPR].[PortalDesigns]
SET Design = (SELECT Design FROM [SSPR].[PortalDesigns] WHERE ClientId = @fromClient AND IdentityStoreId = @fromStore)
WHERE ClientId = @toClient AND IdentityStoreId = @tostore
  1. In @fromClient, enter the Client ID of the portal you want to copy. For example, to copy the design of Portal 1, use Client ID 11.
    PortalDesigns table showing Client ID and Identity Store ID values
  2. In @fromStore, enter the Identity Store ID. For example, use 2.
    Identity Store ID value in PortalDesigns table
  3. In @toClient and @toStore, enter the Client ID and Identity Store ID for the target portal. For example, Client ID 13 and Store ID 2.
  4. Run the query.
  5. The following screenshot shows the executed query:
    Screenshot of executed SQL query

Copy the Design with the Same SQL Server and Different Databases

Environment: Test instance configured with SQLTestServer-DB1, production instance configured with SQLTestServer-DB2.

  1. Go to SQL Server and create a new query.
  2. Enter the following query:
DECLARE @fromClient AS int = n
DECLARE @fromStore AS int = n
DECLARE @toClient AS int = n
DECLARE @tostore AS int = n

UPDATE [toDB].[SSPR].[PortalDesigns]
SET Design = (SELECT Design FROM [fromDB].[SSPR].[PortalDesigns] WHERE ClientId = @fromClient AND IdentityStoreId = @fromStore)
WHERE ClientId = @toClient AND IdentityStoreId = @tostore
  1. In @fromClient, @fromStore, @toClient, and @toStore, enter the appropriate Client ID and Store ID values as described above.
  2. In [toDB], enter the database name of the production portal.
    Screenshot of SQL query for copying design between databases
  3. In [fromDB], enter the database name of the test portal.
  4. Run the query.
  5. The following screenshot shows the executed query:
    Screenshot of executed SQL query for different databases

Copy the Design with Different SQL Servers and Databases

Environment: Test server configured with DB1, production server configured with DB2.

  1. On the test server, connect to the SQL Server instance where you want to create the linked server.
  2. In Object Explorer, go to Server Objects and click Linked Servers.
  3. Create a new linked server.
  4. In the New Linked Server window, enter the name of the server you want to link.
  5. Select Server type as SQL Server.
    Linked server properties window
  6. Select Security from the left pane, choose the appropriate login option, and enter the server credentials.
  7. Click OK. The linked server will appear in the list.
    Linked server security settings

Linked server shown in SQL Server Management Studio

  1. Go to the Netwrix Directory Manager portal of the test server and make the required changes to the portal design.
  2. Return to SQL Server.
  3. Right-click the server and select New Query.
    SQL Server Management Studio new query window for linked server
  4. Enter the following query:
DECLARE @fromClient AS int = n
DECLARE @fromStore AS int = n
DECLARE @toClient AS int = n
DECLARE @tostore AS int = n

UPDATE [toSourceServer].[toDB].[SSPR].[PortalDesigns]
SET Design = (
SELECT Design FROM [fromSourceServer].[fromDB].[SSPR].[PortalDesigns]
WHERE ClientId = @fromClient AND IdentityStoreId = @fromStore
)
WHERE ClientId = @toClient AND IdentityStoreId = @tostore
  1. In @fromClient, @fromStore, @toClient, and @toStore, enter the appropriate Client ID and Store ID values as described above.
  2. In [toSourceServer], enter the server name of the production server.
    Linked server name entry in SQL query
  3. In [fromSourceServer], enter the server name of the test server.
  4. In [fromDB] and [toDB], enter the database names as described above.
  5. Execute the query.

Screenshot of executed SQL query for linked server