Here are the scripts I used for the different demos during the TechNet Event.  This post is a VERY, VERY long post as I copied over all the scripts from the Pessimistic vs. Optimistic demo, Peer to Peer Replication Demo and Mirroring Demo.  Let me know if you have any questions.

Pessimistic vs. Optimistic

Pessimistic

Connection A
   /* Step 1  -  Begins the transaction to update rows in the Product table. */
   USE AdventureWorks_Demo4
   GO
   BEGIN TRANSACTION
      UPDATE Production.Product
         SET StandardCost = 5.0,
                 ListPrice = 11.50
         WHERE Name LIKE '%sock%'

   /* Step 3  -  This will rollback the transaction and allow the other processes query to complete by releasing the Exclusive locks. */
   ROLLBACK TRAN

Connection B
   /* Step 2  -  Select statement to run to request shared locks. */
   USE AdventureWorks_Demo4
   GO
   SELECT  Name,
      StandardCost,
      ListPrice
   FROM Production.Product
   WHERE Name LIKE '%Sock%'

Enable Row Versioning

   /* Step 1  -  Enables the database for snapshot isolation transactions to occur. */
   ALTER DATABASE AdventureWorks_Demo4
      SET ALLOW_SNAPSHOT_ISOLATION ON
   GO

   /* Step 2  -  Enables Read Committed snapshot on the database  */
   ALTER DATABASE AdventureWorks_Demo4
      SET READ_COMMITTED_SNAPSHOT ON
   GO

Snapshot Isolation

Connection A

   /* Step 1  -  Begins the transaction to update rows in the Product table. */
   USE AdventureWorks_Demo4
   GO
   BEGIN TRANSACTION
      UPDATE Production.Product
      SET StandardCost = 5.0,
              ListPrice = 11.50
      WHERE Name LIKE '%sock%'

   /* Step 4  -  This will commit the transaction and release the Exclustive locks on rows of the Product table.  */
   COMMIT TRANSACTION

   /* Step 5  -  Query that verifies the data modification by the preceding transaction.*/
   SELECT  Name,
      StandardCost,
      ListPrice
      FROM Production.Product
      WHERE Name LIKE '%Sock%'

Connection B

   /* Step 2  -  Enables Transaction Isolation Level Snapshot for this session.  */
   SET TRANSACTION ISOLATION LEVEL SNAPSHOT
   GO

   /* Step 3  -  Begins a snapshot isolation transaction.     */
   USE AdventureWorks_Demo4
   GO
   BEGIN TRANSACTION
      SELECT  Name,
         StandardCost,
         ListPrice
      FROM Production.Product
      WHERE Name LIKE '%Sock%'

   /* Step 6  -  Continues the transaction to demonstrate that the pre-committed data is accessed.   */
   SELECT  Name,
      StandardCost,
      ListPrice
   FROM Production.Product
   WHERE Name LIKE '%Sock%'

   /* Step 7  -  Attempts and update in this transaction on data that has been changed after this transaction was started */
   UPDATE Production.Product
      SET StandardCost = 7.00,
         ListPrice = 15.00
      WHERE Name LIKE '%sock%'

Read Committed

Connection A

   /* Step 1  -  Query. */
   USE AdventureWorks_Demo4
   GO
   BEGIN TRANSACTION
      UPDATE Production.Product
      SET StandardCost = 50.00,
         ListPrice = 64.99
      WHERE Name LIKE '%jersey%'

   /* Step 4  -  This will commit the transaction and release the Exclustive locks on rows of the Product table.  */
   COMMIT TRANSACTION

   /* Step 5  -  Query that verifies the data modification by the preceding transaction.*/
   SELECT  Name,
      StandardCost,
      ListPrice
   FROM Production.Product
   WHERE Name LIKE '%jersey%'

Connection B

   /* Step 2  -  Enables Transaction Isolation Level Snapshot for this session.   */
   SET TRANSACTION ISOLATION LEVEL READ COMMITTED
   GO

   /* Step 3  -  Begins a snapshot isolation transaction. */
   USE AdventureWorks_Demo4
   GO
   BEGIN TRANSACTION
      SELECT  Name,
         StandardCost,
         ListPrice
      FROM Production.Product
      WHERE Name LIKE '%jersey%'

   /* Step 6  -  Continues the transaction to demonstrate that the committed data is accessed.  */
   SELECT  Name,
      StandardCost,
      ListPrice
   FROM Production.Product
   WHERE Name LIKE '%jersey%'

   /* Step 7  -  Attempts and update in this transaction on data that has been changed after this transaction was started. */
   UPDATE Production.Product
      SET StandardCost = 75.00,
         ListPrice = 99.99
      WHERE Name LIKE '%jersey%'

   /* Step 8  -  Commits the transaction and releases exclusive locks */
   COMMIT TRANSACTION

   /* Step 9  -  Query to verify transaction was committed.   */
   SELECT  Name,
      StandardCost,
      ListPrice
   FROM Production.Product
   WHERE Name LIKE '%jersey%'

Peer to Peer Replication

Connection to SYD-SQL-01

   /* Step 1  -  Creates backup of demo database.  */
   BACKUP DATABASE AdventureWorks_Demo2 
      TO DISK = '\\LON-DCSQL-01\Backups\Advworks.bak'
      WITH INIT
   GO

Connection to LON-DCSQL-01

   /* Step 2  -  The second step to setting up a peer-to-peer replication is the restore of a full DB backup onto the replication partner. */
   RESTORE DATABASE AdventureWorks_Demo2 
      FROM DISK = '\\LON-DCSQL-01\Backups\Advworks.bak'
      WITH RECOVERY,
      REPLACE
   GO

Connection to LON-DCSQL-01 (New Connection to configure Peer to Peer Publications and Subscriptions)

   /* Step 1  -  Enables AdventureWorks_Demo2 for Replication. */
   EXEC sp_replicationdboption
      @dbname = 'AdventureWorks_Demo2',
      @optname = 'publish',
      @value = 'true'

   /* Step 2  -  Creates a Log Reader Agent and a job to control it's execution.  */
   USE AdventureWorks_Demo2
   GO
   EXEC sp_addlogreader_agent
      @job_login = 'CONTOSO\SQLServer',
      @job_password = 'P@ssw0rd',
      @publisher_security_mode = 1
   GO

   /* Step 3  -  Creates the publication 'Peer2Peer'.  */
   EXEC sp_addpublication
      @publication = 'Peer2Peer',
      @status = 'active',
      @independent_agent = 'true',
      @enabled_for_p2p = 'true'
   GO

   /* Step 4  -  Creates several articles in the 'Peer2Peer' publication containing the tables updatd by the stored procedure.  */
   EXEC sp_addarticle
      @publication = 'Peer2Peer',
      @article = 'Customers',
      @source_owner = 'Sales',
      @source_object = 'Customer',
      @status = 16
   GO 
   EXEC sp_addarticle
      @publication = 'Peer2Peer',
      @article = 'Contacts',
      @source_owner = 'Person',
      @source_object = 'Contact',
      @status = 16
   GO 
   EXEC sp_addarticle
      @publication = 'Peer2Peer',
      @article = 'Addresses',
      @source_owner = 'Person',
      @source_object = 'Address',
      @status = 16
   GO 
   EXEC sp_addarticle
      @publication = 'Peer2Peer',
      @article = 'SalesOrderHeaders',
      @source_owner = 'Sales',
      @source_object = 'SalesOrderHeader',
      @status = 16
   GO 
   EXEC sp_addarticle
      @publication = 'Peer2Peer',
      @article = 'SalesOrderDetails',
      @source_owner = 'Sales',
      @source_object = 'SalesOrderDetail',
      @status = 16
   GO 

   /* Step 5  -  Creates the push subscription to SYD-SQL-01.  */
   EXEC sp_addsubscription
      @publication = 'Peer2Peer',
      @subscriber = 'SYD-SQL-01',
      @destination_db = 'AdventureWorks_Demo2',
      @sync_type = 'replication support only'   
   GO

   /* Step 6  -  Creates the Push Subscription Agent and a job to control it's execution.  */
   EXEC sp_addpushsubscription_agent
      @publication = 'Peer2Peer',
      @subscriber = 'SYD-SQL-01',
      @subscriber_db = 'AdventureWorks_Demo2',
      @subscriber_login = 'CONTOSO\SQLServer',
      @job_login = 'CONTOSO\SQLServer',
      @job_password = 'P@ssw0rd'
   GO

Connection to SYD-SQL-01 (New Connection to configure Peer to Peer Publications and Subscriptions)

   /* Step 7  -  Reseeds the IDENTITY value columns on the Sydney server to avoid primary key violations when the values are replicated.  For each identity column *
   * in replicated tables and for each replication partner, a different IDENTITY value range needs to be maintained.  Make sure the NOT FOR REPLICATION option * 
   * is specified on the IDENTITY PRIMARY KEY constraint.  A CHECK constraint with the NOT FOR REPLICATION option is also advised. Each replication partner  * 
   * would have a different CHECK constraint with values pertaining to their respective ranges.  It lastly enables AdventureWorks_Demo2 for repl. */
   USE AdventureWorks_Demo2
   GO
   DBCC CHECKIDENT ('Sales.Customer',RESEED, 2000000)
   DBCC CHECKIDENT ('Person.Contact',RESEED, 2000000)
   DBCC CHECKIDENT ('Person.Address',RESEED, 2000000)
   DBCC CHECKIDENT ('Sales.SalesOrderHeader',RESEED, 2000000)
   GO

   EXEC sp_replicationdboption
      @dbname = 'AdventureWorks_Demo2',
      @optname = 'publish',
      @value = 'true'
   GO

   /* Step 8  -  Creates a Log Reader Agent and a job to control it's execution.  */
   USE AdventureWorks_Demo2
   GO
   EXEC sp_addlogreader_agent
      @job_login = 'CONTOSO\SQLServer',
      @job_password = 'P@ssw0rd',
      @publisher_security_mode = 1
   GO

   /* Step 9  -  Creates the publication 'Peer2Peer'.  */
   EXEC sp_addpublication
      @publication = 'Peer2Peer',
      @status = 'active',
      @independent_agent = 'true',
      @enabled_for_p2p = 'true'
   GO

   /* Step 10  -  Creates several articles in the 'Peer2Peer' publication containing the tables updatd by the stored procedure.  */
   EXEC sp_addarticle
      @publication = 'Peer2Peer',
      @article = 'Customers',
      @source_owner = 'Sales',
      @source_object = 'Customer',
      @status = 16
   GO 
   EXEC sp_addarticle
      @publication = 'Peer2Peer',
      @article = 'Contacts',
      @source_owner = 'Person',
      @source_object = 'Contact',
      @status = 16
   GO 
   EXEC sp_addarticle
      @publication = 'Peer2Peer',
      @article = 'Addresses',
      @source_owner = 'Person',
      @source_object = 'Address',
      @status = 16
   GO 
   EXEC sp_addarticle
      @publication = 'Peer2Peer',
      @article = 'SalesOrderHeaders',
      @source_owner = 'Sales',
      @source_object = 'SalesOrderHeader',
      @status = 16
   GO 
   EXEC sp_addarticle
      @publication = 'Peer2Peer',
      @article = 'SalesOrderDetails',
      @source_owner = 'Sales',
      @source_object = 'SalesOrderDetail',
      @status = 16
   GO 

   /* Step 11  -  Creates the push subscription to LON-DCSQL-01.  */
   EXEC sp_addsubscription
      @publication = 'Peer2Peer',
      @subscriber = 'LON-DCSQL-01',
      @destination_db = 'AdventureWorks_Demo2',
      @sync_type = 'replication support only'
   GO

   /* Step 12  -  Creates the Push Subscription Agent and a job to control it's execution.  */
   EXEC sp_addpushsubscription_agent
      @publication = 'Peer2Peer',
      @subscriber = 'LON-DCSQl-01',
      @subscriber_db = 'AdventureWorks_Demo2',
      @subscriber_login = 'CONTOSO\SQLServer',
      @job_login = 'CONTOSO\SQLServer',
      @job_password = 'P@ssw0rd'
   GO

Connection to LON-DCSQL-01 (Create Stored Procedure for New Order Processing)

   USE AdventureWorks_Demo2
   GO

   CREATE PROCEDURE up_NewCust_NewOrder_London 
      @SalesPersonID int = 280,
      @TerritoryID int = 1,
      @custType  nchar(1) = 'I',
      @fname   dbo.Name,
      @lname   dbo.Name,
      @PasswordHash varchar(40) ='F295DC2A87C7FD93151A2BC232BEAFF1133F95A2',
      @PasswordSalt varchar(20) ='TVGHbhY=',
      @Address  nvarchar(60) = NULL,
      @City   nvarchar(30) = NULL,
      @StateProvinceID int = NULL,
      @PostalCode  nvarchar (15) = NULL,
      @ShipMethodID int = 2,
      @ProdID1  int = NULL,
      @ProdID2  int = NULL,
      @ProdID3  int = NULL,
      @Qty1   int = NULL,
      @Qty2   int = NULL,
      @Qty3   int = NULL,
      @Price1   money = NULL,
      @Price2   money = NULL,
      @Price3   money = NULL
   AS
   BEGIN TRANSACTION

   DECLARE @SalesOrderID int,
      @CustomerID  int,
      @ContactID  int,
      @AddressID  int,
      @StateRandom int

   SET @StateRandom = CAST(FLOOR(RAND()*10) AS int)

   IF @StateRandom = 0
      BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 2
      SET @City = 'Anchorage'
      SET @PostalCode = '99501'
   END
   IF @StateRandom = 1 
      BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 21
      SET @City = 'Hilo'
      SET @PostalCode = '96720'
   END
   IF @StateRandom = 2 
      BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 23
      SET @City = 'Pocatello'
      SET @PostalCode = '83204'
   END
   IF @StateRandom = 3 
      BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 40
      SET @City = 'Kalispell'
      SET @PostalCode = '59911'
   END
   IF @StateRandom = 4 
      BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 52
      SET @City = 'Las Vegas'
      SET @PostalCode = '89109'
   END
   IF @StateRandom = 5
      BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 58
      SET @City = 'Ashland'
      SET @PostalCode = '97520'
   END
   IF @StateRandom = 6 
      BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 74
      SET @City = 'Moab'
      SET @PostalCode = '84532'
   END
   IF @StateRandom = 7
      BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 82
      SET @City = 'Cody'
      SET @PostalCode = '82414l'
   END
   IF @StateRandom = 8 
      BEGIN
      SET @Address = CAST(FLOOR(RAND()*10000) AS varchar(5)) + 
         ' ' + 
         CAST(FLOOR(RAND()*100) AS varchar(5)) + 
         ' St. NW'
      SET @StateProvinceID = 79
      SET @City = 'Seattle'
      SET @PostalCode = '98104'
   END
   IF @StateRandom = 9
      BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 79
      SET @City = 'Bellevue'
      SET @PostalCode = '98004'
   END
   IF @ProdID1 IS NULL
      SET @ProdID1 = CAST(FLOOR(RAND()*200) AS int)+799
   IF @ProdID2 IS NULL
      SET @ProdID2 = CAST(FLOOR(RAND()*200) AS int)+799
   IF @ProdID3 IS NULL
      SET @ProdID3 = CAST(FLOOR(RAND()*200) AS int)+799
   IF @Qty1 IS NULL
      SET @Qty1 = CAST(FLOOR(RAND()*15) AS int)
   IF @Qty2 IS NULL
      SET @Qty2 = CAST(FLOOR(RAND()*20) AS int)
   IF @Qty3 IS NULL
      SET @Qty3 = CAST(FLOOR(RAND()*10) AS int)
   IF @Price1 IS NULL
      SELECT @Price1 = ListPrice
      FROM Production.Product
      WHERE ProductID = @ProdID1
   IF @Price2 IS NULL
      SELECT @Price2 = ListPrice
      FROM Production.Product
      WHERE ProductID = @ProdID2
   IF @Price3 IS NULL
      SELECT @Price3 = ListPrice
      FROM Production.Product
      WHERE ProductID = @ProdID3

   INSERT INTO Sales.Customer 
      (SalesPersonID, 
       TerritoryID, 
       CustomerType)
      VALUES (@SalesPersonID, 
         @TerritoryID, 
         @custType)
   IF @@error <> 0
      ROLLBACK

   SELECT @CustomerID = ident_current('Sales.Customer')

   INSERT INTO Person.Contact 
      (FirstName, 
      LastName, 
      EmailAddress, 
      PasswordHash, 
      PasswordSalt)
      VALUES (@fname,
         @lname,
         @fname + '.' + @lname + '@contoso.com',
         @PasswordHash,
         @PasswordSalt)
   IF @@error <> 0
   ROLLBACK

   SELECT @ContactID = ident_current('Person.Contact')

   INSERT INTO Person.Address 
      (AddressLine1, 
      City, 
      StateProvinceID, 
      PostalCode)
      VALUES (@Address, 
         @City, 
         @StateProvinceID, 
         @PostalCode)
   IF @@error <> 0
   ROLLBACK

   SELECT @AddressID = ident_current('Person.Address')

   INSERT INTO Sales.SalesOrderHeader
      (DueDate,
      CustomerID,
      ContactID,
      SalesPersonID,
      TerritoryID,
      BilltoAddressID,
      ShiptoAddressID,
      ShipMethodID)
      VALUES (DATEADD(day,14,GetDate()),
         @CustomerID,
         @ContactID,
         @SalesPersonID,
         @TerritoryID,
         @AddressID,
         @AddressID,
         @ShipMethodID)
   IF @@error <> 0
   ROLLBACK

   SELECT @SalesOrderID = ident_current('Sales.SalesOrderHeader')

   INSERT INTO Sales.SalesOrderDetail
      (SalesOrderID,
      LineNumber,
      OrderQty,
      ProductID,
      SpecialOfferID,
      UnitPrice)
      VALUES (@SalesOrderID,
         1,
         @Qty1,
         @ProdID1,
         1,
         @Price1)
   IF @@error <> 0
   ROLLBACK

   INSERT INTO Sales.SalesOrderDetail
      (SalesOrderID,
      LineNumber,
      OrderQty,
      ProductID,
      SpecialOfferID,
      UnitPrice)
      VALUES (@SalesOrderID,
         2,
         @Qty2,
         @ProdID2,
         1,
         @Price2)
   IF @@error <> 0
   ROLLBACK

   INSERT INTO Sales.SalesOrderDetail
      (SalesOrderID,
      LineNumber,
      OrderQty,
      ProductID,
      SpecialOfferID,
      UnitPrice)
      VALUES (@SalesOrderID,
         3,
         @Qty3,
         @ProdID3,
         1,
         @Price3)
   IF @@error <> 0
   ROLLBACK

   COMMIT TRANSACTION
   GO

Connection to SYD-SQL-01 (Create Stored Procedure for New Order Processing)

   USE AdventureWorks_Demo2
   GO

   CREATE PROCEDURE up_NewCust_NewOrder_Sydney
      @SalesPersonID int = 284,
      @TerritoryID int = 1,
      @custType  nchar(1) = 'I',
      @fname   dbo.Name,
      @lname   dbo.Name,
      @PasswordHash varchar(40) ='F295DC2A87C7FD93151A2BC232BEAFF1133F95A2',
      @PasswordSalt varchar(20) ='TVGHbhY=',
      @Address  nvarchar(60) = NULL,
      @City   nvarchar(30) = NULL,
      @StateProvinceID int = NULL,
      @PostalCode  nvarchar (15) = NULL,
      @ShipMethodID int = 2,
      @ProdID1  int = NULL,
      @ProdID2  int = NULL,
      @ProdID3  int = NULL,
      @Qty1   int = NULL,
      @Qty2   int = NULL,
      @Qty3   int = NULL,
      @Price1   money = NULL,
      @Price2   money = NULL,
      @Price3   money = NULL
   AS
   BEGIN TRANSACTION

   DECLARE @SalesOrderID int,
      @CustomerID  int,
      @ContactID  int,
      @AddressID  int,
      @StateRandom int

   SET @StateRandom = CAST(FLOOR(RAND()*10) AS int)

   IF @StateRandom = 0
   BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 2
      SET @City = 'Anchorage'
      SET @PostalCode = '99501'
   END
   IF @StateRandom = 1 
   BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 21
      SET @City = 'Hilo'
      SET @PostalCode = '96720'
   END
   IF @StateRandom = 2 
   BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 23
      SET @City = 'Pocatello'
      SET @PostalCode = '83204'
   END
   IF @StateRandom = 3 
      BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 40
      SET @City = 'Kalispell'
      SET @PostalCode = '59911'
   END
   IF @StateRandom = 4 
   BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 52
      SET @City = 'Las Vegas'
      SET @PostalCode = '89109'
   END
   IF @StateRandom = 5
   BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 58
      SET @City = 'Ashland'
      SET @PostalCode = '97520'
   END
   IF @StateRandom = 6 
   BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 74
      SET @City = 'Moab'
      SET @PostalCode = '84532'
   END
   IF @StateRandom = 7
   BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 82
      SET @City = 'Cody'
      SET @PostalCode = '82414l'
   END
   IF @StateRandom = 8 
   BEGIN
      SET @Address = CAST(FLOOR(RAND()*10000) AS varchar(5)) + 
         ' ' + 
         CAST(FLOOR(RAND()*100) AS varchar(5)) + 
         ' St. NW'
      SET @StateProvinceID = 79
      SET @City = 'Seattle'
      SET @PostalCode = '98104'
   END
   IF @StateRandom = 9
   BEGIN
      SET @Address = 
         CAST(FLOOR(RAND()*10000) AS varchar(5)) +
         ' ' +
         CAST(FLOOR(RAND()*100) AS varchar(5)) +
         ' St. NW'
      SET @StateProvinceID = 79
      SET @City = 'Bellevue'
      SET @PostalCode = '98004'
   END

   IF @ProdID1 IS NULL
      SET @ProdID1 = CAST(FLOOR(RAND()*200) AS int)+799
   IF @ProdID2 IS NULL
      SET @ProdID2 = CAST(FLOOR(RAND()*200) AS int)+799
   IF @ProdID3 IS NULL
      SET @ProdID3 = CAST(FLOOR(RAND()*200) AS int)+799
   IF @Qty1 IS NULL
      SET @Qty1 = CAST(FLOOR(RAND()*15) AS int)
   IF @Qty2 IS NULL
      SET @Qty2 = CAST(FLOOR(RAND()*20) AS int)
   IF @Qty3 IS NULL
      SET @Qty3 = CAST(FLOOR(RAND()*10) AS int)
   IF @Price1 IS NULL
      SELECT @Price1 = ListPrice
      FROM Production.Product
      WHERE ProductID = @ProdID1
   IF @Price2 IS NULL
      SELECT @Price2 = ListPrice
      FROM Production.Product
      WHERE ProductID = @ProdID2
   IF @Price3 IS NULL
      SELECT @Price3 = ListPrice
      FROM Production.Product
      WHERE ProductID = @ProdID3

   INSERT INTO Sales.Customer 
      (SalesPersonID, 
      TerritoryID, 
      CustomerType)
      VALUES (@SalesPersonID, 
         @TerritoryID, 
         @custType)
   IF @@error <> 0
   ROLLBACK

   SELECT @CustomerID = ident_current('Sales.Customer')

   INSERT INTO Person.Contact 
      (FirstName, 
      LastName, 
      EmailAddress, 
      PasswordHash, 
      PasswordSalt)
      VALUES (@fname,
      @lname,
      @fname + '.' + @lname + '@contoso.com',
      @PasswordHash,
      @PasswordSalt)
   IF @@error <> 0
   ROLLBACK

   SELECT @ContactID = ident_current('Person.Contact')

   INSERT INTO Person.Address 
      (AddressLine1, 
      City, 
      StateProvinceID, 
      PostalCode)
      VALUES (@Address, 
         @City, 
         @StateProvinceID, 
         @PostalCode)
   IF @@error <> 0
   ROLLBACK

   SELECT @AddressID = ident_current('Person.Address')

   INSERT INTO Sales.SalesOrderHeader
      (DueDate,
      CustomerID,
      ContactID,
      SalesPersonID,
      TerritoryID,
      BilltoAddressID,
      ShiptoAddressID,
      ShipMethodID)
      VALUES (DATEADD(day,14,GetDate()),
         @CustomerID,
         @ContactID,
         @SalesPersonID,
         @TerritoryID,
         @AddressID,
         @AddressID,
         @ShipMethodID)
   IF @@error <> 0
   ROLLBACK

   SELECT @SalesOrderID = ident_current('Sales.SalesOrderHeader')

   INSERT INTO Sales.SalesOrderDetail
      (SalesOrderID,
      LineNumber,
      OrderQty,
      ProductID,
      SpecialOfferID,
      UnitPrice)
      VALUES (@SalesOrderID,
         1,
         @Qty1,
         @ProdID1,
         1,
         @Price1)
   IF @@error <> 0
    ROLLBACK

   INSERT INTO Sales.SalesOrderDetail
      (SalesOrderID,
      LineNumber,
      OrderQty,
      ProductID,
      SpecialOfferID,
      UnitPrice)
      VALUES (@SalesOrderID,
         2,
         @Qty2,
         @ProdID2,
         1,
         @Price2)
   IF @@error <> 0
   ROLLBACK

   INSERT INTO Sales.SalesOrderDetail
      (SalesOrderID,
      LineNumber,
      OrderQty,
      ProductID,
      SpecialOfferID,
      UnitPrice)
      VALUES (@SalesOrderID,
         3,
         @Qty3,
         @ProdID3,
         1,
         @Price3)
   IF @@error <> 0
   ROLLBACK

   COMMIT TRANSACTION
   GO

Connection to LON-DCSQL-01 (Create new customers and Orders)

   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Abbas', @fname = 'Syed' 
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Abercrombie', @fname = 'Kim'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Aboirous', @fname = 'Hazem'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Aboirous', @fname = 'Sam'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Acevedo', @fname = 'Humberto'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Achong', @fname = 'Gustavo'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Ackerman', @fname = 'Pilar'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Adams', @fname = 'Jay'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Adams', @fname = 'Terry'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Ajenstat', @fname = 'Francois'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Akers', @fname = 'Kim'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Akin', @fname = 'Gigdem'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Alberts', @fname = 'Amy'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Albrecht', @fname = 'Brian'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Alderson', @fname = 'Gregory'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Alexander', @fname = 'Michael'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Haas', @fname = 'Jonathan'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Haddock', @fname = 'Rich'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Hagege', @fname = 'Adina'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Hagens', @fname = 'Erin'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Hall', @fname = 'Don'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Hamilton', @fname = 'David'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Hamilton', @fname = 'James'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Hamlin', @fname = 'Jay'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Hammond', @fname = 'Maria'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Hance', @fname = 'Jim'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Hanif', @fname = 'Kerim'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Hankin', @fname = 'Alex'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Hanson', @fname = 'Mark'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Harnpadoungsataya', @fname = 'Sariya'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Harrington', @fname = 'Mark'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Harris', @fname = 'Keith'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Pai', @fname = 'Jyothi'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Pais', @fname = 'Wilson'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Pak', @fname = 'Jae'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Palit', @fname = 'Punya'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Parkinson', @fname = 'Eric'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Patel', @fname = 'Rajesh'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Patten', @fname = 'Michaell'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Pearson', @fname = 'Simon'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Pellow', @fname = 'Michael'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Penor', @fname = 'Lori'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Pelton', @fname = 'David'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Penuchot', @fname = 'Lionel'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Peoples', @fname = 'John'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Petculescu', @fname = 'Cristian'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Peters', @fname = 'James'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Philips', @fname = 'Carol'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London
      @lname = 'D''Hers', @fname = 'Thierry'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Daniels', @fname = 'David'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Danner', @fname = 'Ryan'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Danseglio', @fname = 'Mike'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Dawson', @fname = 'Matt'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'De Oliveira', @fname = 'Jose'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Decker', @fname = 'Barbara'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'DeGrasse', @fname = 'Kirk'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Dehli Halvorsen', @fname = 'Arne'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Delaney', @fname = 'Aiden'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Delgado', @fname = 'Axel'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Dellamore', @fname = 'Luca'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Locket', @fname = 'Darin'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Loh', @fname = 'Kok-Ho'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Loh', @fname = 'Marcus'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Lopez Garcia', @fname = 'Avelino'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Los', @fname = 'Jeremy'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Louverdis', @fname = 'George'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Low', @fname = 'Spencer'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Low', @fname = 'Jeff'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Lugo', @fname = 'Jose'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Lum', @fname = 'Richard'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Luper', @fname = 'Steve'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Luthra', @fname = 'Vidur'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Löb', @fname = 'Michael'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Teal', @fname = 'Andy'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Tejani', @fname = 'Sameer'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Teper', @fname = 'Jeff'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Thakur', @fname = 'Abhijit'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Tham', @fname = 'Bernard'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Thirunavukkarasu', @fname = 'Ram'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Thorpe', @fname = 'Steven'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Tiano', @fname = 'Mike'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Tibbott', @fname = 'Diane'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Danielle', @fname = 'Tiedt'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Ting', @fname = 'Hung-Fu'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Tippett', @fname = 'John'
   EXEC [SYD-SQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_Sydney 
      @lname = 'Tomiċ', @fname = 'Dragan'
   EXEC [LON-DCSQL-01].AdventureWorks_Demo2.dbo.up_NewCust_NewOrder_London 
      @lname = 'Leonetti', @fname = 'Francesca'
  
Connect to LON-DCSQL-01

   /* Step 1  -  Query the vOrders View to verify all transactions exist in the database on LON-DCSQL-01.  */
   SELECT TOP 300 *
      FROM [LON-DCSQL-01].AdventureWorks_Demo2.Sales.vOrders
      ORDER BY SalesOrderID DESC, LineNumber ASC

   /* Step 2  -  Query the vOrders View to verify all transactions exist in the database on SYD-SQL-01.   */
   SELECT TOP 300 *
      FROM [SYD-SQL-01].AdventureWorks_Demo2.Sales.vOrders
      ORDER BY SalesOrderID DESC, LineNumber ASC

Mirroring Demo

Connection to SYD-SQL-01

   /* Step 1  -  Creates backup of demo database.   */
   BACKUP DATABASE AdventureWorks
      TO DISK = '\\LON-DCSQL-01\Backups\Advworks.bak'
      WITH INIT
   GO

Connection to LON-DCSQL-01

   /* Step 2  -  The second step to setting up a mirrored database is the restore of a full DB backup onto the mirror server.   */
   RESTORE DATABASE AdventureWorks
      FROM DISK = '\\LON-DCSQL-01\Backups\Advworks.bak'
      WITH NORECOVERY,
      REPLACE
   GO

Connection to SYD-SQL-01 (New connection to test Mirror)

   /* Step 1  -  Execute Query against principal database.   */
   USE AdventureWorks
   GO
   SELECT  Name,
      StandardCost,
      ListPrice
      FROM Production.Product
   WHERE Name LIKE '%HL Mountain Frame%'
   GO

   /* Step 4  -  Execute Query against new mirror database.   */
   USE AdventureWorks
   GO
   SELECT  Name,
      StandardCost,
      ListPrice
   FROM Production.Product
   WHERE Name LIKE '%HL Mountain Frame%'
   GO

Connection to LON-DCSQL-01 (New connection to test Mirror)

   /* Step 2  -  Execute Query against mirror database. */
   USE AdventureWorks
   GO
   SELECT  Name,
      StandardCost,
      ListPrice
   FROM Production.Product
   WHERE Name LIKE '%HL Mountain Frame%'
   GO

   /* Stop the SQLService on the Principal */

   /* Step 3  -  Execute Query against what should now be the principal database.   */
   USE AdventureWorks
   GO
   SELECT  Name,
      StandardCost,
      ListPrice
   FROM Production.Product
   WHERE Name LIKE '%HL Mountain Frame%'
   GO