using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Transactions;


public partial class StoredProcedures
{
  [Microsoft.SqlServer.Server.SqlProcedure]
  public static void DoDistributed()
  {
    string ConnStr = 
      "server=server2;integrated security=sspi;database=pubs";
    using (TransactionScope ts = new TransactionScope())
    using (SqlConnection conn1 = 
           new SqlConnection("Context connection=true"))
    using (SqlConnection conn2 = 
           new SqlConnection(ConnStr))
    {
    conn1.Open();
    conn2.Open();
    // do work on connection 1
    // do work on connection 2
    // ask to commit the distributed transaction
    ts.Complete();
    }
  }
};
