Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This can be done by setting the -sourceserver option of the tablediff utility to the first server and the -destinationserver option to the second server. You can use the sys.Tables to iterate through each table in the database so that you can automate this process.</p> <p><strong>Edited</strong></p> <p>I also wanted to point out <a href="http://weblogs.sqlteam.com/jeffs/archive/2004/11/10/2737.aspx" rel="noreferrer">this article</a> which is a clever piece of t-sql code that may serve you better without the complications of tablediff</p> <p>Per your comment, here is an example. This is not an optimal way to do this in a production enviorment, but it should get the job done for you. You would probably be better off implementing this in SSIS if you need a more production worthy option. </p> <pre><code>SET QUOTED_IDENTIFIER ON DECLARE @TableNames as table ( id int identity(1,1), tableName varchar(100)) DECLARE @sTableDiff nvarchar(1000) DECLARE @tableName varchar(100) DECLARE @counter int DECLARE @maxCount int INSERT INTo @TableNames SELECT name FROM sysobjects WHERE type = 'U' SET @counter = 1 SELECT @maxCount = COUNT(name) FROM sysobjects WHERE type = 'U' WHILE @counter &lt; @maxCount Begin SELECT @tableName = tableName FROM @TableNames WHERE id = @counter SET @sTableDiff= ' "C:\Program Files\Microsoft SQL Server\90\COM\tablediff" -sourceserver Server1 -sourceuser sa -sourcepassword password -sourcedatabase YourDatabase -sourcetable ' + @tableName + ' -destinationserver Server2 -destinationuser sa -destinationpassword password -destinationdatabase YourDatabase -destinationtable ' + @tableName + ' -f c:\Diff' EXEC XP_CMDSHELL @sTableDiff Set @counter = @counter + 1 End </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload